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

THUSRINFO Function Module usage

Former Member
0 Likes
2,540

Hi

Anyone has ever used function module THUSRINFO , Any idea how it can replace the C function thusrinfo which was present in SAP 4.5B version?

Ankur

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,526
*&---------------------------------------------------------------------*
*& Report  Z_GET_SERVER                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT z_get_server NO STANDARD PAGE HEADING LINE-SIZE 80.

DATA: usr_tabl TYPE STANDARD TABLE OF uinfo    WITH HEADER LINE,
      srvr_lst TYPE STANDARD TABLE OF msxxlist WITH HEADER LINE,
      found.

PARAMETERS: bname LIKE uinfo-bname.

CALL FUNCTION 'TH_SERVER_LIST'
  TABLES
    list           = srvr_lst
  EXCEPTIONS
    no_server_list = 1
    OTHERS         = 2.

IF sy-subrc <> 0.
  EXIT.
ENDIF.

LOOP AT srvr_lst.
  CALL FUNCTION 'THUSRINFO'
    DESTINATION srvr_lst-name
    TABLES
      usr_tabl = usr_tabl.
  READ TABLE usr_tabl WITH KEY bname = bname.
  IF sy-subrc EQ 0.
    WRITE: / 'Server =',    srvr_lst-name(20),
             'Terminal = ', usr_tabl-term.
    found = 'X'.
  ENDIF.
ENDLOOP.

IF found IS INITIAL.
  MESSAGE i000(zrf) WITH 'User Not Found'.
ENDIF.
9 REPLIES 9
Read only

Former Member
0 Likes
1,526

Search the forum for this function module, you will get the information.

https://forums.sdn.sap.com/search!execute.jspa?forumID=50&forceEmptySearch=true&q=THUSRINFO&objID=f5...

Read only

Former Member
0 Likes
1,527
*&---------------------------------------------------------------------*
*& Report  Z_GET_SERVER                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT z_get_server NO STANDARD PAGE HEADING LINE-SIZE 80.

DATA: usr_tabl TYPE STANDARD TABLE OF uinfo    WITH HEADER LINE,
      srvr_lst TYPE STANDARD TABLE OF msxxlist WITH HEADER LINE,
      found.

PARAMETERS: bname LIKE uinfo-bname.

CALL FUNCTION 'TH_SERVER_LIST'
  TABLES
    list           = srvr_lst
  EXCEPTIONS
    no_server_list = 1
    OTHERS         = 2.

IF sy-subrc <> 0.
  EXIT.
ENDIF.

LOOP AT srvr_lst.
  CALL FUNCTION 'THUSRINFO'
    DESTINATION srvr_lst-name
    TABLES
      usr_tabl = usr_tabl.
  READ TABLE usr_tabl WITH KEY bname = bname.
  IF sy-subrc EQ 0.
    WRITE: / 'Server =',    srvr_lst-name(20),
             'Terminal = ', usr_tabl-term.
    found = 'X'.
  ENDIF.
ENDLOOP.

IF found IS INITIAL.
  MESSAGE i000(zrf) WITH 'User Not Found'.
ENDIF.
Read only

Former Member
0 Likes
1,526

Any idea , How I can replace it in this code which is picked from 4.5B.

-


REPORT zgan_show MESSAGE-ID zz.

TABLES: v_username,

sscrfields.

DATA: BEGIN OF usr_tabl OCCURS 10.

INCLUDE STRUCTURE uinfo.

DATA: END OF usr_tabl.

DATA: opcode TYPE x,

slave_mode TYPE x,

loc_utid LIKE usr_tabl-tid.

CONSTANTS: c_fcode_slon LIKE sy-ucomm VALUE 'SLON',

c_fcode_slof LIKE sy-ucomm VALUE 'SLOF'.

SELECTION-SCREEN BEGIN OF BLOCK userid WITH FRAME.

PARAMETERS: p_userid LIKE uinfo-bname.

SELECTION-SCREEN END OF BLOCK userid.

SELECTION-SCREEN BEGIN OF BLOCK show WITH FRAME.

SELECTION-SCREEN PUSHBUTTON /10(25) slon USER-COMMAND slon.

SELECTION-SCREEN PUSHBUTTON 45(25) slof USER-COMMAND slof.

SELECTION-SCREEN END OF BLOCK show.

INITIALIZATION.

MOVE 'On Screen Flow Show' TO slon.

MOVE 'Off Screen Flow Show' TO slof.

AT SELECTION-SCREEN ON p_userid.

IF NOT p_userid IS INITIAL.

SELECT SINGLE bname

INTO v_username-bname

FROM v_username

WHERE bname = p_userid.

IF sy-subrc <> 0.

MESSAGE e999 WITH 'User not logged on'.

ENDIF.

ELSE.

MESSAGE e999 WITH 'Specify the User Id'.

ENDIF.

AT SELECTION-SCREEN.

FREE usr_tabl.

opcode = 2.

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode ID 'TAB' FIELD

usr_tabl-sys.

READ TABLE usr_tabl WITH KEY bname = p_userid TRANSPORTING tid.

IF sy-subrc <> 0.

MESSAGE e999 WITH 'Requested User Id is not available'.

ENDIF.

loc_utid = usr_tabl-tid.

slave_mode = 5.

IF sscrfields-ucomm = c_fcode_slon.

opcode = 14.

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode ID 'S_TID' FIELD loc_utid

ID 'S_MODE' FIELD slave_mode.

ELSEIF sscrfields-ucomm = c_fcode_slof.

opcode = 15.

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode ID 'S_TID' FIELD loc_utid.

ENDIF.

_________________________________________________________

Read only

0 Likes
1,526

if you look at the code of THUSRINFO they use the same C function call.

anyhow its a good practice to replace the C call in your program with THUSRINFO .

use the following code inplace of the C call.

data: usr_tabl type standard table of UINFO .

CALL FUNCTION 'THUSRINFO'

TABLES

usr_tabl = usr_tabl .

to suit your requirement copy this function module to your name space and add import parameter say opcode type X

and instead of this code

opcode = 2.

in the function

pass the import parameter to opcode.

Hope this helps.

Regards

Raja

Read only

0 Likes
1,526

How do I replace the following statements.

1.)

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode ID 'TAB' FIELD

usr_tabl-sys.

2.)CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode ID 'S_TID' FIELD loc_utid

ID 'S_MODE' FIELD slave_mode.

Regards,

Ankur Bhandari

p.s thanks in advance

Read only

0 Likes
1,526

Hi Ankur,

I tried your code :

1. The first statement u can replace by.

CALL FUNCTION 'TH_USER_LIST'

TABLES

list = usr_tabl.

It works fantasitc.

2. BUT THE SECOND.

Since in that the opcode is DIFFERENT

(14, 15 BASED UPON SELECTION)

This above FM will not work

Bcos it internally uses the opcode as '02'.

3 However i searching for another FM.

If i get, i will let u know.

4. Another Thing,

If it is a must,

that u want to use FM,

then u can create your own Y/Z FM

and write the same code.

ie CALL 'ThUsrInfo'

and use OPCODE parameter of the FM.

(if u want to go with this approach and need help,

pls let us know.

I hope it helps.

Regards,

Amit M.

Read only

0 Likes
1,526

you are check for some fcode (sscrfields-ucomm ) in the code. make this also as the parameter for the cutom function and call the appropriate C call based on sscrfields-ucomm

if you let us know what exactly you are trying to do ,(the big picture) may be we could come out with better approach than this, as using internal C functions is not a good practice.

Regards

Raja

Read only

0 Likes
1,526

There was this program RSM04000 in SAP 4.5 which doesnt exist now. This program allowed the user to share is SAP front end across firewalls, using function codes SLON and SLOF. I am trying to achieve the same thing in 4.7

let me know if you have any other workaround for the same with in SAP.

Ankur Bhandari

Read only

0 Likes
1,526

sorry have no idea about that.

Regards

Raja