12-09-2011 5:27 AM
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
12-09-2011 5: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.
12-09-2011 5:43 AM
Thanks Prabhu,
I have to place this INVALIDATE( ) method after the error message and into the IF condition, right?
12-09-2011 5:51 AM
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