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: 

How to update a field in EKPO while releasing ME29N?

himanshu_gupta13
Employee
Employee
0 Kudos

Dear Experts,

I have a requirement in which while releasing the PO through ME29n, want to update a field of EKPO-IDNLF line item level from EKKO- FRGKE header level.

Kindly help me to sort out this problem.

Many Thanks / Himanshu Gupta

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

ME29N use same program than ME21N/ME22N so you should be able to use BAdI ME_PROCESS_PO_CUST methods.

Regards,

Raymond

16 REPLIES 16

raymond_giuseppi
Active Contributor
0 Kudos

ME29N use same program than ME21N/ME22N so you should be able to use BAdI ME_PROCESS_PO_CUST methods.

Regards,

Raymond

0 Kudos

Dear Raymond,

Thanks..

We used this BADI ME_PROCESS_PO_CUST and in implemenation use the method POST but here in parameter only the IM_HEADER available, actually requirement is first go the the IM_HEADER then accordingly check the field FRGKE i.e. release indicator with the line item data field IDNLF . If it's different each other then have to update the field IDNLF with FRGKE.

But unable to update the field because here <item>-item is local parameter I think..

For your reference code is ...

IF sy-tcode = 'ME29N' .
     DATA: ls_mepoitem TYPE mepoitem,
            ls_mepoheader TYPE mepoheader,
            ls_mepoitemobj TYPE purchase_order_items.

     FIELD-SYMBOLS :<item> TYPE purchase_order_item,
                    <mepoitem>   TYPE mepoitem.

     CALL METHOD im_header->get_data
       RECEIVING
         re_data = ls_mepoheader.



     CALL METHOD im_header->get_items
       RECEIVING
         re_items = ls_mepoitemobj.



     LOOP AT  ls_mepoitemobj ASSIGNING <item>.
       CALL METHOD <item>-item->get_data
         RECEIVING
           re_data = ls_mepoitem.

       DATA : v_frgke TYPE FRGKE,
              v_idnlf TYPE IDNLF.

       CLEAR :v_idnlf, v_frgke.
       SELECT SINGLE FRGKE
         INTO v_frgke
         FROM EKKO
         WHERE EBELN = ls_mepoitem-ebeln.
       IF ( sy-subrc eq 0 ) and ( ls_mepoheader-frgke NE v_frgke ).
         ls_mepoitem-idnlf = v_frgke .

         CALL METHOD <item>-item->set_data
           EXPORTING
             im_data = ls_mepoitem.
       ELSEIF sy-subrc ne 0.

         ls_mepoitem-idnlf = v_frgke .

         CALL METHOD <item>-item->set_data
           EXPORTING
             im_data = ls_mepoitem.
       ENDIF.
     ENDLOOP.
   ENDIF.



Many Thanks/ HImanshu Gupta

0 Kudos

Hi Himanshu

Since you need to modify the data at line item level you should use PROCESS_ITEM method

Nabheet

0 Kudos

Hi nabheet,

For ME29N it will not go in PROCESS_ITEM..

Thansks

0 Kudos

Yes you are right it will trigger if you change any item..What you can try is in posted event call BAPI for change purchase order as a background task.

Nabheet

0 Kudos

Don't use POST, this method does not allow change of data (only allows processing of customer tables or triggering of other actions)

  • Try PROCESS_HEADER or CHECK methods.
  • Also don't SELECT information from database but use method GET_PERSISTENT_DATA.

Regards,

Raymond

0 Kudos

Yes, we used BAPI change purchase ourder but it was causing an error but we didn't use as a background task now I try it...

Thx..

0 Kudos

Backkground task will make sure PO is not locked but you will have to pass all the necessary detail or you can try Raymond suggestion also.

Nabheet

0 Kudos

Here, is GET PERSISTENT DATA use to get the header data of current processing PO or already posted header data in database in against of processed PO, because I need to have the value of  FRGKE already posted and compare with the current  FRGKE, hence their is any difference further logic works.

Thanks

0 Kudos

get_persistent_data get the same information from database that current transaction/processing got at start when reading from database. So here you can check if field value has changed in memory and not yet commited to database.

So in a PROCESS_HEADER :

  • Comparing get_data and get_persistent_data you will detect changes not yet commited to database, but remember the method can be executed multiple times so you will detect the same cagnge multiple time (so okay comare item data before using a set_data to prevent infinite loop)
  • Comparing get_data and get_previous_data you will trigger your change only once when the data is changed.

In a CHECK method always compare with get_persistent_data.

Regards,

Raymond

0 Kudos

Thanks for giving me information on this.... Now, I check it all and find out that set data is not working...

CALL METHOD <item>-item->get_data
               RECEIVING
                 re_data = ls_mepoitem.

             CLEAR :v_idnlf, v_frgke.
**            SELECT SINGLE FRGKE
**              INTO v_frgke
**              FROM EKKO
**              WHERE EBELN = ls_mepoitem-ebeln.
             CALL METHOD IM_HEADER->GET_PERSISTENT_DATA
               IMPORTING
                 EX_DATA ls_prevhead
                     .
             IF ( sy-subrc eq 0 ) and ( ls_mepoheader-frgke NE ls_prevhead-frgke ) AND ( ls_mepoheader-frgke ne ls_mepoitem-idnlf ).
               ls_mepoitem-idnlf = ls_mepoheader-frgke .

               CALL METHOD <item>-item->set_data
                 EXPORTING
                   im_data = ls_mepoitem.


Thx..

0 Kudos

Remenber you cannot use set_data in POST method, in which method did you insert this code ?

Regards,

Raymond

0 Kudos

I am using in Check method

Many Thanks / HImanshu Gupta

former_member946717
Contributor
0 Kudos

Dear Himanshu,

The best way to find an enhancement or BADI to do add logic for your requirement is, go to SE84 and for the package ME, check if there are any enhancements or exits. Maybe you can implement and see

Hope this helps!

himanshu_gupta13
Employee
Employee
0 Kudos

Hi Raymond and Nabhdeep,

I used the BAPI_PO_CHANGE as background process with delay of 10 seconds suggested by nabhdeep, it's working fine.

Thanks to both for your support.

Many Thanks / Himanshu Gupta

0 Kudos

Himanshu you could try it by calling as background task no need to wait will be needed.