10-28-2010 8:46 PM
i would like to logoff the sap. my requirement is: need to check whether the user is valid or not. if user is not valid, sap should come out from login.
how can i write code for this.
10-28-2010 9:24 PM
Sounds like you're talking about the standard SAP login screen.
Please provide more technical details on what you want and why.
Thomas
10-29-2010 12:35 AM
my requirement, there are some specific user ids, which are maintained in ztable. when that user id logs into sap it should be validated the ztable. if user id is invalid show a popup message then it should be logged off.
i found the user exit where i need to write, but i need code to log off the screen after checking validation.
10-29-2010 1:41 AM
Hi,
Check table usr04. There is a date field. You can compare to current date to see if the user is valid.
Best regards,
Caíque Escaler
10-29-2010 2:12 AM
Hi Chander,
Why you want to maintain the invalid user ids in a separate Z-Table? If you change the Validity end date of those user-ids to somewhere in the past SAP will automatically not allow then to log in.
Regards,
Immanuel.
10-29-2010 2:44 AM
my question is not how to validate the user id. I need the code, how to logoff the screen through code.
10-29-2010 2:50 AM
Oh... Sorry that I "misunderstood" your requirement. Wish you good luck,
Regards,
Immanuel.
10-29-2010 3:09 AM
This is a very strange request? How do you define a user as non valid? SAP has all the controls in place to allow you to set up time frames up etc...on users.
But, just to point you in the right direction there is a user exit that is executed at the time of logon that you could use to validate the user. If the user is not valid then you can simply exit which will terminate the logon process.
User exit is SUSR0001. Strictly speaking this is not it's purpose but it can be used.
Cheers,
Neil.
10-29-2010 3:26 AM
Yes You are true neil.
I am using same user exit.
but when i am using 'EXIT', it not going to log off. instead of that it is going to sap initial screen.
i want the code to log off if the user is invalid.
10-29-2010 3:37 AM
Good point. Just chuck an error message. This will stop the logon and give the user an error message.
10-29-2010 3:39 AM
Neil,
there are some emergency Userids to login. my clients wants to maintain them into one Z table to validate
I the entered id is not a emergency User ID, i want to show an error message then logoff the SAP. I am using the User exit for validation. till here it is good.
if the user is not in the specified z table, i want to logoff the SAP. here i required the condition which i am looking to write.
10-29-2010 3:47 AM
Simple mate:
select single uname from <ZTABLE>
where uname eq sy-uname.
if sy-subrc = 4.
message E###.
endif.
10-29-2010 4:21 AM
yes you are true. when i execute first time with error message, it is coming out. but when i am logging agin. it is not working.
there is the problem .
do you have any function module like like to displaying a popup screen when you use /nend
10-29-2010 6:13 AM
10-29-2010 5:25 PM
What about the MESSAGE Exxx suggested earlier, then a variant of your /nend. You may use a transaction code of your choice (or create a dummy one).
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
CLEAR BDCDATA.
BDCDATA-PROGRAM = 'SAPMS38M'.
BDCDATA-DYNPRO = '101'.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '/nex'.
APPEND BDCDATA.
call transaction 'SA38' using bdcdata mode 'N'.
10-29-2010 6:42 PM
10-29-2010 6:48 PM
Yeah but SA38 is a dangerous transaction. Not everyone will have the authorization to use it. In particular, users being logged off automatically are unlikely to have it.
Rob
10-29-2010 7:12 PM
More importantly, look at the comments at the top of the include for the user exit:
Please don't implement
- a logoff of the user
- an error message
- too many popups
Rob
Edited by: Rob Burbank on Oct 29, 2010 2:12 PM
10-29-2010 9:11 PM
Ron,
it is working fine for me. i have implemented the same logic which i expected.
do you any alternative? because most of the user may not have access for SA38. then it may be problem.
10-30-2010 7:49 AM
I still don't see why you don't simply lock the users that you don't want to log on. You could even write a program that uses the appropriate BADI to lock/unlock users according to your Z table. Perhaps running on a daily basis, or immediately after editing the Z table, using table maintenance events.
11-01-2010 11:52 AM
I used a sample transaction to show proof of concept. I suggested that an alternate or dummy transaction be created for this purpose should you decide to use this technique for your requirements.
Rob and Matt's more standard SAP suggestions/alternatives should also be seriously considered.