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

Uploading PO limits using BAPI_PO_CREATE1?

Former Member
0 Likes
1,631

Hi all,

I have written an upload program to upload PO Limits using BAPI_PO_CREATE1 . I am not passing any services .

But it is giving the error that

'no account assignement exists for service line 00000000000'

Please help me to resolve this error?

Thanks,

Vamshi

7 REPLIES 7
Read only

Former Member
0 Likes
1,121

Hi,

Try this

{Sample Code}

loop at i_header.

header-ref_1 = i_header-legacy.

headerx-ref_1 = c_x.

header-doc_type = i_header-bsart.

headerx-doc_type = c_x.

header-comp_code = i_header-bukrs.

headerx-comp_code = c_x.

header-purch_org = i_header-ekorg.

headerx-purch_org = c_x.

header-pur_group = i_header-ekgrp.

headerx-pur_group = c_x.

header-vendor = i_header-lifnr.

headerx-vendor = c_x.

concatenate i_header-bedat+4(4)

i_header-bedat+0(2)

i_header-bedat+2(2)

into header-doc_date.

headerx-doc_date = c_x.

header-created_by = i_header-ernam.

headerx-created_by = c_x.

header-currency = i_header-waers.

headerx-currency = c_x.

concatenate i_header-kdatb+4(4)

i_header-kdatb+0(2)

i_header-kdatb+2(2)

into header-vper_start.

headerx-vper_start = c_x.

loop at i_items where legacy = i_header-legacy.

item-po_item = i_items-ebelp.

itemx-po_item = i_items-ebelp.

itemx-po_itemx = c_x.

if i_header-bsart = 'NB'.

item-material = i_items-ematn.

itemx-material = c_x.

schedule-quantity = i_items-menge * 1000.

schedulex-quantity = c_x.

else.

item-short_text = i_items-ematn.

itemx-short_text = c_x.

*

item-matl_group = '1000'.

itemx-matl_group = c_x.

schedule-quantity = '1'.

schedulex-quantity = c_x.

endif.

item-plant = i_items-werks.

itemx-plant = c_x.

schedule-po_item = i_items-ebelp.

schedule-sched_line = '1'.

schedulex-po_item = i_items-ebelp.

schedulex-sched_line = '1'.

schedulex-po_itemx = c_x.

schedulex-sched_linex = c_x.

concatenate i_items-eildt+0(2)

'/'

i_items-eildt+2(2)

'/'

i_items-eildt+4(4)

into schedule-delivery_date.

schedulex-delivery_date = c_x.

item-price_unit = i_items-peinh * 100.

itemx-price_unit = c_x.

item-tax_code = i_items-mwskz.

itemx-tax_code = c_x.

item-shipping = i_items-evers.

itemx-shipping = c_x.

account-po_item = i_items-ebelp.

accountx-po_item = i_items-ebelp.

accountx-po_itemx = c_x.

if i_header-bsart = 'FO'.

item-pckg_no = sy-tabix.

itemx-pckg_no = 'X'.

limits-pckg_no = sy-tabix.

limits-limit = i_items-overalllimit.

limits-exp_value = i_items-expectedoverall.

posrvaccessvalues-pckg_no = sy-tabix.

posrvaccessvalues-line_no = '0'.

posrvaccessvalues-serno_line = '00'.

posrvaccessvalues-percentage = '100.0'.

posrvaccessvalues-serial_no = '01'.

account-serial_no = '1'.

accountx-serial_no = '1'.

accountx-serial_nox = c_x.

account-quantity = '1'.

accountx-quantity = c_x.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = i_items-kostl

importing

output = account-costcenter.

accountx-costcenter = c_x.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = i_items-sakto

importing

output = account-gl_account.

accountx-gl_account = c_x.

item-acctasscat = i_items-knttp.

itemx-acctasscat = c_x.

item-item_cat = i_items-epstp.

itemx-item_cat = c_x.

endif.

append:item,itemx,schedule,schedulex,account,accountx,limits,posrvaccessvalues.

clear :item,itemx,schedule,schedulex,account,accountx,limits,posrvaccessvalues.

endloop.

call function 'BAPI_PO_CREATE1'

exporting

poheader = header

poheaderx = headerx

  • POADDRVENDOR =

  • TESTRUN =

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

importing

exppurchaseorder = ponumber

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

tables

return = return

poitem = item

poitemx = itemx

  • POADDRDELIVERY =

poschedule = schedule

poschedulex = schedulex

poaccount = account

  • POACCOUNTPROFITSEGMENT =

poaccountx = accountx

  • POCONDHEADER =

  • POCONDHEADERX =

  • POCOND =

  • POCONDX =

polimits = limits

  • POCONTRACTLIMITS =

  • POSERVICES =

posrvaccessvalues = posrvaccessvalues.

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • POPARTNER =

if ponumber eq space.

loop at return where type = 'E'.

clear buffer.

move-corresponding return to e_return.

concatenate i_header-legacy e_return into buffer.

transfer buffer to p2_file.

endloop.

move-corresponding i_header to i_eheader.

transfer i_eheader to p3_file.

loop at i_items where legacy = i_header-legacy.

move-corresponding i_items to i_eitems.

transfer i_eitems to p4_file.

endloop.

else.

commit work and wait.

endif.

Regards

Krishna

Read only

0 Likes
1,121

Hi krishna,

Thanks for the help. Problem solved.

Thanks,

Vamshi.

Read only

Former Member
0 Likes
1,121

Hi,

Check the following link:

https://wiki.sdn.sap.com/wiki/display/ABAP/RFCPurchaseOrderCreationfrom+Ariba

cheers

Aveek

Read only

Former Member
0 Likes
1,121

Hi,

We have to populate the BAPIESUHC-PCKG_NO field with a value (similar concept like Item number)

Each PO item needs to have one package Number. The same is linked to Limits and corresponding Account Assignments.

Please see the existing data in EKPO, ESUH, ESKN tables etc.

Regards,

Yogesh

Read only

0 Likes
1,121

hi all,

Though the purchase order is creating successfully. But the account assignment values are not updating.

Please help me to identify the error?

Thanks,

Vamshi

Read only

0 Likes
1,121

Hi all,

Solved. Thanks for the help.

Thanks,

Vamshi

Read only

Former Member
0 Likes
1,121

Hi,

Check this part of the code:

  • LOOP AT t_poitem.

  • LOOP AT t_account. " Where po_item = t_poitem-po_item.

    • l_tabix = sy-tabix.

    • READ TABLE t_poitem index l_tabix.

**

    • t_accountx-po_item = t_account-po_item.

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

***mod-004

*

  • if not t_account-po_item is initial.

  • t_accountx-po_item = t_account-po_item.

  • else.

  • t_accountx-po_item = t_poitem-po_item.

  • t_account-po_item = t_poitem-po_item.

  • endif.

**mod-004

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

  • IF NOT t_account-po_item IS INITIAL.

  • t_accountx-po_itemx = c_x.

  • ENDIF.

*

  • IF NOT t_account-serial_no IS INITIAL.

  • t_accountx-SERIAL_NO = t_account-serial_no.

  • t_accountx-serial_nox = c_x.

  • ENDIF.

*

    • To change the value of T_POITEM-DISTRIB

    • to 2 in case of a split

  • IF t_account-serial_no > 1.

  • READ TABLE T_POITEM WITH KEY po_item = t_account-po_item.

  • IF sy-subrc = 0.

  • t_poitem-distrib = '2'.

  • MODIFY t_poitem INDEX sy-tabix TRANSPORTING distrib.

  • READ TABLE t_poitemx WITH KEY po_item = t_poitem-po_item.

  • IF sy-subrc = 0.

  • t_poitemx-distrib = 'X'.

  • MODIFY t_poitemx INDEX sy-tabix TRANSPORTING distrib.

  • ENDIF.

  • ENDIF.

  • ENDIF.

*

    • l_tabix = sy-tabix.

    • t_accountx-po_item = l_tabix.

    • IF NOT t_accountx-po_item IS INITIAL.

    • t_accountx-po_item = c_x.

    • ENDIF.

**

  • IF NOT t_account-costcenter IS INITIAL.

  • t_accountx-costcenter = c_x.

  • ENDIF.

*

  • IF NOT t_account-gl_account IS INITIAL.

  • t_accountx-gl_account = c_x.

  • ENDIF.

*

  • IF NOT t_account-unload_pt IS INITIAL.

  • t_accountx-unload_pt = c_x.

  • ENDIF.

*

  • IF NOT t_account-wbs_element IS INITIAL.

  • t_accountx-wbs_element = c_x.

  • ENDIF.

*

  • IF NOT t_account-distr_perc IS INITIAL.

  • t_accountx-distr_perc = c_x.

  • ENDIF.

*

  • IF NOT t_account-net_value IS INITIAL.

  • t_accountx-net_value = c_x.

  • ENDIF.

*

  • IF NOT t_account-quantity IS INITIAL.

  • t_accountx-quantity = c_x.

  • ENDIF.

*

  • APPEND T_accountx.

  • CLEAR: t_accountx.

*

    • READ TABLE t_accountx

    • WITH KEY po_item = t_account-po_item

    • serial_no = t_account-serial_no.

    • IF sy-subrc = 0.

    • MODIFY t_accountx.

    • ENDIF.

  • modify t_account.

  • ENDLOOP.

*

  • ENDLOOP.

*

  • delete t_account where po_item = '0000'.

  • delete t_accountx where po_item = '0000'.

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

**MOD-004

  • sort t_accountx by po_item.

  • delete adjacent duplicates from t_accountx comparing

  • po_item.

MOD-004*******************************************************

cheers

Aveek