流程订单的物料清单数据
bapi:CO_XT_COMPONENT_ADD
部分参考代码:
DATA: LS_STORAGE_LOCATION TYPE COXT_S_STORAGE_LOCATION,
LS_STORAGE_LOCATIONX TYPE COXT_S_STORAGE_LOCATIONX,
LS_REQU_QUAN TYPE COXT_S_QUANTITY,
LV_OPERATION TYPE CO_APLZL,
LV_BATCH TYPE COXT_BATCH,
LV_BATCHX TYPE COXT_BATCHX,
LV_POSTP TYPE POSTP,
LV_SEQUENCE TYPE PLNFOLGE,
LV_MATERIAL TYPE MATNR,
LV_POSITIONNO TYPE POSITIONNO,
LV_NUMC TYPE NUMC4.
DATA:LV_UNIT TYPE T006-ISOCODE.
DATA:LV_TABIX TYPE SY-TABIX .
DATA:LS_RETURN TYPE COXT_BAPIRETURN.
DATA:LV_ERROR TYPE C.
TYPES: BEGIN OF TY_RESB_BT.
INCLUDE TYPE RESBB.
TYPES: INDOLD TYPE SYST_TABIX.
TYPES: NO_REQ_UPD TYPE SYST_DATAR.
TYPES: END OF TY_RESB_BT.
TYPES TT_RESB_BT TYPE TABLE OF TY_RESB_BT.
FIELD-SYMBOLS: <FT_RESB_BT> TYPE TT_RESB_BT,
<FS_RESB_BT> TYPE TY_RESB_BT.
SORT PT_ORD BY WERKS PROJN ZPROJPERS AUART AUFNR ZDELFLAG PLNBEZ MATNR.
DATA:LV_INDEX TYPE SY-TABIX.
DATA:LV_QUANTITY LIKE AFKO-GAMNG.
LV_QUANTITY = 0.
LOOP AT PT_ORD INTO DATA(LS_ORD).
LV_INDEX = SY-TABIX.
LV_QUANTITY = LV_QUANTITY + LS_ORD-BDMNG.
AT END OF MATNR.
READ TABLE PT_ORD INTO LS_ORD INDEX LV_INDEX.
LS_STORAGE_LOCATION-WERKS = LS_ORD-WERKS.
LS_STORAGE_LOCATIONX-WERKS = 'X'.
LS_REQU_QUAN-QUANTITY = LV_QUANTITY." LS_ORD-BDMNG.
LS_REQU_QUAN-UOM = LS_ORD-MEINS.
LV_POSITIONNO = '0010'.
LV_POSTP = 'L'.
LV_MATERIAL = LS_ORD-MATNR.
SELECT SINGLE AUFNR, AUFPL INTO @DATA(LS_AFKO)
FROM AFKO
WHERE AUFNR = @PV_AUFNR.
IF SY-SUBRC EQ 0.
* Fetch operation to which it has to be assigned
SELECT SINGLE AUFPL, APLZL, PLNFL INTO @DATA(LS_AFVC)
FROM AFVC
WHERE AUFPL = @LS_AFKO-AUFPL.
IF SY-SUBRC EQ 0.
LV_OPERATION = LS_AFVC-APLZL.
LV_SEQUENCE = LS_AFVC-PLNFL.
ENDIF.
ENDIF.
CALL FUNCTION 'CO_XT_COMPONENT_ADD'
EXPORTING
IS_ORDER_KEY = PV_AUFNR
I_MATERIAL = LV_MATERIAL
IS_REQU_QUAN = LS_REQU_QUAN
I_OPERATION = LV_OPERATION
I_SEQUENCE = LV_SEQUENCE
IS_STORAGE_LOCATION = LS_STORAGE_LOCATION
IS_STORAGE_LOCATIONX = LS_STORAGE_LOCATIONX
I_BATCH = LV_BATCH
I_BATCHX = LV_BATCHX
I_POSTP = LV_POSTP
I_POSNO = LV_POSITIONNO
IMPORTING
ES_BAPIRETURN = LS_RETURN
E_ERROR_OCCURRED = LV_ERROR.
IF LV_ERROR = SPACE.
CLEAR: LV_NUMC,
LS_RETURN.
* Modify POSNR via ASSIGN before DB update to correct the blank
* item number in Components due to incompatible types of I_POSNO
* (type CIF_R3RES-POSITIONNO) and RESB-POSNR
ASSIGN ('(SAPLCOBC)RESB_BT[]') TO <FT_RESB_BT>.
LOOP AT <FT_RESB_BT> ASSIGNING <FS_RESB_BT>.
LV_NUMC = SY-TABIX * 10.
<FS_RESB_BT>-POSNR = LV_NUMC