04-02-2014 6:55 AM
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
04-02-2014 7:06 AM
ME29N use same program than ME21N/ME22N so you should be able to use BAdI ME_PROCESS_PO_CUST methods.
Regards,
Raymond
04-02-2014 7:06 AM
ME29N use same program than ME21N/ME22N so you should be able to use BAdI ME_PROCESS_PO_CUST methods.
Regards,
Raymond
04-02-2014 7:19 AM
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
04-02-2014 7:27 AM
Hi Himanshu
Since you need to modify the data at line item level you should use PROCESS_ITEM method
Nabheet
04-02-2014 7:39 AM
04-02-2014 7:56 AM
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
04-02-2014 8:02 AM
Don't use POST, this method does not allow change of data (only allows processing of customer tables or triggering of other actions)
Regards,
Raymond
04-02-2014 8:06 AM
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..
04-02-2014 8:11 AM
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
04-02-2014 8:26 AM
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
04-02-2014 8:42 AM
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 :
In a CHECK method always compare with get_persistent_data.
Regards,
Raymond
04-02-2014 9:31 AM
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..
04-02-2014 9:46 AM
Remenber you cannot use set_data in POST method, in which method did you insert this code ?
Regards,
Raymond
04-02-2014 9:56 AM
04-02-2014 7:16 AM
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!
04-02-2014 10:55 AM
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
04-02-2014 11:18 AM
Himanshu you could try it by calling as background task no need to wait will be needed.