Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_PO_CREATE

Former Member
0 Likes
603

Hi All,

I am using " BAPI_PO_CREATE " bapi to create STO.

my STO is generated by MRP is not getting any value.

i m passing following data to BAPI.

CALL FUNCTION 'BAPI_PO_CREATE'
      EXPORTING
        PO_HEADER                  = PO_HEADER
        PO_HEADER_ADD_DATA         = PO_HEADER_ADD_DATA
      IMPORTING
        PURCHASEORDER              = PURCHASEORDER
      TABLES
        PO_ITEMS                   = PO_ITEM
        PO_ITEM_ADD_DATA           = PO_ITEM_ADD_DATA
        PO_ITEM_SCHEDULES          = PO_ITEM_SCHEDULES
        PO_ITEM_ACCOUNT_ASSIGNMENT = PO_ITEM_ACCOUNT_ASSIGNMENT
        PO_ITEM_TEXT               = PO_ITEM_TEXT
        RETURN                     = ZRETURN
      EXCEPTIONS
        OTHERS                     = 0.

4 REPLIES 4
Read only

Former Member
0 Likes
539

call following BAPI after the first one.

call function 'BAPI_TRANSACTION_COMMIT'.

to commit the transaction which will update the values.

anya

Read only

0 Likes
539

Hi,

I already told you that my STO is getting generated, but the MRP in condition is not getting updated.

And I am using this FM (BAPI_TRANSACTION_COMMIT)

Read only

Former Member
0 Likes
539

Hi,

Try using BAPI_PO_CREATE1.

Regards,

Ramya

Read only

0 Likes
539

Try using COMMIT WORK AND WAIT.

OR USE THE FOLLOWING BAPI

loop at i_tab.

refresh pohead.

refresh poheadx.

refresh poitem.

refresh poitemX.

pohead-DOC_TYPE = i_tab-bsart.

pohead-VENDOR = i_tab-lifnr.

pohead-PURCH_ORG = c_ekorg.

pohead-CREAT_DATE = i_tab-verkf1.

pohead-PUR_GROUP = c_ekgrp.

pohead-COMP_CODE = c_bukrs.

pohead-SALES_PERS = I_TAB-VERKF2.

pohead-doc_date = sy-datum.

pohead-langu = sy-langu.

append pohead.

poheadx-DOC_TYPE = c_x.

poheadx-VENDOR = c_x.

poheadx-PURCH_ORG = c_x.

poheadx-PUR_GROUP = c_x.

poheadx-COMP_CODE = c_x.

poheadx-SALES_PERS = c_x.

poheadx-doc_date = c_x.

poheadx-langu = c_x.

append poheadx.

loop at i_tab3 WHERE VERKF = I_TAB-VERKF.

poitem-PO_ITEM = i_tab3-ebelp1.

poitem-MATERIAL = i_tab3-MATNR.

poitem-QUANTITY = i_tab3-MENGE.

poitem-PO_UNIT = i_tab3-BPRME.

poitem-NET_PRICE = i_tab3-NETPR.

poitem-PLANT = i_tab3-WERKS.

poitem-GR_TO_DATE = i_tab3-LEWED.

poitem-VEND_MAT = i_tab3-IDNLF.

append poitem.

poitemx-PO_ITEM = i_tab3-ebelp1.

poitemx-MATERIAL = c_x.

poitemx-QUANTITY = c_x.

poitemx-PO_UNIT = c_x.

poitemx-NET_PRICE = c_x.

poitemx-PLANT = c_x.

poitemx-GR_TO_DATE = c_x.

poitemx-tax_code = c_x.

poitemx-item_cat = c_x.

POITEMx-ACCTASSCAT = c_x.

poitemx-VEND_MAT = c_x.

append poitemx.

endloop.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

POHEADER = pohead

POHEADERX = poheadx

  • POADDRVENDOR =

  • TESTRUN =

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

IMPORTING

  • EXPPURCHASEORDER =

EXPHEADER = ponum

  • EXPPOEXPIMPHEADER =

TABLES

RETURN = errmsg

POITEM = poitem

POITEMX = poitemx

  • POADDRDELIVERY =

  • POSCHEDULE =

  • POSCHEDULEX =

  • POACCOUNT =

  • POACCOUNTPROFITSEGMENT =

  • POACCOUNTX =

  • POCONDHEADER =

  • POCONDHEADERX =

  • POCOND =

  • POCONDX =

  • POLIMITS =

  • POCONTRACTLIMITS =

  • POSERVICES =

  • POSRVACCESSVALUES =

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • POPARTNER =

.

clear errflag.

loop at errmsg.

if errmsg-type eq 'E'.

write:/'Error in function', errmsg-message.

errflag = 'X'.

else.

write:/ errmsg-message.

endif.

endloop.

if errflag is initial.

commit work and wait.

if sy-subrc ne 0.

write:/ 'Error in updating'.

exit.

else.

write:/ ponum-PO_NUMBER, ponum-comp_code.

endif.

endif.

endloop.