Application Development and Automation 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: 
Read only

Abap program to end specific User's Program, by sesion/tcode or GUIID

ben09
Explorer
0 Likes
2,261

Hello everyone, I've seen this posted quite  few times, posted here but it does not seem to work properly for me, and wanted to know what I was doing wrong.

So what I want to do is end a specific users program/session which they have started, it would be great if I could end it by GUI-id but I havnt been able to find any info on doing that. But atleast to be able to do it by session & tcode, this would have to be done via the background, with no user interaction.

What I've tried is to get the info on users by
CALL FUNCTION 'TH_USER_LIST'
  TABLES
    list lt_UINFO
    USRLIST lt_USRINFO
  EXCEPTIONS
    others   1.
 

and then kill the session by
CALL FUNCTION 'TH_DELETE_USER'
  EXPORTING
    client sy-mandt  " Current client
    user   =  ls_usrinfo-bname   " Username of the session
    tid    =  ls_usrinfo-tid    " Session ID (TID) to end
  EXCEPTIONS
    OTHERS 1.

as I've seen other people on here say it worked for them, but this ends the users entire session, all their current transaction and not just a specific program or tcode and thus wont work for me.

Does anybody know of a good way to end a users specific transaction/program or guiid?

6 REPLIES 6
Read only

RaymondGiuseppi
Active Contributor
2,231

Could you try:

(NB: Use Include TSKHINCL for constants)

Loop on result of TH_USER_LIST' and list of nodes for each user

  CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_mode_count
    ID 'TID' FIELD tid
    ID 'MODES' FIELD modes. " table of type modus

Delete one node with

  CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_delete_mode
    ID 'TID' FIELD tid 
    ID 'MODES' FIELD modus-modus. 

 

Read only

0 Likes
2,220

Thank you, but what data value should I define the OPCODE id's with? to my knowledge they are al defined with some number e.g: DATAopcode_get_mode_list TYPE VALUE 'INT'.

Read only

2,219

😎Look at the already provided include TSKHINCL 

Read only

0 Likes
2,126

ohh apologies, my reading comprehension is worse than I thought.

Read only

0 Likes
2,103

A cup of coffee and you're back on track 😎

Read only

0 Likes
2,063

Thank you for the assistance, that worked 🙂

Just out of curiosity do you know a way to end a users program in fashion similar to LEAVE PROGRAM, as in a service that listens to a request of closing a program and returning the user to their previous "page".