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

Help with BAPI_PO_CREATE1

Former Member
0 Likes
850

Hi Folks!

I'm trying to create a PO with BAPI_PO_CREATE1. I'm facing a problem here because for some reason in the POITEM information the BAPI ALWAYS go and look at the quotation and changes the quantity of the items, and I don't want it to do that, instead I want it to use the quantity indicated.

Hope someone can help me through this problem.

Kind Regards,

Gilberto Li

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
801

Check the below code:

DATA: i_poitem TYPE STANDARD TABLE OF bapimepoitem,

i_poitemx TYPE STANDARD TABLE OF bapimepoitemx,

i_poitem_sch TYPE STANDARD TABLE OF bapimeposchedule,

i_poitem_schx TYPE STANDARD TABLE OF bapimeposchedulx,

i_acct_ass TYPE STANDARD TABLE OF bapimepoaccount,

i_acct_assx TYPE STANDARD TABLE OF bapimepoaccountx,

i_services TYPE STANDARD TABLE OF bapiesllc ,

i_srvacc TYPE STANDARD TABLE OF bapiesklc,

i_return TYPE STANDARD TABLE OF bapiret2,

wa_header TYPE bapimepoheader,

wa_headerx TYPE bapimepoheaderx,

wa_poitem TYPE bapimepoitem,

wa_poitemx TYPE bapimepoitemx,

wa_poitem_sch TYPE bapimeposchedule,

wa_poitem_schx TYPE bapimeposchedulx,

wa_acct_ass TYPE bapimepoaccount,

wa_acct_assx TYPE bapimepoaccountx,

wa_services TYPE bapiesllc,

wa_srvacc TYPE bapiesklc,

wa_return TYPE bapiret2,

ws_po TYPE bapimepoheader-po_number,

ws_wait TYPE bapita-wait.

CONSTANTS: c_x TYPE char01 VALUE 'X'.

break gbpra8.

wa_header-doc_type = 'ZDET'.

wa_header-vendor = '0002000000'.

PERFORM conversion_output USING wa_header-vendor

CHANGING wa_header-vendor.

wa_header-comp_code = 'DE03'.

wa_header-purch_org = 'DE03'.

wa_header-pur_group = 'DE1'.

wa_header-vper_start = '20060730'.

wa_header-vper_end = '20070621'.

wa_headerx-comp_code = c_x.

wa_headerx-doc_type = c_x.

wa_headerx-creat_date = c_x.

wa_headerx-created_by = c_x.

wa_headerx-vendor = c_x.

wa_headerx-purch_org = c_x.

wa_headerx-pur_group = c_x.

wa_headerx-vper_start = c_x.

wa_headerx-vper_end = c_x.

wa_poitem-po_item = 100.

wa_poitem-short_text = 'Sample'.

wa_poitem-plant = 'DE03'.

wa_poitem-quantity = 1.

wa_poitem-tax_code = 'V1'.

wa_poitem-item_cat = 'D'.

wa_poitem-acctasscat = 'K'.

wa_poitem-matl_group = 'ZDESS'.

wa_poitem-pckg_no = 10.

wa_poitem-gr_ind = space.

wa_poitem-gr_basediv = space.

APPEND wa_poitem TO i_poitem .

wa_poitemx-po_item = 100.

wa_poitemx-po_itemx = c_x.

wa_poitemx-short_text = c_x.

wa_poitemx-plant = c_x.

wa_poitemx-quantity = c_x.

wa_poitemx-tax_code = c_x.

wa_poitemx-item_cat = c_x.

wa_poitemx-acctasscat = c_x.

wa_poitemx-matl_group = c_x.

wa_poitemx-pckg_no = c_x.

wa_poitemx-gr_ind = c_x.

wa_poitemx-gr_basediv = space.

APPEND wa_poitemx TO i_poitemx.

wa_poitem-po_item = 200.

wa_poitem-short_text = 'Sample'.

wa_poitem-plant = 'DE03'.

wa_poitem-quantity = 1.

wa_poitem-tax_code = 'V1'.

wa_poitem-item_cat = 'D'.

wa_poitem-acctasscat = 'K'.

wa_poitem-matl_group = 'ZDESS'.

wa_poitem-pckg_no = 40.

wa_poitem-gr_ind = space.

wa_poitem-gr_basediv = space.

APPEND wa_poitem TO i_poitem .

wa_poitemx-po_item = 200.

wa_poitemx-po_itemx = c_x.

wa_poitemx-short_text = c_x.

wa_poitemx-plant = c_x.

wa_poitemx-quantity = c_x.

wa_poitemx-tax_code = c_x.

wa_poitemx-item_cat = c_x.

wa_poitemx-acctasscat = c_x.

wa_poitemx-matl_group = c_x.

wa_poitemx-pckg_no = c_x.

wa_poitemx-gr_ind = c_x.

wa_poitemx-gr_basediv = space.

APPEND wa_poitemx TO i_poitemx.

wa_acct_ass-po_item = 100.

wa_acct_ass-serial_no = 01.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_assx-po_item = 100.

wa_acct_assx-serial_no = 01.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_acct_ass-po_item = 100.

wa_acct_ass-serial_no = 02.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_assx-po_item = 100.

wa_acct_assx-serial_no = 02.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_acct_ass-po_item = 200.

wa_acct_ass-serial_no = 01.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_assx-po_item = 200.

wa_acct_assx-serial_no = 01.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_acct_ass-po_item = 200.

wa_acct_ass-serial_no = 02.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_assx-po_item = 200.

wa_acct_assx-serial_no = 02.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_services-pckg_no = 10.

wa_services-line_no = 1.

wa_services-outl_no = '0'.

wa_services-outl_ind = c_x.

wa_services-subpckg_no = 20.

wa_services-from_line = 1.

wa_services-to_line = 2.

APPEND wa_services TO i_services.

wa_services-pckg_no = 20.

wa_services-line_no = 2.

wa_services-service = 'H007'.

wa_services-quantity = '12'.

wa_services-gr_price = '100'.

wa_services-userf1_txt = 'Firm'.

APPEND wa_services TO i_services.

wa_services-pckg_no = 40.

wa_services-line_no = 1.

wa_services-outl_no = '0'.

wa_services-outl_ind = c_x.

wa_services-subpckg_no = 50.

wa_services-from_line = 1.

wa_services-to_line = 2.

APPEND wa_services TO i_services.

wa_services-pckg_no = 50.

wa_services-line_no = 2.

wa_services-service = 'H008'.

wa_services-quantity = '12'.

wa_services-gr_price = '100'.

wa_services-userf1_txt = 'Firm'.

APPEND wa_services TO i_services.

wa_srvacc-pckg_no = 10.

wa_srvacc-line_no = 1.

wa_srvacc-serno_line = 01.

wa_srvacc-serial_no = 01.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

wa_srvacc-pckg_no = 20.

wa_srvacc-line_no = 2.

wa_srvacc-serno_line = 02.

wa_srvacc-serial_no = 02.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

wa_srvacc-pckg_no = 40.

wa_srvacc-line_no = 1.

wa_srvacc-serno_line = 01.

wa_srvacc-serial_no = 01.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

wa_srvacc-pckg_no = 50.

wa_srvacc-line_no = 2.

wa_srvacc-serno_line = 02.

wa_srvacc-serial_no = 02.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = wa_header

poheaderx = wa_headerx

IMPORTING

exppurchaseorder = ws_po

TABLES

return = i_return

poitem = i_poitem

poitemx = i_poitemx

poschedule = i_poitem_sch

poschedulex = i_poitem_schx

poaccount = i_acct_ass

poaccountx = i_acct_assx

poservices = i_services

posrvaccessvalues = i_srvacc.

break gbpra8.

LOOP AT i_return INTO wa_return.

ENDLOOP.

ws_wait = 5.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ws_wait.

&----


*& Form conversion_output

&----


  • Conversion exit input

----


FORM conversion_output USING p_ip

CHANGING p_op.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = p_ip

IMPORTING

output = p_op.

ENDFORM. " conversion_output

Regards,

Prakash.

7 REPLIES 7
Read only

Former Member
0 Likes
802

Check the below code:

DATA: i_poitem TYPE STANDARD TABLE OF bapimepoitem,

i_poitemx TYPE STANDARD TABLE OF bapimepoitemx,

i_poitem_sch TYPE STANDARD TABLE OF bapimeposchedule,

i_poitem_schx TYPE STANDARD TABLE OF bapimeposchedulx,

i_acct_ass TYPE STANDARD TABLE OF bapimepoaccount,

i_acct_assx TYPE STANDARD TABLE OF bapimepoaccountx,

i_services TYPE STANDARD TABLE OF bapiesllc ,

i_srvacc TYPE STANDARD TABLE OF bapiesklc,

i_return TYPE STANDARD TABLE OF bapiret2,

wa_header TYPE bapimepoheader,

wa_headerx TYPE bapimepoheaderx,

wa_poitem TYPE bapimepoitem,

wa_poitemx TYPE bapimepoitemx,

wa_poitem_sch TYPE bapimeposchedule,

wa_poitem_schx TYPE bapimeposchedulx,

wa_acct_ass TYPE bapimepoaccount,

wa_acct_assx TYPE bapimepoaccountx,

wa_services TYPE bapiesllc,

wa_srvacc TYPE bapiesklc,

wa_return TYPE bapiret2,

ws_po TYPE bapimepoheader-po_number,

ws_wait TYPE bapita-wait.

CONSTANTS: c_x TYPE char01 VALUE 'X'.

break gbpra8.

wa_header-doc_type = 'ZDET'.

wa_header-vendor = '0002000000'.

PERFORM conversion_output USING wa_header-vendor

CHANGING wa_header-vendor.

wa_header-comp_code = 'DE03'.

wa_header-purch_org = 'DE03'.

wa_header-pur_group = 'DE1'.

wa_header-vper_start = '20060730'.

wa_header-vper_end = '20070621'.

wa_headerx-comp_code = c_x.

wa_headerx-doc_type = c_x.

wa_headerx-creat_date = c_x.

wa_headerx-created_by = c_x.

wa_headerx-vendor = c_x.

wa_headerx-purch_org = c_x.

wa_headerx-pur_group = c_x.

wa_headerx-vper_start = c_x.

wa_headerx-vper_end = c_x.

wa_poitem-po_item = 100.

wa_poitem-short_text = 'Sample'.

wa_poitem-plant = 'DE03'.

wa_poitem-quantity = 1.

wa_poitem-tax_code = 'V1'.

wa_poitem-item_cat = 'D'.

wa_poitem-acctasscat = 'K'.

wa_poitem-matl_group = 'ZDESS'.

wa_poitem-pckg_no = 10.

wa_poitem-gr_ind = space.

wa_poitem-gr_basediv = space.

APPEND wa_poitem TO i_poitem .

wa_poitemx-po_item = 100.

wa_poitemx-po_itemx = c_x.

wa_poitemx-short_text = c_x.

wa_poitemx-plant = c_x.

wa_poitemx-quantity = c_x.

wa_poitemx-tax_code = c_x.

wa_poitemx-item_cat = c_x.

wa_poitemx-acctasscat = c_x.

wa_poitemx-matl_group = c_x.

wa_poitemx-pckg_no = c_x.

wa_poitemx-gr_ind = c_x.

wa_poitemx-gr_basediv = space.

APPEND wa_poitemx TO i_poitemx.

wa_poitem-po_item = 200.

wa_poitem-short_text = 'Sample'.

wa_poitem-plant = 'DE03'.

wa_poitem-quantity = 1.

wa_poitem-tax_code = 'V1'.

wa_poitem-item_cat = 'D'.

wa_poitem-acctasscat = 'K'.

wa_poitem-matl_group = 'ZDESS'.

wa_poitem-pckg_no = 40.

wa_poitem-gr_ind = space.

wa_poitem-gr_basediv = space.

APPEND wa_poitem TO i_poitem .

wa_poitemx-po_item = 200.

wa_poitemx-po_itemx = c_x.

wa_poitemx-short_text = c_x.

wa_poitemx-plant = c_x.

wa_poitemx-quantity = c_x.

wa_poitemx-tax_code = c_x.

wa_poitemx-item_cat = c_x.

wa_poitemx-acctasscat = c_x.

wa_poitemx-matl_group = c_x.

wa_poitemx-pckg_no = c_x.

wa_poitemx-gr_ind = c_x.

wa_poitemx-gr_basediv = space.

APPEND wa_poitemx TO i_poitemx.

wa_acct_ass-po_item = 100.

wa_acct_ass-serial_no = 01.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_assx-po_item = 100.

wa_acct_assx-serial_no = 01.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_acct_ass-po_item = 100.

wa_acct_ass-serial_no = 02.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_assx-po_item = 100.

wa_acct_assx-serial_no = 02.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_acct_ass-po_item = 200.

wa_acct_ass-serial_no = 01.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_assx-po_item = 200.

wa_acct_assx-serial_no = 01.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_acct_ass-po_item = 200.

wa_acct_ass-serial_no = 02.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_assx-po_item = 200.

wa_acct_assx-serial_no = 02.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_services-pckg_no = 10.

wa_services-line_no = 1.

wa_services-outl_no = '0'.

wa_services-outl_ind = c_x.

wa_services-subpckg_no = 20.

wa_services-from_line = 1.

wa_services-to_line = 2.

APPEND wa_services TO i_services.

wa_services-pckg_no = 20.

wa_services-line_no = 2.

wa_services-service = 'H007'.

wa_services-quantity = '12'.

wa_services-gr_price = '100'.

wa_services-userf1_txt = 'Firm'.

APPEND wa_services TO i_services.

wa_services-pckg_no = 40.

wa_services-line_no = 1.

wa_services-outl_no = '0'.

wa_services-outl_ind = c_x.

wa_services-subpckg_no = 50.

wa_services-from_line = 1.

wa_services-to_line = 2.

APPEND wa_services TO i_services.

wa_services-pckg_no = 50.

wa_services-line_no = 2.

wa_services-service = 'H008'.

wa_services-quantity = '12'.

wa_services-gr_price = '100'.

wa_services-userf1_txt = 'Firm'.

APPEND wa_services TO i_services.

wa_srvacc-pckg_no = 10.

wa_srvacc-line_no = 1.

wa_srvacc-serno_line = 01.

wa_srvacc-serial_no = 01.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

wa_srvacc-pckg_no = 20.

wa_srvacc-line_no = 2.

wa_srvacc-serno_line = 02.

wa_srvacc-serial_no = 02.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

wa_srvacc-pckg_no = 40.

wa_srvacc-line_no = 1.

wa_srvacc-serno_line = 01.

wa_srvacc-serial_no = 01.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

wa_srvacc-pckg_no = 50.

wa_srvacc-line_no = 2.

wa_srvacc-serno_line = 02.

wa_srvacc-serial_no = 02.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = wa_header

poheaderx = wa_headerx

IMPORTING

exppurchaseorder = ws_po

TABLES

return = i_return

poitem = i_poitem

poitemx = i_poitemx

poschedule = i_poitem_sch

poschedulex = i_poitem_schx

poaccount = i_acct_ass

poaccountx = i_acct_assx

poservices = i_services

posrvaccessvalues = i_srvacc.

break gbpra8.

LOOP AT i_return INTO wa_return.

ENDLOOP.

ws_wait = 5.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ws_wait.

&----


*& Form conversion_output

&----


  • Conversion exit input

----


FORM conversion_output USING p_ip

CHANGING p_op.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = p_ip

IMPORTING

output = p_op.

ENDFORM. " conversion_output

Regards,

Prakash.

Read only

Former Member
0 Likes
801

Hi,

probably you forgot to fill in a field.

First create the PO manually.

Then use FM BAPI_PO_GETDETAIL for that po. This way you know how to fill in the fields used for bapi_po_create1.

Kind regards, Rob Dielemans

Read only

0 Likes
801

Hi Folks, thanks for your replies.

1. Prakash, I've checked your code, however I forgot to mention that I need the reference on the POITEM of the quotation, so this gets saved in historic information, and that's why is taking the quotation quantity information instead of the one's i'm passing to it.

2. Rob, I will try your solution, and see if that helps.

Thanks again.

I will keep you guys informed.

Regards,

Gilberto Li

Read only

0 Likes
801

Hi again.

I've checked the fields to be filled using the FM BAPI_PO_GETDETAIL and I replicate them on the BAPI_PO_CREATE1 and the bapi still always change the quantity indicated.

Does anyone know how to solve this problem? Am I missing something else?

Regards,

Gilberto Li

Read only

0 Likes
801

Hmm.

Normally this should work, however BAPI_PO_CREATE1 is a dreadfull bapi to work with, espescially when things don't work how you want it.

Search OSS, there are 400+ notes on this BAPI so use a specific search.

If this doesn´t work raise an oss message.

Kind regards, Rob Dielemans

Read only

0 Likes
801

Hi Rob, thanks for your reply.

I will follow as you said, i've tried making the BAPI to work as I would like to but I haven't success.

Thanks again.

Kind regards,

Gilberto Li

Read only

0 Likes
801

Good Luck Gilberto Li,

I only have bad memories regarding this BAPI, so I hope you'll fare better than I have done.

Kind regards, Rob Dielemans