You are on page 1of 3

REPORT ZMM_CREATE_PO_BAPI_1 NO STANDARD PAGE HEADING.

*FLAT FILE CONTENT *===================== *A,33,RP01,INK,GR *B,501600,5,KG,RV01 *A,33,RP01,INK,GR *B,501600,10,KG,RV01 *A,33,RP01,INK,GR *B,501600,15,KG,RV01 *A,33,RP01,INK,GR *B,501600,20,KG,RV01 *A,33,RP01,INK,GR *B,501600,20,KG,RV01 *A,33,RP01,INK,GR *B,501600,40,KG,RV01 *A,33,RP01,INK,GR *B,501600,60,KG,RV01 *A,33,RP01,INK,GR *B,501600,80,KG,RV01

DATA : V_1 TYPE STRING. DATA: WA_HEADER TYPE BAPIMEPOHEADER, WA_HEADERX TYPE BAPIMEPOHEADERX, IT_RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE, WA_RETURN TYPE BAPIRETURN, IT_POITEM TYPE TABLE OF BAPIMEPOITEM, WA_POITEM TYPE BAPIMEPOITEM, WA_POITEMX TYPE BAPIMEPOITEMX, IT_POITEMX TYPE TABLE OF BAPIMEPOITEMX. WA_HEADER-COMP_CODE = 'GR'. WA_HEADER-DOC_TYPE = 'NB'. WA_HEADER-CREAT_DATE = SY-DATUM. WA_HEADER-CREATED_BY = SY-UNAME. WA_HEADER-ITEM_INTVL = '00001'. WA_HEADER-VENDOR = '0000000033'. WA_HEADER-PUR_GROUP = 'INK'. WA_HEADER-PURCH_ORG = 'RP01'. WA_HEADERX-COMP_CODE WA_HEADERX-DOC_TYPE WA_HEADERX-CREAT_DATE WA_HEADERX-CREATED_BY WA_HEADERX-ITEM_INTVL WA_HEADERX-PURCH_ORG WA_HEADERX-PUR_GROUP WA_HEADERX-VENDOR = 'X'. = = = = = = = 'X'. 'X'. 'X'. 'X'. 'X'. 'X'. 'X'.

WA_POITEM-MATERIAL = '000000000000501600' . WA_POITEM-PO_ITEM = '1'. WA_POITEM-PLANT = 'RV01' . WA_POITEM-QUANTITY = '5'.

WA_POITEM-STGE_LOC = '0001'. WA_POITEM-PERIOD_IND_EXPIRATION_DATE = 'D'. WA_POITEM-NET_PRICE = '200'. APPEND WA_POITEM TO IT_POITEM.

WA_POITEMX-MATERIAL = 'X'. WA_POITEMX-PO_ITEM = '1'. WA_POITEMX-PLANT = 'X' . WA_POITEMX-QUANTITY = 'X'. WA_POITEMX-STGE_LOC = 'X'. WA_POITEMX-PERIOD_IND_EXPIRATION_DATE = 'X'. WA_POITEMX-NET_PRICE = 'X'. APPEND WA_POITEMX TO IT_POITEMX. WA_POITEM-MATERIAL = '000000000000501600' . WA_POITEM-PO_ITEM = '2'. WA_POITEM-PLANT = 'RV01' . WA_POITEM-QUANTITY = '7'. WA_POITEM-STGE_LOC = '0001'. WA_POITEM-PERIOD_IND_EXPIRATION_DATE = 'D'. WA_POITEM-NET_PRICE = '200'. APPEND WA_POITEM TO IT_POITEM. WA_POITEMX-MATERIAL = 'X'. WA_POITEMX-PO_ITEM = '2'. WA_POITEMX-PLANT = 'X' . WA_POITEMX-QUANTITY = 'X'. WA_POITEMX-STGE_LOC = 'X'. WA_POITEMX-PERIOD_IND_EXPIRATION_DATE = 'X'. WA_POITEMX-NET_PRICE = 'X'. APPEND WA_POITEMX TO IT_POITEMX. DATA: V_PO TYPE BAPIMEPOHEADER-PO_NUMBER. CALL FUNCTION 'BAPI_PO_CREATE1' EXPORTING POHEADER = WA_HEADER POHEADERX = WA_HEADERX POADDRVENDOR = TESTRUN = MEMORY_UNCOMPLETE = MEMORY_COMPLETE = POEXPIMPHEADER = POEXPIMPHEADERX = VERSIONS = NO_MESSAGING = NO_MESSAGE_REQ = NO_AUTHORITY = NO_PRICE_FROM_PO = IMPORTING EXPPURCHASEORDER = V_PO EXPHEADER = EXPPOEXPIMPHEADER = TABLES RETURN = IT_RETURN

* * * * * * * * * * * * *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** ** ** * *

POITEM = IT_POITEM POITEMX = IT_POITEMX. POADDRDELIVERY = POSCHEDULE = POSCHEDULEX = POACCOUNT = POACCOUNTPROFITSEGMENT = POACCOUNTX = POCONDHEADER = POCONDHEADERX = POCOND = POCONDX = POLIMITS = POCONTRACTLIMITS = POSERVICES = POSRVACCESSVALUES = POSERVICESTEXT = EXTENSIONIN = EXTENSIONOUT = POEXPIMPITEM = POEXPIMPITEMX = POTEXTHEADER = POTEXTITEM = ALLVERSIONS = POPARTNER = POCOMPONENTS = POCOMPONENTSX = POSHIPPING = POSHIPPINGX = POSHIPPINGEXP = . IF it_return is INITIAL . CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING WAIT = IMPORTING RETURN = .

WRITE:/ 'PO NUMBER GENERATED', V_PO. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' * EXPORTING * WAIT = * IMPORTING * RETURN = . ELSE. write:/'FAILED ' . ENDIF.