Badi ME_PROCESS_PO_CUST is used for standard user exits for transaction ME21N,ME22n and ME23n
I am using the method PROCESS_ITEM to check a condtion on an item level and then update a fieald in the condtion (KWERT) and then i want to update the condtion.
This is the code in method process_item :
data: ls_mepoitem type mepoitem
,ls_condition TYPE komv
,lt_conditions type MMPUR_TKOMV.
ls_mepoitem = im_item->get_data( ).
im_item->get_conditions( IMPORTING EX_CONDITIONS = lt_conditions ).
LOOP AT lt_conditions INTO ls_condition WHERE kschl = 'PB00'.
ls_condition-kwert = '88.8'
MODIFY lt_conditions FROM ls_condition.
im_item->set_conditions( lt_conditions ).
The code compiles and can be executed, but the result is that the standard SAP framework starts in an endless loop and exits after severals loops.
If I remove the im_item->set_conditions statement, then there is no endless loop, so the fault is in the set_conditions method. (Which is a standard method). I also get this error message from the system and there it seems that it is just impossible to update the KWERT field.
Can anyone confirm to me that this is the case or can anyone help me to make this work ( change the KWERT field in conditions when the PO is processing the items). ?
Here is the error messages from the system.
Data from Business Add-In ME_PROCESS_PO_CUST not adopted
Message no. MEPO151
An endless loop occurred during the processing of the Business Add-In ME_PROCESS_PO_CUST. The system terminated the processing.
Contact your system administrator.
Procedure for System Administration
Check whether standard fields are changed in the implementation of the Business Add-In ME_PROCESS_PO_CUST.
Changes to standard fields that are part of the Include structure MEPOITEM_TECH and/or MEPOSCHEDULE_TECH are generally not allowed. In addition, no field values that are not changeable through the field settings in the Enjoy transactions can be changed in the BAdI. Correct the implementation accordingly.
It goes to an endless loop because of infinite line item u have to just two lines it may solve ur problem
DATA: lv_bnfpoTYPE banfpo.
IMPORT lv_bnfpo TO lv_bnfpo FROM MEMORY ID 'ZHDR'.
**>If the line item changes (track line item changes)
IF lv_bnfpo <> lv_items-bnfpo
your code of set conditions.
FREE MEMORY ID 'ZHDR'.
lv_bnfpo = lv_items-bnfpo. "lv_items is a table which is populating from get_data method
EXPORT lv_bnfpo FROM lv_bnfpo TO MEMORY ID 'ZHDR'.
Use following code
DATA: LV_PO_HEAD_REF type ref to IF_PURCHASE_ORDER_MM,
CL_PO type ref to CL_PO_HEADER_HANDLE_MM.
LV_PO_HEAD_REF = IM_ITEM->GET_HEADER( ).
* Initialize header check
CL_PO ?= LV_PO_HEAD_REF.
if not CL_PO->MY_RECHECK_QUEUE is initial.