Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Accessing all the line items of Purchase requisition(ME51N)

Hi All,

Is there any way to access all the line items of a purchase requisition(ME51N) at a time?  I Implemented a BADI ‘ME_PROCESS_REQ_CUST’ and check all the interfaces like PROCESS_ITEM, CHECK, POST etc and found these interfaces only triggers for one line item which is currently being processed. Can anyone suggest.



Former Member
Former Member replied

Thank you all for your help. Finally I solved the user requirement with the below code, which I have written in CHECK method.

DATA : ls_item     TYPE mmpur_requisition_items,"mereq_item,

          lv_lifnr    TYPE wlief,

          l_item_list TYPE mmpur_requisition_items,

          l_item      TYPE mmpur_requisition_item,

          l_item_akt  TYPE mereq_item,

          l_item_ref  TYPE REF TO if_purchase_requisition_item,

          ld_attr     TYPE string,

          lo_obj      TYPE REF TO object,

          lv_procss   TYPE char1.


     <lo_lcl>        TYPE any,

     <ls_item>       TYPE mereq_item,

     <ls_itemx>      TYPE mereq_itemx.

   IMPORT lv_procss TO lv_procss FROM MEMORY ID 'ZPROCSSED'.

* TO execute update process for all line item only once

   IF lv_procss NE 'X'.

* Get all the line item into internal tbale

     CALL METHOD im_header->get_items


         im_auth_check = mmpur_no

         im_release_op = mmpur_no


         re_items      = ls_item.

     l_item_list = im_header->get_items( ).

     LOOP AT l_item_list INTO l_item.

* Decode the line item from reference to Data.

       l_item_akt = l_item-item->get_data( ).

       l_item_ref = l_item-item.

       lo_obj     ?= l_item-item.

       ld_attr = 'MY_STATE'.

       ASSIGN lo_obj->(ld_attr) TO <lo_lcl>.

       ld_attr = 'MY_STATE->ITEM'.

       ASSIGN lo_obj->(ld_attr) TO <ls_item>.

* Check Vendor is not initial

       IF <ls_item>-lifnr IS NOT INITIAL .

         lv_lifnr = <ls_item>-lifnr.


         <ls_item>-lifnr = lv_lifnr  .


* Update line item with Vendor

       ld_attr = 'MY_STATE->ITEMX'.

       ASSIGN lo_obj->(ld_attr) TO <ls_itemx>.


     lv_procss = 'X'.

     EXPORT lv_procss FROM lv_procss TO MEMORY ID 'ZPROCSSED'.



Jitendra Nayak

0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question