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

BAPI_USER_GETLIST Selection Range Profile Query

0 Likes
1,628

Greetings,

Using BAPI_USER_GETLIST, I'd like to find all users that have profile 'A' assigned but do not have profile 'B'. A Selection Range expression of the type:

PARAMETER FIELD Sign OP LOW

PROFILES BAPIPROF I EQ 'A'

PROFILES BAPIPROF E EQ 'B'

Returns everyone holding 'A' but does not exclude people holding 'B'.

I'm confused about this result. Can anyone explain why BAPI_USER_GETLIST works this way?

Bill Bormann

Purdue University

5 REPLIES 5
Read only

former_member182670
Contributor
0 Likes
1,124

Quote from BAPI documentation:

"SELECTION_RANGE - You can list multiple attributes in the table, and an attribute can appear more than once. In this case, the selection using the same attribute is linked with 'OR', and selection using different attributes with 'AND'."

I think you should try with SELECTION_EXP - there you can influence the operator (LOGOP specifies whether the selection is to be linked with 'OR' or 'AND')

Read only

0 Likes
1,124

Same result, with SELECTION_EXP set as follows:

LOGOP ARITY PARAMETER FIELD OPTION LOW

AND 2

PROFILES BAPIPROF EQ A

PROFILES BAPIPROF NE B

I used the SELECTION_RANGE based on the example given in the help documentation that demonstrated how to select postal codes that include codes in a certain range, then exclude codes in that range that match a comparison string. For this particular problem, I've found no combination of SELECTION_EXP or SELECTION_RANGE that deliver the expected result.

Bill Bormann

Purdue University

Read only

0 Likes
1,124

The problem here is that these conditions are executed on the joined table.

Here is what BAPI executes:

select

from ( USR02 INNER JOIN UST04 ON USR02MANDT = UST04MANDT AND USR02BNAME = UST04BNAME )

where

( UST04~PROFILE EQ 'A' AND

UST04~PROFILE NE 'B' )

So it select users which have A, and users which have A+B. Users which have just B are excluded.

I your case it should be something like

UST04~PROFILE EQ 'A' AND NOT EXISTS SELECT ....

I don't think you can make it with one call. You need custom query or two BAPI calls and make the intersection in the code.

Read only

0 Likes
1,124

Thanks ... that makes a lot of sense.

Read only

0 Likes
1,124

SELECT *

FROM ust04 AS u

INTO TABLE gt_ust04j

WHERE profile = 'A''

AND NOT EXISTS ( SELECT *

FROM ust04

WHERE bname = u~bname AND

profile = 'B' ).

should do the trick