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: 

FM: SO_USER_LIST_READ or another one

Former Member
0 Kudos

OK, been so long since I asked a question had to remember how to set my email watch to be sure I get responses and not loose it here in this huge forum

So I have the FM SO_USER_LIST_READ and it has the import parameter "USER_GENERIC_NAME" I thought at one time I could give it a query value other than * and it would return from the list only those that matched but no matter what I try in SE37 I get the entire user list.

Question: Is there another standard FM or what is the proper value to search for "DD" and only get the users with "DD"?

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Hi Craig, I took a look at the SO_USER_LIST_READ function module in my WebAs 7.0 system. It seems that this functionality has been removed or commented out. If you are looking for user names from the USR* tables, then you mighr try the following BAPI. It works good in my system. Your function module and this BAPI are not looking at the same tables but this may help anyway. The SO_USER_LIST_READ is looking at the SAPoffice users, which in my companies case, is always setup when the user is setup, so just looking at the usr* tables would be ok in my case.



report zrich_0001.


data: isr type table of bapiussrge.
data: xsr type bapiussrge.

data: iuser type table of bapiusname.
data: xuser type bapiusname.

<b>xsr-parameter = 'USERNAME'.
xsr-field    = space.
xsr-sign     = 'I'.
xsr-option   = 'CP'.
xsr-low      = 'DD*'.
append xsr to isr.</b>


call function 'BAPI_USER_GETLIST'
  tables
    <b>selection_range = isr</b>
    userlist        = iuser.

loop at iuser into xuser.
  write:/ xuser-username.
endloop.


REgards,

Rich Heilman

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Hi Craig, I took a look at the SO_USER_LIST_READ function module in my WebAs 7.0 system. It seems that this functionality has been removed or commented out. If you are looking for user names from the USR* tables, then you mighr try the following BAPI. It works good in my system. Your function module and this BAPI are not looking at the same tables but this may help anyway. The SO_USER_LIST_READ is looking at the SAPoffice users, which in my companies case, is always setup when the user is setup, so just looking at the usr* tables would be ok in my case.



report zrich_0001.


data: isr type table of bapiussrge.
data: xsr type bapiussrge.

data: iuser type table of bapiusname.
data: xuser type bapiusname.

<b>xsr-parameter = 'USERNAME'.
xsr-field    = space.
xsr-sign     = 'I'.
xsr-option   = 'CP'.
xsr-low      = 'DD*'.
append xsr to isr.</b>


call function 'BAPI_USER_GETLIST'
  tables
    <b>selection_range = isr</b>
    userlist        = iuser.

loop at iuser into xuser.
  write:/ xuser-username.
endloop.


REgards,

Rich Heilman

0 Kudos

Thanks Rich! I was hoping though not to use any custom code, but after an hour or two of looking and your response I think I might be out of luck

0 Kudos

In the SO_USER_LIST_READ function module, notice this code.



* check and convert substitute patterns
  <b>DO.
    REPLACE '*' WITH '%' INTO USER_GENERIC_NAME.
    IF SY-SUBRC NE 0.
      EXIT.
    ENDIF.
  ENDDO.</b>
  CLEAR SOUI_MAS.
  MOVE USER_GENERIC_NAME TO SOUI_MAS-USRNAM.

<b>* read user list from DB
* PERFORM SOUI_SELMAS(SAPFSSO1) TABLES SOUI_TAB     "STH 970725
*                               USING  SOUI_MAS
*                               RCODE.</b>

  PERFORM SOUI_SELMAS_NOADR(SAPFSSO1) TABLES SOUI_TAB     "STH 970725
                                      USING RCODE.


You can see that it converts the * to the % here, which is likely used in a LIKE statement in the WHERE clause of the SELECT. Also notice that there is a PERFORM which is commented out. Take a look at this PERFORM, it may do the functionality that you require. You can copy this function module and uncomment this call and see if it does what you need.

I think you may have to do some hacking to get what you want, but maybe it is as easy as the above.

Good Luck man.

Rich Heilman

0 Kudos

Now that I've looked a little closer, yes, that is exactly what has happened here. SAP has commented all of that functionality out. Notice this line.




* till 4.0 the usernam will not longer exist !!!         "STH980109
  IF SOUI_IN-USRNAM NE SPACE.                            "STH980109
      SOUI_IN-SAPNAM = SOUI_IN-USRNAM.                   "STH980109
  ENDIF.                                                 "STH980109

* IF     SOUI_IN-USRTP  EQ SPACE                         "STH980109
*    AND SOUI_IN-USRYR  EQ SPACE                         "STH980109
*    AND SOUI_IN-USRNO  EQ SPACE                         "STH980109
*    AND SOUI_IN-USRNAM NE SPACE                         "STH980109
*    AND SOUI_IN-SAPNAM EQ SPACE.                        "STH980109
<b>*    SELECT * FROM V_SOUBADRP INTO TABLE SOUB_ARRAY      "STH980109
*             WHERE USRNAM LIKE SOUI_IN-USRNAM.          "STH980109</b>


This is only part of that FORM, which is no longer called, there is a lot more that is commented out which looks like it would have given you the functionality that you want.

Regards,

Rich Heilman

0 Kudos

Rich, am not sure but I don't have the bapi 'BAPI_USER_GETLIST'? Am in 472.

FM's which will get single user details is BAPI_USER_GET_DETAIL or SO_USER_READ.

Also to get the list, as rich suggested the perform which is commented uses SOUI_MAS for selecting respective users (not sure why though:-( )

* read user list from DB
* PERFORM <b>SOUI_SELMAS</b>(SAPFSSO1) TABLES SOUI_TAB     "STH 970725
*                               USING  SOUI_MAS
*                               RCODE.


  PERFORM SOUI_SELMAS_NOADR(SAPFSSO1) TABLES SOUI_TAB     "STH 970725
                                      USING RCODE.
  IF RCODE NE OK.
    RAISE USER_LIST_NO_ENTRIES.
  ENDIF.

only way to copy and uncomment to get the list of user with DD*.

Regds

Manohar

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Craig, I noticed that the SO_USER_LIST_READ is now only doing a SELECT against SOUD. So, how about using function module RFC_READ_TABLE. This seems to work very well in my system.



report zrich_0001.

data: iopt type table of rfc_db_opt.
data: xopt type rfc_db_opt.

data: ifields type table of rfc_db_fld.
data: xfields type rfc_db_fld.

data: idata type table of tab512.
data: xdata type tab512.

<b>xopt = 'USRNAM like ''DD%'''.</b>
append xopt to iopt.

xfields-fieldname = 'USRNAM'.
append xfields to ifields.

call function 'RFC_READ_TABLE'
  exporting
<b>    query_table                = 'SOUD'</b>
*   DELIMITER                  = ' '
*   NO_DATA                    = ' '
*   ROWSKIPS                   = 0
*   ROWCOUNT                   = 0
  tables
    options                    = iopt
    fields                     = ifields
    data                       = idata
 exceptions
   table_not_available        = 1
   table_without_data         = 2
   option_not_valid           = 3
   field_not_valid            = 4
   not_authorized             = 5
   data_buffer_exceeded       = 6
   others                     = 7.

loop at idata into xdata.
  write:/ xdata.
endloop.

REgards,

Rich Heilman

0 Kudos

I'm going to try this on a large system, I did the query part after the FM call - I make the FM call get everything back and then loop through and check it. However it my system bombs because the list is too big then I'll have to go with the custom FM.

I'm going to have to find someone at work who might understand why that was commented out ?

0 Kudos

I am handling the query part after I retreive the whole list for now - I'd rather have it at the ABAP level but hey can't have everything I guess.

So far I've hit 436 users without a problem. I've also asked someone if they can direct me to where to find out why that stuff is commented out.