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: 

Po Creation Price Change Updation.

VenkatRamesh_V
Active Contributor
0 Kudos

I am fetching some pricing condition values from  the  ztable, And    passing to PO   while  creation.

BADI: ME_PROCESS_PO_CUST

METHOD: IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM

CODE:

im_item->get_conditions( IMPORTING ex_conditions = lt_conditions ).

LOOP AT  lt_conditions INTO ls_condition  WHERE  kposn = ls_mepoitem-ebelp. "AND

                                                                              kschl = 'ZGR'.

         lv_flag = 'X'.

         ls_condition-kbetr    = lv_exval.

         ls_condition-kwert    = lv_exval.

         MODIFY lt_conditions FROM ls_condition TRANSPORTING kbetr kwert.

         im_item->set_conditions( EXPORTING im_conditions = lt_conditions ).

ENDLOOP.

While executing  Pricing values updated in ME21N  but displaying

ERROR An endless loop occurred during the processing of the Business Add-In ME_PROCESS_PO_CUST. The system terminated the processing.

ADDED Below code to avoid  Error.

cl_po ?=  im_header.

    IF NOT  cl_po->my_recheck_queue IS INITIAL.

        CLEAR cl_po->my_recheck_queue.

      ENDIF.

But   pricing conditions  values not getting updated in Po.

1 ACCEPTED SOLUTION

VenkatRamesh_V
Active Contributor
0 Kudos

Solved by

Replacing

         im_item->set_conditions( EXPORTING im_conditions = lt_conditions ).

       

        IF NOT  cl_po->my_recheck_queue IS INITIAL.

        CLEAR cl_po->my_recheck_queue.

      ENDIF.

With


Data  cl_po  TYPE REF TO cl_po_header_handle_mm.


CALL METHOD cl_po->set_tkomv(

       im_tkomv = lt_conditions

       im_item_conditions_changed = mmpur_yes ).

Regards,

Venkat Ramesh.V

4 REPLIES 4

Former Member
0 Kudos

Why not just set a flag to check if it is your first iteration in the BAdi?

0 Kudos

Hi,

Thankyou for replying.

i declared flag already.

LOOP AT  lt_conditions INTO ls_condition  WHERE  kposn = ls_mepoitem-ebelp. "AND

                                                                              kschl = 'ZGR'.

         lv_flag = 'X'.

         ls_condition-kbetr    = lv_exval.

         ls_condition-kwert    = lv_exval.

         MODIFY lt_conditions FROM ls_condition TRANSPORTING kbetr kwert.

         im_item->set_conditions( EXPORTING im_conditions = lt_conditions ).

ENDLOOP.

IF lv_flag is not initial.

cl_po ?=  im_header.

    IF NOT  cl_po->my_recheck_queue IS INITIAL.

        CLEAR cl_po->my_recheck_queue.

      ENDIF.


ENDIF.

but values are not updated in Po.

Regards,

Venkat Ramesh .V



0 Kudos

Umm, I am not sure what  cl_po->my_recheck_queue. does.


But I guess you are getting into infinite loop because you are changing the item within the process of changing an item. So, whenever you try to set the condition, PROCESS_ITEM must be triggered. Hence, a better way is to declare a flag as attribute of the class of the implementation, and set it whenever you get in loop for the first time. and then check the flag before calling set_conditions again.

VenkatRamesh_V
Active Contributor
0 Kudos

Solved by

Replacing

         im_item->set_conditions( EXPORTING im_conditions = lt_conditions ).

       

        IF NOT  cl_po->my_recheck_queue IS INITIAL.

        CLEAR cl_po->my_recheck_queue.

      ENDIF.

With


Data  cl_po  TYPE REF TO cl_po_header_handle_mm.


CALL METHOD cl_po->set_tkomv(

       im_tkomv = lt_conditions

       im_item_conditions_changed = mmpur_yes ).

Regards,

Venkat Ramesh.V