‎2011 Jan 07 12:56 PM
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
‎2011 Jan 07 1:11 PM
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')
‎2011 Jan 07 1:23 PM
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
‎2011 Jan 07 2:02 PM
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.
‎2011 Jan 07 2:15 PM
‎2011 Jan 07 2:18 PM
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