Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in ME21N BADI method

former_member823006
Participant
0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

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.

0 Kudos

Thanks Prabhu,

I have to place this INVALIDATE( ) method after the error message and into the IF condition, right?

0 Kudos

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