*不知道为什么明细信息更新不了。待解决。。。
REPORT YTEST_SAI_20210208.
DATA:
LDF_VBELN TYPE BAPIVBELN-VBELN,
LDS_HEADER TYPE BAPISDH1X,
LDT_RETURN TYPE STANDARD TABLE OF BAPIRET2,
LDT_EXT TYPE STANDARD TABLE OF BAPIPAREX,
LDS_EXT TYPE BAPIPAREX,
LDS_VBAK TYPE BAPE_VBAK,
LDS_VBAKX TYPE BAPE_VBAKX,
LDS_VBAP TYPE BAPE_VBAP,
LDS_VBAPX TYPE BAPE_VBAPX,
LDS_ORDER TYPE BAPISDITM,
LDS_ORDERX TYPE BAPISDITMX,
LDT_ORDER TYPE STANDARD TABLE OF BAPISDITM,
LDT_ORDERX TYPE STANDARD TABLE OF BAPISDITMX.
* △受注番号の設定
LDF_VBELN = '0000004969'. "受注番号
* △受注伝票チェックリストの設定
LDS_HEADER-UPDATEFLAG = 'U'. "登録された販売伝票の変更
* ▲ヘッダ項目(VBAK)
* △拡張項目の設定
LDS_VBAK-VBELN = '0000004969'. "販売伝票
LDS_VBAK-/XLSO/SO_VALD_FM = '20210209'. "タイプ DATS の項目
LDS_VBAK-/XLSO/CATALOG_ID = 'TEST_SAI'. "製品カタログ番号
LDS_VBAKX-VBELN = '0000004969'. "販売伝票
LDS_VBAKX-/XLSO/SO_VALD_FM = 'X'. "タイプ DATS の項目
LDS_VBAKX-/XLSO/CATALOG_ID = 'X'. "製品カタログ番号
* △カスタマ拡張の設定(拡張追加の項目)
CLEAR LDS_EXT.
LDS_EXT-STRUCTURE = 'BAPE_VBAK'.
LDS_EXT-VALUEPART1 = LDS_VBAK.
APPEND LDS_EXT TO LDT_EXT.
CLEAR LDS_EXT.
LDS_EXT-STRUCTURE = 'BAPE_VBAKX'.
LDS_EXT-VALUEPART1 = LDS_VBAKX.
APPEND LDS_EXT TO LDT_EXT.
* ▲明細項目(VBAP)
* △拡張項目の設定
LDS_VBAP-VBELN = '0000004969'.
LDS_VBAP-POSNR = '000010'.
LDS_VBAP-/XLSO/COURSE_ID = '12345678'.
LDS_VBAP-/XLSO/COURSE_BDA = '20210201'.
LDS_VBAP-/XLSO/COURSE_EDA = '20211231'.
LDS_VBAPX-VBELN = '0000004969'.
LDS_VBAPX-POSNR = '000010'.
LDS_VBAPX-COURSE_ID = 'X'.
LDS_VBAPX-COURSE_BEGDA = 'X'.
LDS_VBAPX-COURSE_ENDDA = 'X'.
* △カスタマ拡張の設定(拡張追加の項目)
CLEAR LDS_EXT.
LDS_EXT-STRUCTURE = 'BAPE_VBAP'.
* LDS_EXT-VALUEPART1 = LDS_VBAP.
CALL METHOD CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C
EXPORTING
IM_VALUE = LDS_VBAP
IMPORTING
EX_CONTAINER = LDS_EXT-VALUEPART1
* EXCEPTIONS
* ILLEGAL_PARAMETER_TYPE = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
APPEND LDS_EXT TO LDT_EXT.
CLEAR LDS_EXT.
LDS_EXT-STRUCTURE = 'BAPE_VBAPX'.
LDS_EXT-VALUEPART1 = LDS_VBAPX.
APPEND LDS_EXT TO LDT_EXT.
* △受注明細の設定
LDS_ORDER-ITM_NUMBER = '000010'.
APPEND LDS_ORDER TO LDT_ORDER.
LDS_ORDERX-ITM_NUMBER = '000010'.
LDS_ORDERX-UPDATEFLAG = 'U'.
APPEND LDS_ORDERX TO LDT_ORDERX.
* ■受注変更
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = LDF_VBELN "受注番号
* ORDER_HEADER_IN =
ORDER_HEADER_INX = LDS_HEADER "U:登録された販売伝票の変更
* SIMULATION =
* BEHAVE_WHEN_ERROR = ' '
* INT_NUMBER_ASSIGNMENT = ' '
* LOGIC_SWITCH =
* NO_STATUS_BUF_INIT = ' '
TABLES
RETURN = LDT_RETURN "リターンメッセージ
ORDER_ITEM_IN = LDT_ORDER
ORDER_ITEM_INX = LDT_ORDERX
* PARTNERS =
* PARTNERCHANGES =
* PARTNERADDRESSES =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
* SCHEDULE_LINES =
* SCHEDULE_LINESX =
* ORDER_TEXT =
* ORDER_KEYS =
* CONDITIONS_IN =
* CONDITIONS_INX =
EXTENSIONIN = LDT_EXT
* EXTENSIONEX =
.
LOOP AT LDT_RETURN TRANSPORTING NO FIELDS
WHERE TYPE = 'A' OR TYPE = 'E'.
EXIT.
ENDLOOP.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
BREAK-POINT.
受注変更bapi
最新推荐文章于 2021-12-09 16:48:18 发布