假設我想修改S/4HANA裏Sales Order擡頭的Service Date字段SERV_DATE:數據庫
首先從數據庫表VBKD裏查找到SERV_DATE修改以前的值爲2020年1月1日api
使用以下代碼,將這個字段的值改爲2020年1月2日。code
REPORT zchange_so1. DATA: lv_num TYPE bapivbeln-vbeln, ls_doc_header TYPE bapisdhd1, lt_vbap TYPE STANDARD TABLE OF vbap. lv_num = '0000000268'. CALL FUNCTION 'SD_VBAP_READ_WITH_VBELN' EXPORTING i_vbeln = lv_num TABLES et_vbap = lt_vbap EXCEPTIONS record_not_found = 1 OTHERS = 2. BREAK-POINT. DATA: i_order_header_in LIKE bapisdhd1 . DATA: i_order_header_inx LIKE bapisdhd1x, lt_bapiret2 LIKE bapiret2 OCCURS 0 WITH HEADER LINE. i_order_header_inx-updateflag = 'U'. i_order_header_in-serv_date = '20200102' . i_order_header_inx-serv_date = 'X'. CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE' EXPORTING salesdocument = lv_num order_header_in = i_order_header_in order_header_inx = i_order_header_inx TABLES return = lt_bapiret2. clear: lt_bapiret2. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' IMPORTING RETURN = lt_bapiret2. BREAK-POINT.
執行以後,從輸出參數lt_bapiret2裏查看到這個Sales Order已經成功被更新了。blog
從後臺數據庫表VBKD裏查看到這個字段的值也已經成功更新了:class
要獲取更多Jerry的原創文章,請關注公衆號"汪子熙":後臺