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: 

Update EKPV-KUNNR in shipping tab of ME21N/ME22N

Former Member
0 Kudos

Hello,

I have a requirement where I have to update EKPV-KUNNR with a new value.

I tried to use BADI ME_PROCESS_PO_CUST Method PROCESS_ITEM.

I am using get_shipping_data to get the shipping details and then modifying EKPV-KUNNR and calling set_shipping_data but this is not getting updated.

I found out that in set_shipping_data, there is an old record and new record, and in new record only few fields are changed and because of that old_record is always equal to new_record and that is why my changed customer number is not updated.

Code in set_shipping_data

  l_data_old = me->if_purchase_order_item_mm~get_shipping_data( ).

* initial transfer from BAPI interface (old_data always empty)

  IF l_parent->for_bapi EQ mmpur_no.

    CHECK NOT l_data_old IS INITIAL.

  ENDIF.

  l_data_new = l_data_old. 

MOVE: im_ekpv-vstel TO l_data_new-vstel,

        im_ekpv-lprio TO l_data_new-lprio,

        im_ekpv-vsbed TO l_data_new-vsbed,

        im_ekpv-route TO l_data_new-route,

        im_ekpv-ablad TO l_data_new-ablad,

        im_ekpv-spe_auth_number  TO l_data_new-spe_auth_number,

        im_ekpv-spe_src_dlv_no   TO l_data_new-spe_src_dlv_no,

        im_ekpv-spe_src_exidv    TO l_data_new-spe_src_exidv,

        im_ekpv-spe_inspout_guid TO l_data_new-spe_inspout_guid,

        im_ekpv-spe_follow_up    TO l_data_new-spe_follow_up.

  IF l_data_new NE l_data_old.

    READ TABLE po_ekpv_hash_table INTO wa WITH TABLE KEY item = me.

    IF sy-subrc IS INITIAL.

      wa-data = l_data_new.

      MODIFY TABLE po_ekpv_hash_table FROM wa.

    ELSE.

      wa-item = me.

      wa-data = l_data_new.

      INSERT wa INTO TABLE po_ekpv_hash_table.

    ENDIF.

    ekpv_changed = mmpur_yes.

The issue is that none of the aforementioned fields are being changed so code never goes to l_data_new NE l_data_old where EKPO table is updated.

Can anyone help??

5 REPLIES 5

former_member188827
Active Contributor
0 Kudos

Have you checked im_ekpv in debugging? Does it contain values that are different from l_data_old?

Regards

0 Kudos

Hi Mehwish,

Yes I debugged it and l_data_old is same as l_data_new but im_ekpv contains changed value of customer number (KUNNR) but this does not affect l_data_new as only

   MOVE: im_ekpv-vstel TO l_data_new-vstel,

         im_ekpv-lprio TO l_data_new-lprio,

         im_ekpv-vsbed TO l_data_new-vsbed,

         im_ekpv-route TO l_data_new-route,

         im_ekpv-ablad TO l_data_new-ablad,

         im_ekpv-spe_auth_number  TO l_data_new-spe_auth_number,

         im_ekpv-spe_src_dlv_no   TO l_data_new-spe_src_dlv_no,

         im_ekpv-spe_src_exidv    TO l_data_new-spe_src_exidv,

         im_ekpv-spe_inspout_guid TO l_data_new-spe_inspout_guid,

         im_ekpv-spe_follow_up    TO l_data_new-spe_follow_up.

these fields are being moved to l_data_new which remain unchanged.

So if any of the above fields changes then only i_data_new is different from l_data_old which is  not happening in my case. Do I need to code somewhere else? Any exit may be?

0 Kudos

So, why are you not passing im_ekpv-kunnr to l_data_new-kunnr? i dont see any move statement for this.

Regards

0 Kudos

This is the standard code written in set_shipping_data, it is not the custom code. It is written that way only if these fields change then only updation happens. Do I need to change the standard code?

0 Kudos

Im sorry, i dont have system access right now, thats why cant check the code:) Yes, you can try an implicit enhancement to do so. As far as i remember, certain fields cannot be changed through this badi, so you can check if you get appropriate enhancement point to plug in your code.

Regards