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_change quantity adds up

Former Member
0 Likes
2,353

hi

i m using bapi_po_change for bapi change.

but it adds up quantity in existing record instead of updating it

hi

i m using bapi_po_change for bapi change.

but it adds up quantity in existing record instead of updating it

13 REPLIES 13
Read only

Former Member
0 Likes
2,109

Hi, send us your code.

Read only

0 Likes
2,109

   item-po_item = w_ekpo-ebelp.

       item-material = w_ekpo-matnr.

       item-plant = w_ekpo-werks.

       item-quantity = w_ekpo-menge.

       item-net_price = w_ekpo-netpr.

*      item-ir_ind    = ' '.
*      itemx-info_upd = 'U'.
       APPEND item TO item1.
       itemx-po_item = w_ekpo-ebelp .
       itemx-po_itemx = 'X' .
       itemx-material ='X' .
       itemx-plant = 'X' .
       itemx-quantity = 'X' .
       itemx-net_price = 'X' .

Read only

0 Likes
2,109

Hi, I have tested with the below simple logic and it works for me.


CLEAR: item, itemx.

item-po_item = '00010'.
CLEAR MENGE.
MENGE = 150.
item-quantity = MENGE.
APPEND ITEM TO PO_ITEM.

itemx-po_item = '00010'.
itemx-po_itemx = 'X'.
itemx-quantity = 'X'.
APPEND ITEMX TO PO_ITEMX.

CALL FUNCTION 'BAPI_PO_CHANGE'
  EXPORTING
    PURCHASEORDER = ebeln
  TABLES
    RETURN        = bapiret2
    POITEM        = po_item
    POITEMX       = po_itemx.

IF sy-subrc is INITIAL.
  commit WORK.
ENDIF.

Read only

0 Likes
2,109

it is adding up quantity,do i need to put some indicator

Read only

0 Likes
2,109

Hi

Can you check the schedule line items as well ?? ?

  ls_poschedule-po_item      =  .

  ls_poschedule-sched_line   =

  ls_poschedule-quantity     =

   APPEND ls_poschedule TO lt_poschedule.

ls_poschedulex-sched_linex 'X'.


  APPEND ls_poschedulex TO lt_poschedule

Read only

0 Likes
2,109

ya i did this.

data is perfect before going into bapi.

bapi is adding up quantity value with existing quantity.it should update

Read only

0 Likes
2,109

Hi, I have tried with your logic aswell and it is working for me. May be you try to change the PO using ME22N with the same data and see what went wrong.

Read only

0 Likes
2,109

hi

check whether this happens for a particular PO  or all the PO 's ....For the PO you are trying to update ensure that  GR has not happened !!!!

Read only

lijisusan_mathews
Active Contributor
0 Likes
2,109

Instead of giving the Quantity in Item ,

Give it in Schedule line item


  
wa_schedule-sched_line        = '10'.
   wa_schedule-req_qty           = wa_upload-qty."'4.5'.
   APPEND wa_schedule TO it_schedule.

   wa_shedulex-itm_number          = w_no.
   wa_shedulex-updateflag              = 'U'.
   wa_shedulex-sched_line        = '10'.
   wa_shedulex-req_qty           = 'X'.


Can you try this and respond

by the way,

I had faced thsi same issue, and it was definitely coz of this flag.

Regards,

Suzie

Read only

0 Likes
2,109

i cant see req_qty and updatefalg field in schedule table

and if i dont pass schedule table in bapi,quantity remains same means its not updating tha quantity.

Read only

0 Likes
2,109

O I am extremely sorry.. I mistook the bapi for Sales order change , not Po change..

In thsi case, try replacing 'X' with 'U' in schedulex.

Read only

0 Likes
2,109

'U' in which field of schedule

my code for schedule.

  schedule-po_item = w_eket-ebelp.

         schedule-sched_line = w_eket-etenr.

         schedule-delivery_date = w_eket-eindt.

         schedule-quantity = w_eket-menge.

         APPEND schedule TO schedule1.
         schedulex-po_item = w_ekpo-ebelp.
         schedulex-sched_line = w_eket-etenr.
         schedulex-sched_linex = 'X'.
         schedulex-po_itemx = 'X'.
         schedulex-sched_linex = 'X'.
         schedulex-delivery_date = 'X'.
         schedulex-quantity = 'X'.
         APPEND schedulex TO schedulex1.

Read only

0 Likes
2,109

  schedulex-quantity = 'U'.