2008 Mar 06 7:30 AM
Dear all,
i have a very tricky requirement
i want to restrict ME22N transaction to certain users according to particular document type.
Now i have found out BADI ME_PROCESS_PO_CUST and have written code according to requirement which is working fine and the system is throwing error message as required. Then after clicking on error message when user presses the BACK button ,it is showing a popup "
do u want to save the document"
here if the user clicks on "YES"
than its allowing changes which shouldnt be the case can u plz help me out as to what should be done so that after the first error mesage
the popup for "do u want to Save" shouldnt com or it shouldnt allow to change the document
my code is as below
method IF_EX_ME_PROCESS_PO_CUST~CLOSE.
IF SY-TCODE = 'ME22N'.
DATA: IT_MEPOHEADER TYPE MEPOHEADER.
IT_MEPOHEADER = IM_HEADER->GET_DATA( ).
IF SY-SUBRC = 0.
IF SY-UNAME = 'ABAP05' OR SY-UNAME = 'FUNC57' .
IF SY-UCOMM = 'MECHECKDOC' OR SY-UCOMM = 'MESAVE' .
MESSAGE e000(0) WITH 'you are not authorized to use ME22N for the given document type'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
endmethod.
here sy-ucomm MECHECKDOC is for checking
and MESAVE' is for saving
2008 Mar 06 9:48 AM
Hi All,
I have done the same object.
In ME_PROCESS_PO_CUST, there is a method PROCESS_HEADER.
In that u have used GET DATA. method.
If u do not want the changes depending on the conditions, U have to set back the old values.
For that purpose, u have to use GET PREVIOUS DATA method to hold the old values (before changes)
Then depending on the condition, if u do not want changes, U can set back those changes using the SET DATA method.
In SET DATA method, u can use the values of GET PREVIOUS DATA.
I hope u can do this.
If u need code help, contact me on mnpss@yahoo.com
Reward if useful
Narendra
2008 Mar 06 7:34 AM
method IF_EX_ME_PROCESS_PO_CUST~CLOSE.
IF SY-TCODE = 'ME22N'.
DATA: IT_MEPOHEADER TYPE MEPOHEADER.
IT_MEPOHEADER = IM_HEADER->GET_DATA( ).
IF SY-SUBRC = 0.
IF SY-UNAME = 'ABAP05' OR SY-UNAME = 'FUNC57' .
IF SY-UCOMM = 'MECHECKDOC' OR SY-UCOMM = 'MESAVE' .
Leave to transaction 'ME22N'.
MESSAGE e000(0) WITH 'you are not authorized to use ME22N for the given document type'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
endmethod.
try using leave to transaction stmt b4 or after message and see if dis works...
2008 Mar 06 7:37 AM
also if u give message stmt like:
Message 'you are not authorized to use ME22N for the given document type' type 'E'.
the transaction will terminate but if u provide message as u had mentioned with message class, this kind of abnormal behavior is encountered which u mentioned..
plz reward points if dis helps
2008 Mar 06 7:41 AM
Thanks for ur reply
but still it is not working as after all the code written finally while leaving the transaction the popup comes and it allows all the changed code to be saved i had also previously tried using leave , set screen keyword but of no use.
anyway thanks once again
2008 Mar 06 7:49 AM
hi,
try to add info message if possible as aftererror message control wont move further
IF SY-UCOMM = 'MECHECKDOC' OR SY-UCOMM = 'MESAVE' .
MESSAGE i000(0) WITH 'you are not authorized to use ME22N for the given document type'.
exit.
ENDIF.
revert back
regards,
naveen
2008 Mar 06 7:56 AM
Thanks for ur reply
Even exit doesnot work
the thing that is happning is system is asking popup irrespective of the code at the final stage and here if clicked on yes the unwanted data gets saved.
2008 Mar 06 8:05 AM
hi,,,
try this way..
IF SY-UCOMM = 'MECHECKDOC' OR SY-UCOMM = 'MESAVE' .
MESSAGE i000(0) WITH 'you are not authorized to use ME22N for the given document type'.
leave transaction.
ENDIF
revert back...
regards,
naveen
2008 Mar 06 8:07 AM
2008 Mar 06 8:48 AM
Thanks once again
neither does suppress dialog or leave transaction work
i dont know how to prevent that final popup to appear as irrespective of the code the final popup comes and every validation goes into mess.
2008 Mar 06 8:59 AM
2008 Mar 06 9:48 AM
Hi All,
I have done the same object.
In ME_PROCESS_PO_CUST, there is a method PROCESS_HEADER.
In that u have used GET DATA. method.
If u do not want the changes depending on the conditions, U have to set back the old values.
For that purpose, u have to use GET PREVIOUS DATA method to hold the old values (before changes)
Then depending on the condition, if u do not want changes, U can set back those changes using the SET DATA method.
In SET DATA method, u can use the values of GET PREVIOUS DATA.
I hope u can do this.
If u need code help, contact me on mnpss@yahoo.com
Reward if useful
Narendra
2008 Mar 06 11:02 AM
Thank u all,
mypurpose has finally been solved here is the code for the same
method IF_EX_ME_PROCESS_PO_CUST~CHECK.
IF SY-TCODE = 'ME22N'.
DATA: IT_MEPOHEADER TYPE MEPOHEADER.
IT_MEPOHEADER = IM_HEADER->GET_DATA( ).
IF SY-SUBRC = 0.
IF SY-UNAME = 'ABAP05' OR SY-UNAME = 'FUNC57' .
Message 'you are not authorized to use ME22N for the given document type' type 'E'.
ENDIF.
ENDIF.
ENDIF.
endmethod.
here previously i used sy-ucomm as a filter which was preventing as sy-ucomm was getting changed to "YES"
after clicking on th popup and the check was not working.
Thanks to all.