BAPI_SALESORDER_CREATEFROMDAT2
-
概要
受注伝票を新規登録するBAPIです。販売伝票カテゴリが「C:受注」の伝票タイプのデータのみ登録可能です。
DATA: LS_ORDER_HEADER_IN TYPE BAPISDH1,
LS_ORDER_HEADER_INX TYPE BAPISDH1X,
LT_ORDER_ITEMS_IN TYPE TABLE OF BAPISDITM,
LT_ORDER_ITEMS_INX TYPE TABLE OF BAPISDITMX,
LT_PARTNERCHANGES TYPE TABLE OF BAPIPARNRC,
LT_ORDER_SCHEDULES_IN TYPE TABLE OF BAPISCHDL,
LT_ORDER_SCHEDULES_INX TYPE TABLE OF BAPISCHDLX,
LT_ORDER_CONDITIONS_IN TYPE TABLE OF BAPICOND,
LT_ORDER_CONDITIONS_INX TYPE TABLE OF BAPICONDX,
LV_SALESDOCUMENT TYPE VBAK-VBELN,
LT_RETURN TYPE TABLE OF BAPIRET2.
* パラメータに値を設定する
LV_SALESDOCUMENT = '0000001234'. " 受注伝票番号
LS_ORDER_HEADER_IN-PURCH_NO_C = 'PO-1234'. " 得意先発注番号
LS_ORDER_HEADER_INX-UPDATEFLAG = 'U'. " 更新区分
LS_ORDER_HEADER_INX-PURCH_NO_C = 'X'.
* :
* (以下略)
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = LV_SALESDOCUMENT
ORDER_HEADER_IN = LS_ORDER_HEADER_IN
ORDER_HEADER_INX = LS_ORDER_HEADER_INX
TABLES
RETURN = LT_RETURN
ORDER_ITEMS_IN = LT_ORDER_ITEMS_IN
ORDER_ITEMS_INX = LT_ORDER_ITEMS_INX
PARTNERCHANGES = LT_PARTNERCHANGES
ORDER_SCHEDULES_IN = LT_ORDER_SCHEDULES_IN
ORDER_SCHEDULES_INX = LT_ORDER_SCHEDULES_INX
ORDER_CONDITIONS_IN = LT_ORDER_CONDITIONS_IN
ORDER_CONDITIONS_INX = LT_ORDER_CONDITIONS_INX
.
* エラーメッセージの取得
READ TABLE LT_RETURN WITH KEY TYPE = 'E'.
* エラーメッセージがない場合
IF SY-SUBRC <> 0.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.