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
1,273

Hi,

I'm trying to create STO using BAPI_PO_CREATE. My code is this.

pohdr-DOC_DATE = '03022006'.

pohdr-DOC_TYPE = 'EUB'.

*pohdr-DOC_CAT = 'F'.

pohdr-CO_CODE = '1000'.

pohdr-PURCH_ORG = '1000'.

pohdr-PUR_GROUP = '001'.

*pohdr-PO_NUMBER = '1000000007'.

*pohdr-VENDOR = 'ABZ'.

pohdr-SUPPL_PLNT = '1012'.

append pohdr.

*poitm-PO_NUMBER = '1000000007'.

poitm-PO_ITEM = '00010'.

poitm-MATERIAL = '10052000501336000'.

poitm-STORE_LOC = '0001'.

*poitm-PUR_MAT = ' '.

*poitm-ACCTASSCAT = 'F'.

poitm-MAT_GRP = '000336'.

poitm-plant ='3263'.

poitm-SHORT_TEXT = 'Bottle 32 oz Amcor'.

poitm-UNIT = 'EA'.

poitm-NET_PRICE = 23.

poitm-ITEM_CAT = '7'.

append poitm.

posch-PO_ITEM = '00010'.

posch-DELIV_DATE = '20060302'.

posch-QUANTITY = '3000'.

append posch.

CALL FUNCTION 'BAPI_PO_CREATE'

EXPORTING

PO_HEADER = pohdr

importing

PURCHASEORDER = ponum

TABLES

PO_ITEMS = poitm

  • PO_ITEM_ADD_DATA =

PO_ITEM_SCHEDULES = posch

  • PO_ITEM_ACCOUNT_ASSIGNMENT =

  • PO_ITEM_TEXT =

RETURN = i_return.

I'm getting error as "Enter Material or Account assigment category"..Account Assignment category not needed for STO creation i think..Why this error even if i have given the material..

Pls help.

I'm strugling.

Ram

8 REPLIES 8
Read only

Former Member
0 Likes
977

Hi,

account assignment category should be passed

to bapi even STO orders.

Regards

amole

Read only

Former Member
0 Likes
977

Try and pass the item category to the poitem data.

poitm-item_cat = 'U' <== STO

Read only

0 Likes
977

Hi,

I tried to give the account assigment category .But now getting error as

"Procurement w/o matterial from vendor with plant assignment not defined".

Pls help if anything i'm missing for this ?

thanks

Ram

Read only

0 Likes
977

Prabha,

Have you passed the vendor in the header,

wa_po_header-vendor = '0001000025'.

Sit with the functional guys and create a PO manually in ME21. Check what are the mandatory fields ME21 asks and pass all the mandatory fields to the BAPI.

Regards,

Prakash.

Read only

0 Likes
977

Hi Prakash,

Thanks fo rthe reply

Its PO for STO.and We give the Supplying Plant here.

I have given all fields and able to create STO/PO from ME21n. But only from BAPI its creating problem.

I hav egiven the MAterial also..But still getting msg as "Enter Material or Acc Ass Category"

Same msg i get from ME21n also.But when i enter Material..it works fine

Pls help

Thanks

Ram

Read only

Former Member
0 Likes
977

Check the sample code for creating a PO:

&----


*& Report YPRA_SAMPLE39 *

*& *

&----


*& *

*& *

&----


REPORT ypra_sample39.

Create PO

DATA: wa_po_header TYPE bapiekkoc,

wa_po_add_header TYPE bapiekkoa,

ws_po_number TYPE bapiekkoc-po_number,

ws_po_number1 TYPE bapimepoheader-po_number,

ws_pack_no TYPE packno,

i_poitems TYPE bapiekpoc OCCURS 0 WITH HEADER LINE,

i_poitems_sch TYPE bapieket OCCURS 0 WITH HEADER LINE,

i_acct_ass TYPE bapiekkn OCCURS 0 WITH HEADER LINE,

i_return TYPE bapireturn OCCURS 0 WITH HEADER LINE,

i_return1 TYPE bapiret2 OCCURS 0 WITH HEADER LINE,bapiret2,

i_services TYPE bapiesllc OCCURS 0 WITH HEADER LINE,

bapi_esll TYPE bapiesllc OCCURS 0 WITH HEADER LINE,

i_srv_accass TYPE bapiesklc OCCURS 0 WITH HEADER LINE,

i_po_limits TYPE bapiesuhc OCCURS 0 WITH HEADER LINE,

i_po_contract_limits TYPE bapiesucc OCCURS 0 WITH HEADER LINE.

DATA: serial_no LIKE bapiesknc-serial_no,

line_no LIKE bapiesllc-line_no,

pack_no LIKE bapiesllc-line_no.

*CALL FUNCTION 'NUMBER_GET_NEXT'

  • EXPORTING

  • nr_range_nr = '01'

  • object = 'SERVICE'

    • QUANTITY = '1'

    • SUBOBJECT = ' '

    • TOYEAR = '0000'

    • IGNORE_BUFFER = ' '

  • IMPORTING

  • number = ws_pack_no

    • QUANTITY =

    • RETURNCODE =

  • EXCEPTIONS

  • interval_not_found = 1

  • number_range_not_intern = 2

  • object_not_found = 3

  • quantity_is_0 = 4

  • quantity_is_not_1 = 5

  • interval_overflow = 6

  • buffer_overflow = 7

  • OTHERS = 8 .

*IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

wa_po_header-doc_date = sy-datum.

wa_po_header-doc_type = 'ZES3'.

wa_po_header-co_code = 'SP01'.

wa_po_header-purch_org = 'SP01'.

wa_po_header-pur_group = 'ES1'.

wa_po_header-vendor = '0001000025'.

wa_po_header-created_by = sy-uname.

wa_po_header-langu = sy-langu.

*wa_po_header-doc_date = sy-datum.

*wa_po_header-doc_type = 'ZDET'.

*wa_po_header-co_code = 'DE03'.

*wa_po_header-purch_org = 'DE03'.

*wa_po_header-pur_group = 'DE1'.

*wa_po_header-vendor = '0002000000'.

*wa_po_header-created_by = sy-uname.

*wa_po_header-langu = sy-langu.

*wa_po_add_header = 'Z004'.

*i_services-pckg_no = '0000000265'.

i_poitems-po_item = 10.

i_poitems-item_cat = '9'.

i_poitems-acctasscat = 'K'.

i_poitems-plant = 'SP01'.

i_poitems-short_text = '007002046'.

i_poitems-disp_quan = '1'.

i_poitems-mat_grp = 'ZES1'.

*i_poitems-pckg_no = '0000000265'.

*i_poitems-line_no = 1.

i_poitems-pckg_no = 10.

APPEND i_poitems.

i_poitems_sch-po_item = 10.

i_poitems_sch-deliv_date = sy-datum.

APPEND i_poitems_sch.

line_no = line_no + 1.

pack_no = pack_no + 1.

bapi_esll-pckg_no = 10.

bapi_esll-line_no = 1.

bapi_esll-outl_no = 10.

bapi_esll-outl_ind = 'X'.

bapi_esll-subpckg_no = 20.

bapi_esll-from_line = 1.

bapi_esll-to_line = 3.

APPEND bapi_esll.

bapi_esll-pckg_no = 20.

bapi_esll-line_no = 2.

*bapi_esll-subpckg_no = pack_no + 1.

*bapi_esll-from_line = 1.

*bapi_esll-outl_ind = 'X'.

bapi_esll-service = '000000000003000018'.

bapi_esll-quantity = '1'.

bapi_esll-gr_price = '1'.

APPEND bapi_esll.

i_srv_accass-pckg_no = 10.

i_srv_accass-line_no = 1.

i_srv_accass-serno_line = 01.

i_srv_accass-serial_no = 01.

i_srv_accass-percentage = 100.

APPEND i_srv_accass.

i_srv_accass-pckg_no = 20.

i_srv_accass-line_no = 2.

i_srv_accass-serno_line = 02.

i_srv_accass-serial_no = 02.

i_srv_accass-percentage = 100.

i_srv_accass-quantity = '1'.

APPEND i_srv_accass.

*i_acct_ass-g_l_acct = '7910100'.

*i_acct_ass-co_area = '1000'.

*i_acct_ass-cost_ctr = '12000'.

*APPEND i_acct_ass.

*i_services-line_no = 10.

*i_services-outl_level = '0'.

*i_services-outl_ind = 'X'.

*i_services-subpckg_no = 2.

*i_services-service = '000000000003000018'.

*i_services-quantity = '1'.

*i_services-gr_price = '1'.

*i_services-ssc_lim = 'X'.

*APPEND i_services.

*i_services-line_no = 10.

*i_services-service = 'H007'.

*i_services-quantity = '1'.

*i_services-gr_price = '1'.

*APPEND i_services.

*i_po_limits-pckg_no = ws_pack_no.

*APPEND i_po_limits.

*

*i_po_contract_limits-pckg_no = ws_pack_no.

*APPEND i_po_contract_limits.

*i_srv_accass-pckg_no = ws_pack_no.

*i_srv_accass-line_no = 10.

*i_srv_accass-serno_line = 1.

*i_srv_accass-serial_no = 1.

*i_srv_accass-quantity = 1.

*APPEND i_srv_accass.

CALL FUNCTION 'BAPI_PO_CREATE'

EXPORTING

po_header = wa_po_header

po_header_add_data = wa_po_add_header

  • HEADER_ADD_DATA_RELEVANT =

  • PO_ADDRESS =

skip_items_with_error = 'X'

  • ITEM_ADD_DATA_RELEVANT =

  • HEADER_TECH_FIELDS =

IMPORTING

purchaseorder = ws_po_number

TABLES

po_items = i_poitems

  • PO_ITEM_ADD_DATA =

po_item_schedules = i_poitems_sch

  • po_item_account_assignment = i_acct_ass

  • PO_ITEM_TEXT =

return = i_return

  • po_limits = i_po_limits

  • po_contract_limits = i_po_contract_limits

po_services = bapi_esll

po_srv_accass_values = i_srv_accass

  • PO_SERVICES_TEXT =

  • PO_BUSINESS_PARTNER =

  • EXTENSIONIN =

  • POADDRDELIVERY =

.

break gbpra8.

LOOP AT i_return.

ENDLOOP.

IF NOT ws_po_number IS INITIAL.

ws_po_number1 = ws_po_number.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = '2'.

WRITE: / ws_po_number.

ENDIF.

Regards,

Prakash.

Read only

Former Member
0 Likes
977

Please check the material length, maybe you have to add a leading zero.

Kind Regards

Eswar

Read only

Former Member
0 Likes
977

Hi Ram,

I would suggest to use BAPI_PO_CREATE1 as it is more in line with ME21N transaction (Enjoy Purchase Orders) .

Regards

Saurabh