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: 

Changing Item Values before saving Purchase Requisition in me51n, set_data function

Former Member
0 Kudos

Hello,

        I have written a user exit, which is called whenever changes are made to a purchase requisition. User Exit is MEREQ001 , function module EXIT_SAPLMEREQ_010 . My requirement here is that the Requisitioner should be 135 for every PR item under certain conditions. Therefore whenever there is any change made to the PR, before saving the PR item, I need to set the Requisitioner to 135, give a status message saying that the Requisitioner is set to 135 and save the Pr with the changed values. Following is the code I have written in EXIT_SAPLMEREQ_010. However, the set_data function called below does not change the PR values. Pls help

data: lt_item type mmpur_requisition_items,
       wa_item type mmpur_requisition_item,
       wa_itemdet type mereq_item,
       wa_itemref type ref to if_purchase_requisition_item,

       w_message type i.

constants: c_135 type afnam value '135'.



call method im_req_header->get_items
     receiving
             re_items = lt_item.

    loop at lt_item into wa_item.
     wa_itemref = wa_item-item.
     wa_itemdet = wa_itemref->get_data( ).

     if wa_itemdet-afnam ne c_135.
       w_message = 1.
       wa_itemdet-afnam = c_135.
       call method wa_itemref->set_data( wa_itemdet ).
     endif.
   endloop.


  IF w_message = 1.
    MESSAGE 'Requisitioner defaulted to 135 for all items' TYPE 'I'.
  ENDIF.

1 ACCEPTED SOLUTION

former_member228751
Contributor
0 Kudos

Hi Elizabeeth,

Do not use the function module EXIT_SAPLMEREQ_010 as doesnt have any parameter referencing to if_purchase_requisition_item.

Please implement BADI ME_PROCESS_REQ_CUSTand create its implementation.

Please write this code in the method PROCESS_ITEM. In this menthod you have parameter referencing to if_purchase_requisition_item. Here you can set the values of PR you want.

Thanks,

Sachin

8 REPLIES 8

former_member228751
Contributor
0 Kudos

Hi Elizabeeth,

Do not use the function module EXIT_SAPLMEREQ_010 as doesnt have any parameter referencing to if_purchase_requisition_item.

Please implement BADI ME_PROCESS_REQ_CUSTand create its implementation.

Please write this code in the method PROCESS_ITEM. In this menthod you have parameter referencing to if_purchase_requisition_item. Here you can set the values of PR you want.

Thanks,

Sachin

0 Kudos

Hi Sachin,

           I am able to get a reference to if_purchase_requisition_item in my code (wa_itemref ) and am also able to access each of the line items in the PR in the work area wa_itemdet.


At this point in the code ( wa_itemdet-afnam = c_135 ) , the work area value is set to '135', However, call method wa_itemref->set_data( wa_itemdet ), does not change the values of the work area wa_itemdet . Pls help




      

Hi Elizabeth,

Just because you can doesn't mean you should.  The BADI suggested by Sachim seems more appropriate.

Cheers,

Custodio

raymond_giuseppi
Active Contributor
0 Kudos

I don't think this customer-exit will actually allow the change of data, will it trigger a new check loop in the system if you don't raise an error message, not sure, this exit may be equivalent to ME_PROCESS_REQ_CUST suggested by method CHECK, but better use this BADI with a method like PROCESS_ITEM.

0 Kudos

Hi Raymond,

                 I wrote my code in the PROCESS_HEADER method of the BADI ME_PROCESS_REQ_CUST and now I am able to set values for the PR items. The only thing remaining now is displaying an 'I' type message saying that the PR items data has been changed Can u please tell me exactly how  to display a message using the 

0 Kudos

In the method, add some code like :

INCLUDE mm_messages_mac.
mmpur_metafield mmmfd_preq_name.
mmpur_message_forced 'I' '00' '001' 'Requisitioner defaulted to 135 for all items' '' '' ''.

Regards,

Raymond

0 Kudos

Hello,

          I am still not able to display an "I" type message using the macro mmpur_message_forced in the PROCESS_HEADER method of the BADI ME_PROCESS_REQ_CUST. Somebody pls help

Following is the code

INCLUDE mm_messages_mac.


IF w_message = 1.  "flag

      mmpur_message_forced 'I' 'ME' '303' 'Requisitioner defaulted to 135 for all items' '' '' ''.

endif.

Former Member
0 Kudos

Hi, look at this example,