Skip to Content
Author's profile photo Mohamed Ismail

BAdI (MM-PM): Direct PR creation restriction against the Work Order (WO) with order category ‘30’ (Maintenance order )’.



    Recently I have implemented BAdI(ME_PROCESS_REQ_CUST) for ‘Direct purchase Requisition   creation Restriction against the Work Order(WO) with order category ‘30’ (Maintenance order )’.

   If user tries to create PR (Me51n) with Accountassignment Category ‘F’ with WO which has order category ‘30’ (Maintenance Order = ‘30’) then system will throw error message.

The Error message is  Sorry you cannot create direct PR with order category 30(mainta.Order).

How to do this?

You can use transaction SE18 to implement it.

  1. Go to transaction SE18.



2. Press ‘Display’.


3. From the menu Implementation->Create


4. Give your implementation name as below (starts with
Z…). Here I have given as zme_process_Req_cust



5. Then give implementation short text as you like.


6. Then click ‘Interface’  tab and select method ‘PROCESS_ ITEM’ (BY DOUBLE CLICKING).



7. In this method,please add the following coding.

method if_ex_me_process_req_cust~process_item.


include mm_messages_mac . “useful macros for message handling


data:   it_items_ref             type  mmpur_requisition_items,


        wa_items_ref             type  mmpur_requisition_item,


        ls_item_ref              type  ref to if_purchase_requisition_item,

        ls_item                  type  mereq_item,


        ls_acc_ref               type  ref to if_accounting_model_mm,


        wa                       type  mmpur_accounting_type,


        ls_accounting            type  exkn,


        ls_mmpur_accounting_list type  mmpur_accounting_list,


        ls_mereq_header          type  ref to if_purchase_requisition.

  data: lv_aufnr type aufk-aufnr.

ls_mereq_header   =   im_item->get_requisition( ).

it_items_ref      =   ls_mereq_header->get_items( ).


loop at it_items_ref into wa_items_ref.

         ls_item_ref   = wa_items_ref-item.

         ls_item       = ls_item_ref->get_data( ).

   if ls_item-knttp = ‘F’ and ls_item-estkz = ‘R’.

   ls_mmpur_accounting_list = ls_item_ref->if_acct_container_mm~get_items( ).

loop at ls_mmpur_accounting_list into wa .

           ls_acc_ref    = wa-model.

                  ls_accounting = ls_acc_ref->get_exkn( ).

       select single aufnr  from aufk into lv_aufnr  where aufnr = ls_accounting-aufnr and autyp = ’30’.

           if sy-subrc eq 0.


          message e026(zq) with ls_item-bnfpo.








8. Finally ‘SAVE’ and ‘ACTIVATE’.



How to create error message?


Here in the above coding, my error message is E026 with message class ZQ.You can use transction code SE91, you can createyour own message.




9. Now try to create PR(me51n) with Account assignment category ‘F’ with WO (WO has order
category =’30’(Maintenance order),then you will get error message
Sorry   you cannot create direct PR with order category 30(mainta.Order). So , you cannot complete your PR..


I welcome your  suggestion, please. Thank you.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Mehmet Ozgur Unal
      Mehmet Ozgur Unal

      Well explained document , keep it up !


      M.Ozgur Unal

      Author's profile photo Mohamed Ismail
      Mohamed Ismail
      Blog Post Author

      Thank you Ozgur.