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

Problem in BAPI_PO_CREATE1

Former Member
0 Likes
394

hi,

i am using the BAPI_PO_CREATE to create the multiple POS,i am facing the problem with header texts to load,

1)step:i am downloading the all porelated data into excel sheet it is comming perfectly.

2)while loading the POs i am using BAPI_PO_CREATE.

But i am getting the problem with header texts.

so i am tinknig to go for BAPI_PO_CREATE1.But i dont know how to use this can any body haev sample code pls send it.

Thanks,

Rammohan.

2 REPLIES 2
Read only

Former Member
0 Likes
339

data: begin of pohead occurs 10.

include structure BAPIMEPOHEADER.

data: end of pohead.

data: begin of poheadx occurs 10.

include structure BAPIMEPOHEADERX.

data: end of poheadx.

*EXPPURCHASEORDER

data: BEGIN OF ponum.

include structure BAPIMEPOHEADER.

data: end of ponum.

data: begin of poitem occurs 100.

include structure BAPIMEPOITEM.

data: end of poitem.

data: begin of poitemx occurs 100.

include structure BAPIMEPOITEMX.

data: end of poitemx.

data: begin of errmsg occurs 10.

include structure bapiret2.

data: end of errmsg.

data : errflag.

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-tax_code = c_x.

  • poitem-item_cat = c_x.

*

  • POITEM-ACCTASSCAT = c_x.

  • poitem-AGREEMENT = i_tab3-ebeln.

  • poitem-AGMT_ITEM = i_tab3-ebelp1.

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-AGREEMENT = 'X'.

  • poitemx-AGMT_ITEM = '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.

Read only

anilnal
Explorer
0 Likes
339

Hi,

BAPI_PO_CREATE1 is always a preferred method over BAPI_PO_CREATE.

For the header texts, the data is to be moved to the table POTEXTHEADER of the above FM. This data can be fetched from STXH, in case you're using a legacy system. The PO data and the text id data are to be moved here. Also check the POTEXTHEADERX for the fields filled.

This would create the header texts when the PO is created.

Regards,

Anil.