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 for po creation

Former Member
0 Likes
545

Hi ,

I am using "bapi_po_create1" to create a po. apart from header I am populating items,accounts, services

table.. but the po is not getting created as it gives error like:

1. Po data is faulty

2. Maintain services or limits

But with the same data the po gets created using Me21n. Please suggest?

3 REPLIES 3
Read only

Former Member
0 Likes
465

hi

please try this

call function 'BAPI_CFG_CREATE'

exporting

object_id = 'MYMATCODE'

root_type = 'MARA'

root_name = 'MYMATCODE'

plant = 'MYPLANT'

importing

cfg_handle = l_handle

root_instance = l_instance

exceptions

error = 1

others = 2.l_characts_vals-atnam = 'WIDTH'.

l_characts_vals-atwtb = '500'.

append l_characts_vals to it_characts_vals.

call function 'BAPI_CFGINST_CHARCS_VALS_SET'

exporting object_id = 'MYMATCODE'

instance = l_instance

tables

characts_vals = it_characts_vals

characts_vals_err = it_characts_vals_err.

call function 'CE_C_SET_CBASE'....

l_poitem-int_obj_no = l_handle....

call function 'BAPI_PO_CREATE1'

exporting

poheader = l_poheader

poheaderx = l_poheaderx

importing expheader = l_expheader

exppurchaseorder = l_exppurchaseorder

tables

poitem = lt_poitem

poitemx = lt_poitemx

poschedule = lt_poschedule

poschedulex = lt_poschedulex

return = lt_return.

call function 'BAPI_TRANSACTION_COMMIT'.

regards

prashant

Read only

Former Member
0 Likes
465

Hi,

I think you are creating a Service PO, you have to maintain relation between PO Service and POSRVACCESSVALUES tables as well

check this sample code for same..

      • Internal table for Service

DATA: Service like BAPIESLLC occurs 0 with header line,

Service1 like BAPIESKLC occurs 0 with header line.

Service-PCKG_NO = '0000000001'.

Service-LINE_NO = '0000000001'.

Service1-LINE_NO = '0000000001'.

Service-EXT_LINE = '0000000010'.

Service-SUBPCKG_NO = '0000000002'.

append service.

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

      • POPULATE Service TABLE

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

Service-PCKG_NO = '0000000002' .

Service-LINE_NO = Service-LINE_NO + 1 .

  • Service-EXT_LINE = record-EXT_LINE .

Service-service = record-service.

Service-quantity = record-quantity.

Service-GR_PRICE = record-Net_price.

Service-SUBPCKG_NO = '0000000000'.

append service.

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

      • POPULATE Service value TABLE

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

Service1-PCKG_NO = '0000000002' .

Service1-LINE_NO = Service1-LINE_NO + 1 .

append service1.

Sachin

Read only

Former Member
0 Likes
465

Is your problem solved now?.

Varun