Skip to Content
Author's profile photo Mohamed Ismail

Badi:Not allowing creating PO(specific document type) without PR

JAHEER HUSSAIN,CRISTAL.

______________________________________________________________________________________________________________________________
Hi,

Objective:

    Recently I have implemeted Badi(ME_PROCESS_PO_CUST)  for ‘Not allowing create PO(with dcoument type NBPJ and CRPJ) without PR.

If user tries to create PO(PO document type PJCR or NBPJ) with out PR,then system will throw error message.The Error message is “There is NO Purchase Requisition for this PO !”.

How to do this?

You can use transaction SE18 to Implement it.

1.Go to transaction SE18.

/wp-content/uploads/2015/06/1_727289.jpg

2.Press ‘Display’.

3.From the menu Implementation->Create

/wp-content/uploads/2015/06/1_727289.jpg

4.Give your implemenation name as below(starts with Z..) Here I have given as  zme_process_po_cust.

/wp-content/uploads/2015/06/1_727289.jpg

5.Then give implementation  short text as you like.

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

/wp-content/uploads/2015/06/1_727289.jpg

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

method if_ex_me_process_po_cust~process_item.


  include mm_messages_mac . “useful macros for message handling


  CALL FUNCTION ‘MEPO_DOC_HEADER_GET’


    IMPORTING


      EX_EKKO = LS_MEPOHEADER.

  IF ( LS_MEPOHEADER-BSART = ‘NBPJ’ OR LS_MEPOHEADER-BSART = ‘PJCR’ ) .  “here I am checking my document type

    CALL METHOD IM_ITEM->GET_DATA


      RECEIVING


        RE_DATA = LS_MEPOITEM.

    IF LS_MEPOITEM-BANFN IS INITIAL.


     MESSAGE E025(ZQ).

   

    ENDIF.

  ENDIF.

endmethod.

————————————————————————–

How to create error message?

Here my error message  is E025 with message class ZQ.You can use transction code SE91,you can create your own message.

/wp-content/uploads/2015/06/1_727289.jpg

8.Finally ‘SAVE’ and  ‘ACTIVATE’.

9.Now try to create PO with your own PO document type without PR,then you will get error message and without rcreating PR,you can not complete your PO..However you can ‘HOLD’ your PO.

I welcome your suggestion,please.Thank you.

Assigned tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Dangerous code, the documentation says use method invalidate for error mmessages. Please correct your code.

      Author's profile photo Jaheer Hussain
      Jaheer Hussain
      Blog Post Author

      what dangerous code? Can you check sample code of Process_item? Here you can find error syntax for message.

      Author's profile photo Jürgen L
      Jürgen L

      Your code only works because it is an error message, it would not work if  you issue warnings.In any case it is not the supposed to deal with messages in this BADI.

      see KBA 1709562 - Messages ignored in BAdIs ME_PROCESS_REQ_CUST and ME_PROCESS_PO_CUST

      Author's profile photo Jaheer Hussain
      Jaheer Hussain
      Blog Post Author

      Thank you Jurgen.That is correct.

      • "The same source code works for an error message (E) but does not work for W, S or I messages ".

      However I need to restrict creating PO,so I need only Error message for my nrequirement.It does not mean that it is dangerous code.