用这个BAPI:BAPI_COPAACTUALS_POSTCOSTDATA 记录销售成本的时候,发现不能return生产的co凭证号,利用内存应该是最好的方法。

SCN上的帖子:https://blogs.sap.com/2013/11/22/to-get-copa-document-number-returned-by-bapicopaactualspostcostdata-posting/

参照这个方法我做了第四代增强的开发

    GV_CALL_COPA_BAPI_INDICATOR = 'Y' .
EXPORT GV_CALL_COPA_BAPI_INDICATOR TO MEMORY ID 'ZCOPA_UPD_BAPI1'.



IMPORT GV_MEMID_COPADOC FROM MEMORY ID 'ZCOPA_UPD_BAPI'.

RKE_SERVE_ACT_DOC_NUMBER

代码如下:

*$*$-Start: ZEHM_POINT_001----------------------------------------------------------------------$*$*
ENHANCEMENT ZFICO_COPA_EHMP_UPD_BY_BAPI. "active version
*EHM BY ZHAIMING 2016-10-20 23:39:29 bapi用
DATA: GV_MEMID_COPADOC TYPE RKE_BELNR,
GV_CALL_COPA_BAPI_INDICATOR TYPE CHAR1. DATA: BEGIN OF LW_LINE_ITEM,
BELNR TYPE RKE_BELNR,
END OF LW_LINE_ITEM.
FIELD-SYMBOLS <FS_COPADOC> TYPE ANY. IMPORT GV_CALL_COPA_BAPI_INDICATOR FROM MEMORY ID 'ZCOPA_UPD_#### . IF GV_CALL_COPA_BAPI_INDICATOR EQ 'Y'.
ASSIGN LINE_ITEM_TAB TO <FS_COPADOC>.
MOVE-CORRESPONDING <FS_COPADOC> TO LW_LINE_ITEM .
GV_MEMID_COPADOC = LW_LINE_ITEM-BELNR .
EXPORT GV_MEMID_COPADOC TO MEMORY ID 'ZCOPA_UPD####'.
ENDIF.
ENDENHANCEMENT.
*$*$-End: ZEHM_POINT_001----------------------------------------------------------------------$*$*

我同事没有看我写的代码也做了这个增强,思路就是在增强里调用使用BAPI程序的子程序,方法可以 但是针对某个程序做开发,不能广泛适用。

*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT ZENH_####. "active version
*
PERFORM ######### IN PROGRAM ZFIR####
USING ERKRS
T_PALEDGER
LINE_ITEM_TAB[].
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*

附原帖内容:

To get copa document number returned by “BAPI_COPAACTUALS_POSTCOSTDATA” posting

Abstract  

While posting COPA document by BAPI “BAPI_COPAACTUALS_POSTCOSTDATA” , this BAPI

does not return successful records with generated copa document number.

But in case system need to capture generated copa doc number there is workaround with

implicit enhancement withing bapi as described in doc,

About the Domain

SAP ABAP/FICO module can use this document. This will help them to get generated COPA

document number which is posted by BAPI_COPAACTUALS_POSTCOSTDATA.

Steps involved

The step that needs to be followed is as below.

It’s divided mainly into 2 section .

A. custom program

B. Enhancement

Create a Custom Program like ZCOPA_UPDATE .

Please follow steps given below for this program.

  • Export BAPI_Call indicator from your program to memory id

This indicator will make sure enhancement will be trigger only in case bapi will be called for custom program

gv_call_copa_bapi_indicator = ‘Y’ .

EXPORT gv_call_copa_bapi_indicator TO MEMORY ID ‘ZCOPA_UPD_BAPI1’.

  • Call Bapi to post data

       *To post Copa document

CALL FUNCTION ‘BAPI_COPAACTUALS_POSTCOSTDATA’

EXPORTING

operatingconcern = ip_operatingconcern

testrun          = ip_testrun

TABLES

inputdata        = lt_bapi_copa_data

fieldlist        = lt_bapi_copa_field

return           = lt_return.

  • IF lt_return[] IS INITIAL ,means copa doc posted ,then only read copa document number .

In case there is any record in return with message type E or A it means there is an error while generating copa doc , so do not import                doc numner from  ID ‘ZCOPA_UPD_BAPI’

  • CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
  • Importing copa document number from enhancement only if lt_return is initial

or have S,I,W message type.because doc number can be  populated in error cases also as this enhancement from where exporting  memory

ID ‘ZCOPA_UPD_BAPI’ is before actual posting , so always check return table (is initial or have S,I,W message               type only)

IMPORT gv_memid_copadoc  FROM MEMORY ID ‘ZCOPA_UPD_BAPI’ .

So gv_memid_copadoc  will have copa document number which is generated.

Create a implicit enhancement like ZCOPA_ENH_UPDATE .  

Please follow steps given below for this enhancement.

  • Create implicit enhancement in FM “RKE_SERVE_ACT_DOC_NUMBER “  in the end of function.

Which will be used during BAPI posting as this FM function to get next available document number for COPA posting , But actual posting will happen after this FM .

So at this stage we will be able to get COPA doc number which will be generated later on and confirm if there is no error in return table of BAPI .

As Actual copa posting perform  is refreshing inputdata table , and not returning success message we need to use this way .

  • Import BAPI called by Custom Program indicator to make sure enhancement will be triggered only if BAPI call from custom program

IMPORT gv_call_copa_bapi_indicator FROM MEMORY ID ‘ZCOPA_UPD_BAPI1’ .

if gv_call_copa_bapi_indicator EQ ‘Y’ .

then only create following steps

  • Define field-symbol  with genric type as line item table which contain copa records is genric type and define workarea with field Belnr.

*As line item table type genric , so get doc no using field symbol
ASSIGN LINE_ITEM_TAB to <fs_copadoc>.

*As field symbol type any defined work area with belnr which contain copa doc no
MOVE-CORRESPONDING <fs_copadoc> to lw_line_item .

  • Get copa document number in variable

GV_MEMID_COPADOC = lw_line_item–belnr .

  • And Export Copa Doc number to memory id.

EXPORT GV_MEMID_COPADOC to memory id ‘ZCOPA_UPD_BAPI’.

Output

Copa document number will be retrieved successfully from BAPI.

Conclusion

This code could be used to get copa document number generated through BAPI  psoting .

获利能力分析COPA的BAPI:BAPI_COPAACTUALS_POSTCOSTDATA 通过增强返回凭证号的更多相关文章

  1. springmvc 通过异常增强返回给客户端统一格式

    在springmvc开发中,我们经常遇到这样的问题:逻辑正常执行时返回客户端指定格式的数据,比如json,但是遇NullPointerException空指针异常,NoSuchMethodExcept ...

  2. SAP BAPI创建批次 为保存内部对象号

    使用BAPI:BAPI_BATCH_CREATE 创建批次时,能够保存成功,但是MCH1表和KSSK表中没有内部对象号. 无奈,查找源码. 最后在BAPI中调用的这个函数这里找到了问题.此处kzcla ...

  3. Wireshark分析实战:某达速递登录帐号密码提取

    - 准备工作 首先,备好Wireshark,打开,在外网网卡上抓包. 其次,用浏览器访问http://www.yundaex.com/cn/index.php,并在手机上下载安装其APP,找到登录页面 ...

  4. 【MM系列】SAP MM模块-BAPI:BAPI_GOODSMVT_CREATE的CODE分析

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-BAPI:BAPI ...

  5. SAP 常用增强记录文档

    转自:http://blog.csdn.net/budaha 20170215需要一个PR 修改保存时候的增强,目的是同步PR的处理状态 EBAN-STATU 到一个自建表ZTPRTOPO,记得有个P ...

  6. Hadoop源代码分析

    http://wenku.baidu.com/link?url=R-QoZXhc918qoO0BX6eXI9_uPU75whF62vFFUBIR-7c5XAYUVxDRX5Rs6QZR9hrBnUdM ...

  7. 大型服装集团BI决策系统的分析主题模块

    一般BI商业智能解决方案都包含财务.销售.客户等分析模块,本文分享的是某大型服装集团通过帆软FineBI建设的BI决策系统.该决策系统主要针对财务.资金.采购.生产.库存.物流.销售.渠道.产品.客户 ...

  8. kafka系列四、kafka架构原理、高可靠性存储分析及配置优化

    一.概述 Kakfa起初是由LinkedIn公司开发的一个分布式的消息系统,后成为Apache的一部分,它使用Scala编写,以可水平扩展和高吞吐率而被广泛使用.目前越来越多的开源分布式处理系统如Cl ...

  9. 扩增子分析QIIME2. 1简介和安装

    原网站:https://blog.csdn.net/woodcorpse/article/details/75103929 声明:本文为QIIME2官方帮助文档的中文版,由中科院遗传发育所刘永鑫博士翻 ...

随机推荐

  1. python调试 设置断点

    1在所需要调试的地方加入如下代码: import pdb    pdb.set_trace() 2调试代码常用命令: 实例请见参考文献: 1http://www.cnblogs.com/qi09/ar ...

  2. GPS(2)关于位置的3个示例,实时获取GPS定位数据,求两个经纬点距离,邻近某个区域圆时警告

    实时获取GPS定位数据 import android.app.Activity; import android.content.Context; import android.location.Loc ...

  3. centos 搭建 darwin calendar 服务器

    方法一(官网方法): useradd caluser ----为日历服务器建立一个新用户,方便管理 passwd caluser -----新用户更改密码 su caluser mkdir ~/Cal ...

  4. Innodb的启动

    Innodb的启动与关闭 1. 启动函数的流程 innobase_start_or_create_for_mysql 启动的主要步骤包括: 1. 初始化innodb的参数 2. 初始化系统结构 主要结 ...

  5. poj3692

    首先这道题很容易想到二分图相关(给的很明确了): 但是我们发现,男孩之间都互相认识,女孩之间也互相认识 这样是不能划分点集的 但是男孩之间都互相认识,女孩之间也互相认识,所以男孩和男孩,女孩和女孩之间 ...

  6. 原创js模型驱动

    使用ajax方式请求数据,向页面展示一个对象的时候,往往让人头疼的是一大堆 .val()  .text()方法,这样做固然不会出错,但是效率太低 以下提供一个自己编写的Jquery模型驱动插件,正在测 ...

  7. 西南科技大学第十一届ACM程序设计大赛发言稿

    西南科技大学第十一届ACM程序设计大赛发言稿 各位老师.志愿者及参赛选手: 大家好,我是来自计科学院卓软1301的哈特13,很荣幸今天能站在这里代表参赛选手发言. 回想起来,我参加ACM比赛已经快两年 ...

  8. Entity Framework 增删改查和事务操作

    1.增加对象 DbEntity db = new DbEntity(); //创建对象实体,注意,这里需要对所有属性进行赋值(除了自动增长主键外),如果不赋值,则会数据库中会被设置为NULL(注意是否 ...

  9. 为枚举类型添加说明 zt

    enum Orientation { [DescriptionAttribute("东")] East, [DescriptionAttribute("南")] ...

  10. ubuntu安装和卸载软件命令

    ubuntu安装和卸载软件命令 Ubuntu软件安装与删除相关命令 安装软件 命令: apt-get install softname1 softname2 softname3…… 卸载软件 命令: ...