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:

PR

ME_PROCESS_REQ_CUST

PROCESS_ITEM      (method)

PO

ME_PROCESS_PO_CUST

PROCESS_ITEM      (method)

Reservation

MB_RESERVATION_BADI

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.


        else.


          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.


          endif.


        endif.


      endloop.


    endif.


  endif.


endmethod.

New NetWeaver Information at SAP.com

Very Helpfull

User Rating: Be the first one !