货铺QQ群号:834508274
调用BAPI的时候注意
DEMO
REPORT ZDEMO_CLOSE_PO.
PARAMETERS P_PO TYPE BAPIMEPOHEADER-PO_NUMBER..
DATA:LT_RETURN LIKE TABLE OF BAPIRET2,
LS_RETURN LIKE LINE OF LT_RETURN,
LT_POITEM LIKE TABLE OF BAPIMEPOITEM,
LT_POITEMX LIKE TABLE OF BAPIMEPOITEMX.
DATA:LS_POITEM LIKE LINE OF LT_POITEM.
DATA:LS_POITEMX LIKE LINE OF LT_POITEMX.
DATA:LS_DATA LIKE BAPI_TE_MEPOHEADER.
DATA:LS_DATAX LIKE BAPI_TE_MEPOHEADERX.
DATA:LT_EXTENSIONIN LIKE TABLE OF BAPIPAREX .
DATA:LS_EXTENSIONIN LIKE BAPIPAREX .
DATA:LS_POHEADER LIKE BAPIMEPOHEADER,
LS_POHEADERX LIKE BAPIMEPOHEADERX.
CLEAR LS_POHEADER.
CLEAR LS_POHEADERX.
LS_POHEADER-PO_NUMBER = P_PO.
LS_POHEADER-CREAT_DATE = SY-DATUM.
LS_POHEADER-DOC_DATE = SY-DATUM.
LS_POHEADER-CREATED_BY = SY-UNAME..
LS_POHEADERX-PO_NUMBER = 'X'.
LS_POHEADERX-CREAT_DATE = 'X'.
LS_POHEADERX-DOC_DATE = 'X'.
LS_POHEADERX-CREATED_BY = 'X'.
CLEAR LT_POITEM[].
LS_POITEM-PO_ITEM = '00010'.
LS_POITEM-DELETE_IND = 'X'.
APPEND LS_POITEM TO LT_POITEM[].
CLEAR LT_POITEMX[].
LS_POITEMX-PO_ITEM = '00010'.
LS_POITEMX-PO_ITEMX = 'X'.
LS_POITEMX-DELETE_IND = 'X'.
APPEND LS_POITEMX TO LT_POITEMX[].
CLEAR:LS_DATA,LS_DATAX.
LS_DATA-PO_NUMBER = P_PO.
LS_DATAX-PO_NUMBER = P_PO.
LS_DATA-ZDJYY = '8'."8.
LS_DATAX-ZDJYY = 'X'.
CLEAR: LS_EXTENSIONIN,LT_EXTENSIONIN[].
LS_EXTENSIONIN-VALUEPART1 = LS_DATA.
LS_EXTENSIONIN-STRUCTURE = 'BAPI_TE_MEPOHEADER'.
APPEND LS_EXTENSIONIN TO LT_EXTENSIONIN.
LS_EXTENSIONIN-VALUEPART1 = LS_DATAX.
LS_EXTENSIONIN-STRUCTURE = 'BAPI_TE_MEPOHEADERX'.
APPEND LS_EXTENSIONIN TO LT_EXTENSIONIN.
CLEAR LT_RETURN[].
CALL FUNCTION 'BAPI_PO_CHANGE'EXPORTINGPURCHASEORDER = P_POPOHEADER = LS_POHEADERPOHEADERX = LS_POHEADERXTABLESRETURN = LT_RETURNPOITEM = LT_POITEMPOITEMX = LT_POITEMXEXTENSIONIN = LT_EXTENSIONIN.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'EXPORTINGWAIT = 'X'.