Application Development 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: 

bapi_po_change quantity adds up

Former Member
0 Kudos

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

former_member200345
Contributor
0 Kudos

Hi, send us your code.

0 Kudos

   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' .

0 Kudos

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.

0 Kudos

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

0 Kudos

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

0 Kudos

ya i did this.

data is perfect before going into bapi.

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

0 Kudos

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.

0 Kudos

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 !!!!

lijisusan_mathews
Active Contributor
0 Kudos

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

0 Kudos

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.

0 Kudos

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.

0 Kudos

'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.

0 Kudos

  schedulex-quantity = 'U'.