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: 

logoff the sap screen

0 Kudos

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.

20 REPLIES 20

ThomasZloch
Active Contributor
0 Kudos

Sounds like you're talking about the standard SAP login screen.

Please provide more technical details on what you want and why.

Thomas

0 Kudos

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.

0 Kudos

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

0 Kudos

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.

0 Kudos

my question is not how to validate the user id. I need the code, how to logoff the screen through code.

0 Kudos

Oh... Sorry that I "misunderstood" your requirement. Wish you good luck,

Regards,

Immanuel.

former_member186750
Contributor
0 Kudos

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.

0 Kudos

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.

0 Kudos

Good point. Just chuck an error message. This will stop the logon and give the user an error message.

0 Kudos

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.

0 Kudos

Simple mate:

select single uname from <ZTABLE> 
               where uname eq sy-uname. 

          if sy-subrc  = 4.
            message E###. 
          endif. 

0 Kudos

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

0 Kudos

that sounds rather strange. Can you post your code here please?

MrWhan
Participant
0 Kudos

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'.

0 Kudos

Thanks Ron,

This code really Helpful. it is working as expected.

0 Kudos

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

0 Kudos

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

0 Kudos

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.

0 Kudos

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.

0 Kudos

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.