Hi,
I have a requirement in which I have to create a custom program to update zfields of certain records in VBAP standard table.
I used BAPI_SALESORDER_CHANGE FM to operate the update and BAPI_TRANSACTION_COMMIT, and it is working, the record is successfully updated. However, the change is not written in changelog of sales order.
Upon further inspection, Tables CDHDR and CDPOS contain no record of the update.
Both the zfields I am updating are correctly appended to VBAP, and also appended in BAPE_VBAP, BAPE_VBAPX, VBAPKOZ and VBAPKOZX, and the data element of both fields have change doc ticked, VBAP table is not ticked for logs.
How could I do to have the changes visible in changelog ?
Below is my source code :
DATA: t_line LIKE bapisditm OCCURS 0 WITH HEADER LINE,t_linex LIKE bapisditmx OCCURS 0 WITH HEADER LINE,
lt_icdtxt_verkbeleg TYPE TABLE OF cdtxt.
order_headerx-updateflag = 'U'.
t_line-itm_number = ls_vbap-posnr.
t_line-material = ls_vbap-matnr.
t_line-hg_lv_item = ls_vbap-uepos.
APPEND t_line.
t_linex-itm_number = ls_vbap-posnr.
t_linex-updateflag = 'U'.
APPEND t_linex.
CLEAR bape_vbap.
bape_vbap-vbeln = ls_vbap-vbeln.
bape_vbap-posnr = ls_vbap-posnr.
bape_vbap-zz_qte_refer = ls_vbap-kwmeng.
bape_vbap-zz_unit_refer = ls_vbap-vrkme.
t_exten-structure = 'BAPE_VBAP'.
t_exten-valuepart1 = bape_vbap.
APPEND t_exten.
CLEAR bape_vbapx.
bape_vbapx-vbeln = ls_vbap-vbeln.
bape_vbapx-posnr = ls_vbap-posnr.
bape_vbapx-zz_qte_refer = 'X'.
bape_vbapx-zz_unit_refer = 'X'.
t_exten-structure = 'BAPE_VBAPX'.
t_exten-valuepart1 = bape_vbapx.
APPEND t_exten.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = ls_vbap-vbeln
order_header_inx = order_headerx
TABLES
return = t_return
order_item_in = t_line
order_item_inx = t_linex
extensionin = t_exten.
CALL FUNCTION 'VERKBELEG_WRITE_DOCUMENT'
EXPORTING
objectid = CONV cdhdr-objectid( ls_vbap-vbeln )
tcode = sy-tcode
utime = sy-uzeit
udate = sy-datum
username = sy-uname
upd_vbap = 'X'
TABLES
icdtxt_verkbeleg = lt_icdtxt_verkbeleg.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.