Skip to Content

Problem in ME21N BADI method

Hi Experts,

In my earlier thread, I asked which method to choose for ME_PROCESS_PO_CUST for ME21N Tcode.

I got my answer as "CHECK" method, and I closed that thread.

Now when I am writing a code there in CHECK method and activate it and going to create purchase order, I am not able to block save data.

My query is to how I can make a check in SAVE button, when user left "PLANT or TINNO" fields blank, so that it will not be able to save the data to generate PO number.

I am writing a code as :

DATA : ls_mepoheader TYPE REF TO if_purchase_order_mm.
  DATA : l_header TYPE mepoheader.

  INCLUDE mm_messages_mac. "useful macros for message handling

  l_header = ls_mepoheader->get_data( ).

  IF SY-UCOMM EQ 'MESAVE' OR SY-UCOMM EQ 'MECHECKDOC'.
      IF l_header-plant EQ ' ' OR l_header-tinno EQ ' '.
        mmpur_message_forced 'E' 'ZMSG' '012' '' '' '' ''.
      ENDIF.
  ENDIF.

Now when I am creating a PO from ME21N, it is showing an erorr message that i have given, but when click on SAVE button, it is saving the data and generate PO number.

So I am confused which method to choose... so that it will not let save data.

and also Please check the code i have given.

Thanks,

Deepanshu

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 09, 2011 at 05:32 AM

    Hi ,

    you need call method INVALIDATE to stop users from saving ...check BADI-->sample/default codes to get some idea ...or read its documentation

    
    
    DATA : ls_mepoheader TYPE REF TO if_purchase_order_mm.
      DATA : l_header TYPE mepoheader.
     
      INCLUDE mm_messages_mac. "useful macros for message handling
     
      l_header = ls_mepoheader->get_data( ).
     
      IF SY-UCOMM EQ 'MESAVE' OR SY-UCOMM EQ 'MECHECKDOC'.
          IF l_header-plant EQ ' ' OR l_header-tinno EQ ' '.
            ls_mepoheader->INVALIDATE()."Call this method.....  
           mmpur_message_forced 'E' 'ZMSG' '012' '' '' '' ''.
          ENDIF.
      ENDIF.
    

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Deepanshu Mathur

      Hi ,

      yeah , but not sure abt your codings ....bcos you are using sy-ucomm.....its better to remove those conditions ...

      this check method will be active only when user click on CHECK button or SAVE Button....

      regards

      Prabhu

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.