Skip to Content
0
Dec 09, 2011 at 05:27 AM

Problem in ME21N BADI method

186 Views

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