Skip to Content

BAdI Implementation for the validation of ‘recipient’ field in PR, PO and Reservation.

                                                                                                                                                          By Jaheer M. Ismail

  In order to check whether user enterscorrect SAP user id in the recipient of purchase Requisition  , purchase order and reservation you can use the following BAdI implementation with below given method. If user does not enter any valid SAP user id and not entered anything in this field then when you try to ‘save’ your purchase Requisition, purchase order and reservation you will get error message.

  In the PR,you can find Recipient field in account assignment Tab.

In the PO, you can find Recipient field in account assignment Tab.

  In the reservation, you can find Recipient field as below


BAdI Name and its method to validate recipient with PR, PO and Reservation:



PROCESS_ITEM      (method)



PROCESS_ITEM      (method)



DATA_CHECK          (method)

Transaction code for BAdI implementation is SE18



Logic to validate recipient Field:

Where to write piece of code for validation: Abaper will write code in each method.

Your abaper will write code for the validation of‘ user entered SAP use id’  with table field USR21-BNAME.If user enter
invalid SAP user id, then you get error message like this when you save PR,PO and reservation.

Error Message: Provided Recipient doesn’t match with SAP User ID for item &.

This way you can validate your recipient  field in PR, PO and reservation and functional consultant can use this document to write functional specification.


Coding part:For PO.

  Here I created one z table( zpo_plant) for putting my plant.This should validate only for certain plants not all plants.


method if_ex_me_process_po_cust~process_item.

  include mm_messages_mac . “useful macros for message handling

  break adhummansure.

  data: ls_mepoitem type mepoitem,

        ls_purchase_order_accountings type purchase_order_accountings,

        wa type purchase_order_accounting,

        ls_acc_ref type ref to if_purchase_order_account_mm,

        ls_accounting type mepoaccounting.

  data: lv_bname type usr21-bname,

        lv_werks type zpo_plant-werks.

  ls_mepoitem = im_item->get_data( ).

  if ls_mepoitem-knttp = ‘K’ or ls_mepoitem-knttp = ‘A’ or ls_mepoitem-knttp = ‘F’

      or ls_mepoitem-knttp = ‘Q’ or ls_mepoitem-knttp = ‘P’.

    select single werks from zpo_plant into lv_werks where werks = ls_mepoitem-werks.

    if sy-subrc = 0.

      ls_purchase_order_accountings = im_item->get_accountings( ).

      loop  at ls_purchase_order_accountings into wa.

        ls_acc_ref = wa-accounting.

        ls_accounting = ls_acc_ref->get_data( ).

        if ls_accounting-wempf is initial.

          message e024(zmm) with ls_accounting-ebelp.


          translate ls_accounting-wempf to upper case.

          select single bname from usr21 into lv_bname where bname = ls_accounting-wempf.

          if sy-subrc ne 0.

            message e023(zmm) with ls_accounting-ebelp.







To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Dibyendu Patra

    Well, as you are exploring your experience, then you should give the piece of code also along with result.

    At present, you document looks like “this field can be checked by using these BADIs”

    As it is work of both functional and technical person, so you should give the illustration from both side (technical and functional). 🙂

    1. Jaheer Hussain Post author

      Dib,Thank you for youe comments. 🙂

      This forum is for MM function side ,that is why I did not put abap coding.If some body needs I can send it to them.

      1. Dibyendu Patra

        As I have explained it’s a work of both technical and functional person and as you are sharing a document with regards to some requirement, so you should share this part also. And why if someone needs, of-course if someone try to test the same, he needs the coding part also.

        P.S. you may can check my last blog post Account determination for GR/IR clearing account (WRX) as per Purchase order document type, where I explained same kind of enhancement by using a exit. I also said that, the coding part will be done by the ABAPer, but I have also given the piece part so code, so that any one can test the same with this code.


Leave a Reply