下面的P_CHANGE为D跟I的时候都是OK的,但是用U就不行
*--------------------------------------------------------------------*
*-----原料POCOMPONENTS
*--------------------------------------------------------------------*
****-----第1行
G_CHANGE_ID = P_CHANGE."'D'.
G_ITEM_NO = G_ITEM_NO + 1.
GS_POCOMPONENTS-PO_ITEM = '00010'.
GS_POCOMPONENTS-SCHED_LINE = '0001'.
GS_POCOMPONENTS-ITEM_NO = G_ITEM_NO. "'0001'.
GS_POCOMPONENTS-MATERIAL = '000000002800200001'.
GS_POCOMPONENTS-ENTRY_QUANTITY = 1003.
GS_POCOMPONENTS-PLANT = '1000'.
GS_POCOMPONENTS-REQ_DATE = SY-DATUM.
GS_POCOMPONENTS-ENTRY_UOM = 'TON'.
GS_POCOMPONENTS-CHANGE_ID = G_CHANGE_ID."'I'.
APPEND GS_POCOMPONENTS TO GT_POCOMPONENTS.
****-----填充要修改字段的参数
CLEAR GS_POCOMPONENTSX.
PERFORM FILL_CHECK_STRUCTURE USING 'BAPIMEPOCOMPONENTX'
'GS_POCOMPONENTS'
'GS_POCOMPONENTSX'
C_X.
GS_POCOMPONENTSX-PO_ITEM = GS_POCOMPONENTS-PO_ITEM.
GS_POCOMPONENTSX-SCHED_LINE = GS_POCOMPONENTS-SCHED_LINE.
GS_POCOMPONENTSX-ITEM_NO = GS_POCOMPONENTS-ITEM_NO.
APPEND GS_POCOMPONENTSX TO GT_POCOMPONENTSX.
****-----第2行
G_ITEM_NO = G_ITEM_NO + 1.
GS_POCOMPONENTS-PO_ITEM = '00010'.
GS_POCOMPONENTS-SCHED_LINE = '0001'.
GS_POCOMPONENTS-ITEM_NO = G_ITEM_NO. "'0001'.
GS_POCOMPONENTS-MATERIAL = '000000002800200001'.
GS_POCOMPONENTS-ENTRY_QUANTITY = 1004.
GS_POCOMPONENTS-PLANT = '1000'.
GS_POCOMPONENTS-REQ_DATE = SY-DATUM.
GS_POCOMPONENTS-ENTRY_UOM = 'TON'.
GS_POCOMPONENTS-CHANGE_ID = G_CHANGE_ID."'I'.
APPEND GS_POCOMPONENTS TO GT_POCOMPONENTS.
****-----填充要修改字段的参数
CLEAR GS_POCOMPONENTSX.
PERFORM FILL_CHECK_STRUCTURE USING 'BAPIMEPOCOMPONENTX'
'GS_POCOMPONENTS'
'GS_POCOMPONENTSX'
C_X.
GS_POCOMPONENTSX-PO_ITEM = GS_POCOMPONENTS-PO_ITEM.
GS_POCOMPONENTSX-SCHED_LINE = GS_POCOMPONENTS-SCHED_LINE.
GS_POCOMPONENTSX-ITEM_NO = GS_POCOMPONENTS-ITEM_NO.
APPEND GS_POCOMPONENTSX TO GT_POCOMPONENTSX.
*--------------------------------------------------------------------*
*-----计划行POSCHEDULE
*--------------------------------------------------------------------*
LOOP AT BAPI_POSCHEDULE.
CLEAR :GS_POSCHEDULE,GS_POSCHEDULEX.
MOVE-CORRESPONDING BAPI_POSCHEDULE TO GS_POSCHEDULE.
APPEND GS_POSCHEDULE TO GT_POSCHEDULE.
PERFORM FILL_CHECK_STRUCTURE USING 'bapimeposchedulx'
'gs_poschedule'
'gs_poschedulex'
C_X.
GS_POSCHEDULEX-PO_ITEM = BAPI_POSCHEDULE-PO_ITEM. "采购凭证的项目编号 zift_mm003_matnr-ebelp
GS_POSCHEDULEX-SCHED_LINE = BAPI_POSCHEDULE-SCHED_LINE.
APPEND GS_POSCHEDULEX TO GT_POSCHEDULEX.
ENDLOOP.
*--------------------------------------------------------------------*
*-----执行BAPI
*--------------------------------------------------------------------*
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = P_EBELN"GS_PURCHASEORDER
TABLES
RETURN = GT_RETURN
POITEM = GT_POITEM
POITEMX = GT_POITEMX
POSCHEDULE = GT_POSCHEDULE
POSCHEDULEX = GT_POSCHEDULEX
POCOMPONENTS = GT_POCOMPONENTS
POCOMPONENTSX = GT_POCOMPONENTSX.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*--------------------------------------------------------------------*
*-----原料POCOMPONENTS
*--------------------------------------------------------------------*
****-----第1行
G_CHANGE_ID = P_CHANGE."'D'.
G_ITEM_NO = G_ITEM_NO + 1.
GS_POCOMPONENTS-PO_ITEM = '00010'.
GS_POCOMPONENTS-SCHED_LINE = '0001'.
GS_POCOMPONENTS-ITEM_NO = G_ITEM_NO. "'0001'.
GS_POCOMPONENTS-MATERIAL = '000000002800200001'.
GS_POCOMPONENTS-ENTRY_QUANTITY = 1003.
GS_POCOMPONENTS-PLANT = '1000'.
GS_POCOMPONENTS-REQ_DATE = SY-DATUM.
GS_POCOMPONENTS-ENTRY_UOM = 'TON'.
GS_POCOMPONENTS-CHANGE_ID = G_CHANGE_ID."'I'.
APPEND GS_POCOMPONENTS TO GT_POCOMPONENTS.
****-----填充要修改字段的参数
CLEAR GS_POCOMPONENTSX.
PERFORM FILL_CHECK_STRUCTURE USING 'BAPIMEPOCOMPONENTX'
'GS_POCOMPONENTS'
'GS_POCOMPONENTSX'
C_X.
GS_POCOMPONENTSX-PO_ITEM = GS_POCOMPONENTS-PO_ITEM.
GS_POCOMPONENTSX-SCHED_LINE = GS_POCOMPONENTS-SCHED_LINE.
GS_POCOMPONENTSX-ITEM_NO = GS_POCOMPONENTS-ITEM_NO.
APPEND GS_POCOMPONENTSX TO GT_POCOMPONENTSX.
****-----第2行
G_ITEM_NO = G_ITEM_NO + 1.
GS_POCOMPONENTS-PO_ITEM = '00010'.
GS_POCOMPONENTS-SCHED_LINE = '0001'.
GS_POCOMPONENTS-ITEM_NO = G_ITEM_NO. "'0001'.
GS_POCOMPONENTS-MATERIAL = '000000002800200001'.
GS_POCOMPONENTS-ENTRY_QUANTITY = 1004.
GS_POCOMPONENTS-PLANT = '1000'.
GS_POCOMPONENTS-REQ_DATE = SY-DATUM.
GS_POCOMPONENTS-ENTRY_UOM = 'TON'.
GS_POCOMPONENTS-CHANGE_ID = G_CHANGE_ID."'I'.
APPEND GS_POCOMPONENTS TO GT_POCOMPONENTS.
****-----填充要修改字段的参数
CLEAR GS_POCOMPONENTSX.
PERFORM FILL_CHECK_STRUCTURE USING 'BAPIMEPOCOMPONENTX'
'GS_POCOMPONENTS'
'GS_POCOMPONENTSX'
C_X.
GS_POCOMPONENTSX-PO_ITEM = GS_POCOMPONENTS-PO_ITEM.
GS_POCOMPONENTSX-SCHED_LINE = GS_POCOMPONENTS-SCHED_LINE.
GS_POCOMPONENTSX-ITEM_NO = GS_POCOMPONENTS-ITEM_NO.
APPEND GS_POCOMPONENTSX TO GT_POCOMPONENTSX.
*--------------------------------------------------------------------*
*-----计划行POSCHEDULE
*--------------------------------------------------------------------*
LOOP AT BAPI_POSCHEDULE.
CLEAR :GS_POSCHEDULE,GS_POSCHEDULEX.
MOVE-CORRESPONDING BAPI_POSCHEDULE TO GS_POSCHEDULE.
APPEND GS_POSCHEDULE TO GT_POSCHEDULE.
PERFORM FILL_CHECK_STRUCTURE USING 'bapimeposchedulx'
'gs_poschedule'
'gs_poschedulex'
C_X.
GS_POSCHEDULEX-PO_ITEM = BAPI_POSCHEDULE-PO_ITEM. "采购凭证的项目编号 zift_mm003_matnr-ebelp
GS_POSCHEDULEX-SCHED_LINE = BAPI_POSCHEDULE-SCHED_LINE.
APPEND GS_POSCHEDULEX TO GT_POSCHEDULEX.
ENDLOOP.
*--------------------------------------------------------------------*
*-----执行BAPI
*--------------------------------------------------------------------*
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = P_EBELN"GS_PURCHASEORDER
TABLES
RETURN = GT_RETURN
POITEM = GT_POITEM
POITEMX = GT_POITEMX
POSCHEDULE = GT_POSCHEDULE
POSCHEDULEX = GT_POSCHEDULEX
POCOMPONENTS = GT_POCOMPONENTS
POCOMPONENTSX = GT_POCOMPONENTSX.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.