BAPI_GOODSMVT_CREATE修改创建人的问题
参考自http://www.ut163.com/create-material-movement-voucher-bapi-goodsmvt-create/
在做外围系统入库数据传SAP时候,业务部门发现物料凭证的生成人员不是操作者,提出需要修改,经检查BAPI_GOODSMVT_CREATE函数,发现和人有关的参数就header上的pr_uname,
bapi header ls_header-pr_uname = "指定用户"
经过传参发现不起作用,生成的物料凭证,创建人还是接口账号,不是代码中指定的。
1.解决方法
1.事务码SE18,选择Enhancement Spot,打开MB_GOODSMOVEMENT,
2.选择MB_BAPI_GOODSMVT_CREATE->实施,右键,点击”创建BADI实施”,结果如图。
3.双击新生成的实施“ZMB_BAPI_GOODSMVT_CREATE”,打开实施方法IF_EX_MB_BAPI_GOODSMVT_CREATE~EXTENSIONIN_TO_MATDOC,编辑代码如下。
method IF_EX_MB_BAPI_GOODSMVT_CREATE~EXTENSIONIN_TO_MATDOC. DATA: LT_EXTENSION type standard table of BAPIPAREX, LS_EXTENSION type BAPIPAREX, LS_ZEXTEN TYPE ZBAPI_TE_XMKPF. LOOP AT EXTENSION_IN INTO LS_EXTENSION WHERE STRUCTURE = 'ZBAPI_TE_XMKPF'. LS_ZEXTEN = LS_EXTENSION-VALUEPART1. IF LS_ZEXTEN-USNAM IS NOT INITIAL. CS_IMKPF-USNAM = LS_ZEXTEN-USNAM. ENDIF. EXIT. ENDLOOP. endmethod.
4,在上面的代码中使用了结构,ZBAPI_TE_XMKPF,此结构是从标准结构BAPI_TE_XMKPF复制来的,并增加字段USNAM,结构如下
5.现在,只要在BAPI_GOODSMVT_CREATE中把物料凭证创建人写到增强结构中,就可以了,
DATA: LT_EXTENSION type standard table of BAPIPAREX, LS_EXTENSION type BAPIPAREX. DATA: WA_ZEXTEN LIKE ZBAPI_TE_XMKPF. WA_ZEXTEN-USNAM = LS_ZSDT0226_CONF2-ZCREN. "收货人 LS_EXTENSION-VALUEPART1 = WA_ZEXTEN. LS_EXTENSION-STRUCTURE = 'ZBAPI_TE_XMKPF'. "CONDENSE lt_extension-valuepart1 . APPEND LS_EXTENSION TO LT_EXTENSION. ....... CALL FUNCTION 'BAPI_GOODSMVT_CREATE' EXPORTING GOODSMVT_HEADER = L_HEADER GOODSMVT_CODE = L_CODE IMPORTING GOODSMVT_HEADRET = LS_GOODSMVT TABLES GOODSMVT_ITEM = LT_ITEM * GOODSMVT_SERIALNUMBER = RETURN = LT_RETURN * GOODSMVT_SERV_PART_DATA = EXTENSIONIN = LT_EXTENSION