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: 

BAPI_USER_GETLIST filtering data

lrayapat73
Participant
0 Kudos
1,945

Hi All,

I am trying get all users with certain filters like FirstName="somename", LastName=somename", pls. refer below, how can I pass logical oprtation like "or" , currently with below code it's always going as "and" operation, all the users where FIRSTNAME="Ellena" and LASTNAME="Clarc". But I want as FIRSTNAME="Ellena" or LASTNAME="Clarc"

Code using with .Net connector NCO 3.0,

IRfcFunction fnGetAllUsers = repo.CreateFunction("BAPI_USER_GETLIST");

IRfcTable selectionRange = fnGetAllUsers.GetTable("SELECTION_RANGE");

selectionRange.Append();

selectionRange.SetValue("PARAMETER", "ADDRESS");

selectionRange.SetValue("FIELD", "FIRSTNAME");

selectionRange.SetValue("SIGN", "I");

selectionRange.SetValue("OPTION", "EQ");

selectionRange.SetValue("LOW", "Ellena");

selectionRange.Append();

selectionRange.SetValue("PARAMETER", "ADDRESS");

selectionRange.SetValue("FIELD", "LastNAME");

selectionRange.SetValue("SIGN", "I");

selectionRange.SetValue("OPTION", "EQ");

selectionRange.SetValue("LOW", "Clarc");

Thanks,

Kumar

1 ACCEPTED SOLUTION

jmodaal
Active Contributor
1,531

Hello,

try it using the SELECTION_EXP parameter, filling the first row with 'OR' and specification of 2 following selection criteria that has to be considered. See attached screenshot.

7 REPLIES 7

jmodaal
Active Contributor
1,532

Hello,

try it using the SELECTION_EXP parameter, filling the first row with 'OR' and specification of 2 following selection criteria that has to be considered. See attached screenshot.

0 Kudos
1,531

Thank you Jan, it's working as explained above.

Is it possible to do like below,

(FIRSTNAME='ELLENA' or LASTNAME='Clarc') AND (E_MAIL='test@test.com' or Department='Sales')

In my application user gets an option to choose the filters, with 'AND', 'OR' combinations.

jmodaal
Active Contributor
0 Kudos
1,531

Hello,

I think that this is not possible in a single call. So, for the selection you gave, you have to call the function module twice and use the intersection of both result lists.

0 Kudos
1,531

Ok, thanks Jan.

0 Kudos
1,531

Hello,

is it possible to search on UserName? Not sure what is the parameter value for Username?

selectionRange.Append();

selectionRange.SetValue("PARAMETER", "<???>");

selectionRange.SetValue("FIELD", "USERNAME");

selectionRange.SetValue("SIGN", "I");

selectionRange.SetValue("OPTION", "EQ");

selectionRange.SetValue("LOW", "Clarc");

jmodaal
Active Contributor
1,531

Hello,

in that case you have to use the other parameter table SELECTION_RANGE.

0 Kudos
1,531

Thanks Jan.

It's working even with selection exp, with out "Field" property.

selectionExpression.Append();

selectionExpression.SetValue("LOGOP", "AND");

selectionExpression.SetValue("ARITY", "0");

selectionExpression.Append();

selectionExpression.SetValue("PARAMETER", "USERNAME");

// selectionExpression.SetValue("FIELD", "USERNAME");

selectionExpression.SetValue("OPTION", "EQ");

selectionExpression.SetValue("LOW", "TestUserName1");