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.
Showing results for 
Search instead for 
Did you mean: 

log off from ABAP Program

Former Member
0 Kudos

I Wonder whether it is possible to write an abap program

which fulfills following requirement.

just like the tcode which is used to log off /nex.

but it closes all sap windows without warning on the same server.

what i want,

i want to write a progam and then create a tcode for that say zex.

on entering that tcode the system close all sap window on the same server except one.


say i have opened 4 sessions of prd server. and i want to close 3 of them.

then i execute custom tcode say zex. and out of 4 --3 sessions will be closed.

no of sessions to be closed  = total no of open sessions - 1.

dont know whether it is possible>

ur suugesstions wanted.

there are FM present.


call 'syst_logoff'.

but none of them suits to my requirement.,


Former Member
0 Kudos

is there no one to reply

Active Contributor
0 Kudos

Hi Abhishek,

Well in that case the requirement isnt to logoff but to close all the open sessions except one. But how are you going to decide which session has to be open ?

I would suggest to check FM's for closing a session or debug close session to identify how SAP does it.


Best regards,


0 Kudos

The session which will remain open will be that opened at the begning.

say it other way:

at any open session at bottom right corner there displayed:

server name (session No ) client.

eg: dev(1)700.

only session 1 will remain open and all other will be closed.

i tried to debug.

first /h in command box.

and then tcode /nex. but it does not goes in debugging mode rather it exits sap.

0 Kudos

Hi Abhishek,

You need to switch on System Debugging.


Best regards,


0 Kudos

<< Content Removed >> i first switch on system debugging and then entered tcode /nex. but that is what i am saying instead on entering into debugging mode it directly exits.

all sap sessions closed!

<< Moderator Message : Speak professionally in the forums >>

Message was edited by: Kesavadas Thekkillath

Active Contributor
0 Kudos

Get list of modes  and delete specific modes are not easy, you will mostly require use of "forbidden" call system command like ThUsrInfo.

What if you want to try ?

Look at include TSKHINCL for opcode values, perform some where-used on those constants, if unlucky you find SAP report using the system calls, if you are lucky the call is executed in a useful function module (name starting with TH_)

The result could look like following samples,  informative only, neither tested nor intended to be tested...

DATA: tid TYPE utid,

      modes TYPE sy-index,

      mode_list type table of modus with HEADER LINE,

      modus type modus.

* Current session id (Look at TH_USER_INFO)

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_usr_attr

  ID 'TID' FIELD tid. " Id of current session

* Number of modes (Look at form modus_liste of RSM04000_ALV)

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_mode_count

  ID 'TID' FIELD tid

  ID 'MODES' FIELD modes. " number of modes

CHECK modes GT 1.

* List of modes with transaction (Look at TH_SELECT_MODE)

*CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_get_mode_list

*    ID 'TID' FIELD tid

*    ID 'MODE_LIST' FIELD  mode_list. " mode list

* Delete a Mode (Look at TH_DELETE_MODE)

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_delete_mode

     ID 'MODE' FIELD mode.

Try in a sandbox...



PS: /nex is not an actual transaction, trying to enter in debug mode (even system) in what is probably a C program gives little chance of success...

Former Member
0 Kudos


Did you have a look @ FM TH_DELETE_USER. Unfortunately I could not confirm it on my system because of 'Authority' issue.


Raju chitale