凭证创建时(创建人)需要更改为其它人员
1. 复制BAPI_TE_XMKPF, 增加字段USNAM
2. SE18: BADI名称 - MB_BAPI_GOODSMVT_CREATE 创建badi实施
3. 增强代码编辑如下:
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. 只要在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_extension-valuepart1 = wa_zexten.
ls_extension-structure = 'ZBAPI_TE_XMKPF'.
append ls_extension to lt_extension.
*其它代码
........
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = header
goodsmvt_code = code
importing
materialdocument = mat_doc
tables
goodsmvt_item = itab
goodsmvt_serialnumber = goodsmvt_serialnumber
return = gt_return
extensionin = lt_extension. "增强