cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_PO_CREATE1 partial order for purchase requisition

0 Kudos

Dear Community,

I'm facing a problem with P/O creation by BAPI_PO_CREATE1 ... and I am hoping someone knows the solution for this ...

I'm creating a P/O with the above BAPI with reference to a purchase requisition. The quantity of the requisition is supposed to be distributed between multiple P/O items with different outline agreements, for instance like that:

P/O Item 1: Qty 30 PC, PReq: 12715564, Outline Agmnt: 4600003793, Contract Item: 10

P/O Item 2: Qty 70 PC, PReq: 12715564, Outline Agmnt: 4600003796, Contract Item: 30

(P/O requisition: quantity: 100 PC, ordered quantity: 0 PC, open quantity: 100 PC)

The P/O is created as expected, but the values in the purchase requisition are like that after P/O creation (ordered quantity is wrong):

Quantity: 100 PC, quantity ordered: 200 PC, open quantity: 0 PC

Doing the same with ME21N gives the right result: quantity ordered = 100 PC.

If I compare the values in the database tables afterwards, EKKO, EKPO and EKET are the same for P/O creation by BAPI and by ME21N, but EBAN shows a difference:

BAPI: EBELN = outline agreement number, BSMNG = 200

ME21N: EBELN = P/O number, BSMNG = 100

This is how I fill the BAPI items:

ls_item-po_item = lv_ebelp. ls_itemx-po_item = lv_ebelp.

ls_item-material = <f_plan>-matnr. ls_itemx-material = abap_true.

ls_item-agreement = <f_plan>-agr_ebeln. ls_itemx-agreement = abap_true.

ls_item-agmt_item = <f_plan>-agr_ebelp. ls_itemx-agmt_item = abap_true.

ls_item-plant = <f_plan>-werks. ls_itemx-plant = abap_true.

ls_item-no_rounding = abap_true. ls_itemx-no_rounding = abap_true.

ls_item-item_cat = lv_item_cat. ls_itemx-item_cat = abap_true.

ls_item-quantity = <f_plan>-po_itotq. ls_itemx-quantity = abap_true.

ls_item-preq_no = <f_plan>-banfn. ls_itemx-preq_no = abap_true.

ls_item-preq_item = <f_plan>-bnfpo. ls_itemx-preq_item = abap_true.

APPEND ls_item TO lt_item.

APPEND ls_itemx TO lt_itemx.

ls_schedule-po_item = ls_item-po_item.

ls_schedulex-po_item = ls_item-po_item.

ls_schedule-sched_line = 1.

s_schedule-preq_no = ls_eban-banfn. ls_schedulex-preq_no = abap_true.

ls_schedule-preq_item = ls_eban-bnfpo. ls_schedulex-preq_item = abap_true.

ls_schedule-quantity = <f_plan>-po_itotq. ls_schedulex-quantity = abap_true.

APPEND ls_schedule TO lt_schedule.

APPEND ls_schedulex TO lt_schedulex.

... the same for item 1

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = ls_header

poheaderx = ls_headerx

IMPORTING

exppurchaseorder = lv_ebeln

TABLES

return = lt_return

poitem = lt_item

poitemx = lt_itemx

poschedule = lt_schedule

poschedulex = lt_schedulex.

Does anybody have an idea, what to do?

Accepted Solutions (0)

Answers (1)

Answers (1)

Jelena
Active Contributor
0 Kudos

Dunno, as long as the quantities you are entering are correct I'd assume it should work. There seems to be nothing wrong with the code. Perhaps search for the SAP notes regarding BAPI, run ANST and, if nothing found, open an incident with SAP.

P.S. Please make use of the "code" button to format the code for better readability. Thank you.