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: 

how to get the information of the users type of logon (type of session)

Former Member
0 Kudos

Hello,

we have created a user within transaction SU01. The user has user type "DIALOG".

We use this user to logon to the system using SAP-GUI (->type of logon = GUI ) and by RFC (->type of logon=RFC).

You can see the type of logon in transaction SM04.

Now we are looking for a way to find out within an ABAP if the user is logged on via GUI or via RFC.

We can not use the information of transaction SM04 because the user maybe is working at the same time as GUI and RFC.

We need the information about the actual session. So we can use sy-uname, sy-mandt,... but there is no field in table SYST which we can use to get the type of logon.

Does anybody know a way to get this information during the active session?

Thanks

Arnfried

4 REPLIES 4

Former Member
0 Kudos

Hi,

After trace of SM04,

You could chech this prg RSM04000_ALV line 1600:

For example:

DATA: BEGIN OF usr_tabl OCCURS 10.
        INCLUDE STRUCTURE uinfo.
DATA: END OF usr_tabl.

DATA: th_opcode(1)                    TYPE x.

CONSTANTS: opcode_list                     LIKE th_opcode VALUE 2.

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_list
  ID 'TAB' FIELD usr_tabl-*sys*.

IF sy-subrc = 0.
*  CASE usr_tabl_alv-type.
*    WHEN 2.   usr_tabl_alv-ext_type = text-052." (system)
*    WHEN 4.   usr_tabl_alv-ext_type = text-035." (Gui)
*    WHEN 32.  usr_tabl_alv-ext_type = text-036."(RFC)
*    WHEN 202. usr_tabl_alv-ext_type = text-039." (Plug-in &).
ENDIF.

Brgds

Julien

0 Kudos

Thanks for the information.

But if I do this I get a list with all users logged on to the system.

So if my user is logged on twise mybe with RFC and GUI I have the problem to detect with is my actual session user.

With sy-uname and sy-mandt I get informations about the session user. When I now read the table USR_TABL-SYS with this informations I will find for example to entries. One for GUI and one for RFC. But which is the entry that belongs to the actual session ?

Arnfried

0 Kudos

Try this:

Call function TH_USER_INFO to obtain values MY_SESSION and TID for the currently active session.

With this TID, you can then call TH_SHOW_USR_DETAILS to fill table TECH_INFO. This is a deep structure, and in field "rollinfo[n].rollout_reason" you will find "RFC" or "GUI" (or whatever). [n] is the value in MY_SESSION minus 1.

Thomas

P.S. I obviously never tried this myself. Please let me know if it works.

0 Kudos

Thanks all for the help.

Here is my solution. A mix from Julian and Thomas.

In future I will encapsulate the code in a function module.

DATA: BEGIN OF usr_tabl OCCURS 10.

INCLUDE STRUCTURE uinfo.

DATA: END OF usr_tabl.

DATA: th_opcode(1) TYPE x.

DATA: LV_TID LIKE SY-INDEX.

CONSTANTS: opcode_list LIKE th_opcode VALUE 2.

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_list

ID 'TAB' FIELD usr_tabl-sys.

CALL FUNCTION 'TH_USER_INFO'

EXPORTING

CLIENT = sy-mandt

USER = sy-uname

IMPORTING

TID = LV_TID.

read table usr_tabl with key tid = lv_tid.

IF sy-subrc = 0.

CASE usr_tabl-type.

WHEN 2.

write 😕 usr_tabl-type, 'SYSTEM'." (system)

WHEN 4.

write 😕 usr_tabl-type, 'GUI'." (Gui)

WHEN 32.

write 😕 usr_tabl-type, 'RFC'."(RFC)

WHEN 202.

write 😕 usr_tabl-type, 'PLUG-IN'." (Plug-in &).

endcase.

ENDIF.