Skip to Content
avatar image
Former Member

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.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 14, 2015 at 07:11 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 10, 2015 at 02:10 PM

    Hi  Jitendra


    You can use the CHECK Method , use the parameter 'IM_HEADER' whose Type is IF_PURCHASE_REQUISITION.

    The interface IF_PURCHASE_REQUISITION has a method called 'GET_ITEMS', Method get_items will return all the items of PR. ( IF_PURCHASE_REQUISITION_ITEM->get_item will return every single item)


    Qingda Niu

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Just like what Atul Mohanty said,

      use method process_item, and create a global variable of the implementing class, and use methodss: set_data and set_datax.

      P.S. you should use the parameter IM_TRTYP of method 'OPEN' also, if you want to achieve your requirement only when creatint a PR. The value doiman of im_trtyp, you will find it in the relevant domain.


  • Jan 10, 2015 at 09:54 AM

    Hi Jitendra,

    I found that you are not able to find the item internal table name inside Exit. Get the Internal table and Program name for Item. Using Field symbol concept, access the value inside Exit as shown below.

    "Data Declarations
        FIELD-SYMBOLS: <tblgart>        TYPE ANY TABLE,
                       <wa_tblgart>     TYPE ANY,
                       <fs_value_lgart> TYPE ANY,
                       <fs_value_betrg> TYPE ANY.

        DATA: obj_tblTYPE REF TO data.

    "Assign Program and Internal Table as shown below

        ASSIGN ('(MP000800)TBLGART[]') TO <tblgart>.
        CREATE DATA obj_tbl LIKE LINE OF <tblgart>.
        ASSIGN obj_tbl->* TO <wa_tblgart>.

        "Check Table have initialized
        IF <tblgart> IS ASSIGNED.
          LOOP AT <tblgart> ASSIGNING <wa_tblgart>.
            ASSIGN COMPONENT 'LGART' OF STRUCTURE <wa_tblgart> TO <fs_value_lgart>.

            "Check Wage type is initialized
            IF <fs_value_lgart> IS ASSIGNED.

              "Check Transport/Conveyance Allowance
              IF <fs_value_lgart> = '1002'.

              "Write the Logic Here    




    Rajkumar Narasimman

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Jitendra,

      The above code is common one, find internal table name and variable and change for your program. Place the breakpoint in the following Exit, hope it will trigger.

      • EXIT_SAPLMEREQ_001
      • EXIT_SAPLMEREQ_002
      • EXIT_SAPLMEREQ_003


      Rajkumar Narasimman

  • avatar image
    Former Member
    Jan 12, 2015 at 07:07 AM

    This message was moderated.

    Add comment
    10|10000 characters needed characters exceeded