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: 

how to change the open quantity of PO / STO using BAPI_PO_CHANGE

Former Member
0 Kudos
1,303

Hi Friends,

How can I change the open quantity in ME22 using the BAPI BAPI_PO_CHANGE...

I am getting some errors..The values I am passing to the BAPI are:-

*-- Purchase Order document

lv_purchaseorder = tbl_join-ebeln.

*-- Calculate Open quantity

lv_quantity = ( tbl_join-menge - tbl_join-wemng ).

*-- Fills Schedule quantity to be processed.

tbl_poschedule-po_item = tbl_join-ebelp.

tbl_poschedule-sched_line = tbl_join-etenr.

tbl_poschedule-quantity = lv_quantity.

APPEND tbl_poschedule.

*-- Marks the Schedule quantity to be processed.

tbl_poschedulex-po_item = tbl_join-ebelp.

tbl_poschedulex-sched_line = tbl_join-etenr.

tbl_poschedulex-po_itemx = c_true.

tbl_poschedulex-sched_linex = c_true.

tbl_poschedulex-quantity = c_true.

APPEND tbl_poschedulex.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

PURCHASEORDER = lv_purchaseorder

  • POHEADER =

  • POHEADERX =

  • POADDRVENDOR =

TESTRUN = 'X'

  • IMPORTING

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

RETURN = tbl_return

POSCHEDULE = tbl_poschedule

POSCHEDULEX = tbl_poschedulex.

Is there any other required fields needs to be passed to change the open quantity..

I am checking in ME22...

The scheduled quantity is 20.

Delivered quantity is 15.

Open quantity is 5 and ( this field is in non-editable display )

Delivery date is 10.10.2002 ( which is in past )

Now using this BAPI ..I want to post the remaining open quantity which is " 5 "

How can i do this ?? Please help.

11 REPLIES 11

Former Member
0 Kudos
451

Hi Hari

Please check after making the following changes:

*-- Marks the Schedule quantity to be processed.

tbl_poschedulex-po_item = tbl_join-ebelp.

tbl_poschedulex-sched_line = tbl_join-etenr.

<b>tbl_poschedulex-po_itemx = 'U'. "c_true.

*tbl_poschedulex-sched_linex = c_true.</b>

tbl_poschedulex-quantity = c_true.

APPEND tbl_poschedulex.

If still you do not get the desired function working add the below code:

tbl_poitem-po_item = tbl_join-ebelp.
tbl_poitem-quantity = lv_quantity.
append tbl_poitem.

tbl_poitemx-po_item = tbl_join-ebelp.
tbl_poitemx-po_itemx = 'U'.
tbl_poitemx-quantity = c_true.
append tbl_poitemx.

Hope this helps.

Kind Regards

Eswar

0 Kudos
451

Hi Eswar,

What is " U " which u mentioned ??

0 Kudos
451

Ok, now i have tried myself.

Here are the parameters that i have passed for successfully changing the quantity.

PURCHASEORDER - PO Number

<b>POSCHEDULE</b>

--PO_ITEM - Item Number

--SCHED_LINE - Schedule Line Number

--QUANTITY - Quantity

<b>POSCHEDULEX</b>

--PO_ITEM - Item Number

--SCHED_LINE - Schedule Line Number

--QUANTITY - 'X'.

Hope it helps this time.

Kind Regards

Eswar

0 Kudos
451

Hi ,

Scheduled quan = 15

Qty delivered = 12

Open quantity = 3.

Now i have to change this 3 to 0 to make it as fully delivered and this Purchase document should not appear in the table VETVG.

In quantity field I am passing this '<b> 3 '.</b> ...plz luk into BAPI error.

This is the same code as mine. But I am having a few errors from BAPI.

Errors are:-

1) Purchase order still contains faulty items

2) Quantity (+ overdelivery tolerance) is less than quantity delivered(12)

3) Quantity 3 smaller than quantity delivered 12

0 Kudos
451

Hi Eswar,

I tried with one more Purchase document and tested the BAPI directly ..by passing the same parameters.

It returned success message saying that xyz document is changed...But I checked in ME23 ..but still the open quantity is remained same and there are no changes effected.

Thanks -> Hari krishna

0 Kudos
451

Hi Hari

I guess, you should change the order quantity...

i.e pass 12 instead of 3 in the way that i have provided you earlier.

For the second case, i guess you have executed in SE37, have you done the COMMIT Work???

Kind Regards

Eswar

0 Kudos
451

Hi Eswar ..

Do you mean in quantity field should i pass '12'.

With the another purchase document ..

Yes..I executed the BAPI without Test Run only

But no results in ME23

0 Kudos
451

Hi Hari

Yah you got my point. Please try it that way.

I will try by doing few customization settings to enable the process in my system. It might take a while for me to complete that. So please test with the way that i have mentioned to check if itz happening in your desired way...

Kind Regards

Eswar

0 Kudos
451

0 Kudos
451

Hari

Hurrayyyyyy, I have managed to do the process successfully.

As per my understanding your requirement is as below:

When partial delivery has happened, we will still find an entry in table VETVG. So you want to negotiate by changing the quantity, hence the entry in VETVG is disappeared.

Below is what i have done:

1. Created a Stock PO.

2. Created delivery for partial quantity

3. Done the Goods Issue

4. Change the quantity in PO to the qty that has been delivered via BAPI: BAPI_PO_CHANGE.

I have successfully changed the PO quantity via BAPI to find the entry in table VETVG disappear.

Do correct me if my understanding is wrong.

Kind Regards

Eswar

0 Kudos
451

Hi Eswar,

You got my requirement properly. Please send me the code . Remember I PO can contain multiple line items and 1 line item contain multiple schedule line items.

Please explain how u proceeded. If possible Please send me the code.