cancel
Showing results for 
Search instead for 
Did you mean: 

How to achieve 'OR' condition between search parameters in program

former_member267851
Participant
0 Kudos

Hi All,

I have two fields in search parameter let field A and B,   AS per my client requirement , I want result   should search either by A or B  but not both.

I want result  based on 'OR' in between those two parameters.

So suggest me which one going to help me to achieve this by add_selection_param or GET_SELECTION_PARAMS .

And how i write the code for 'OR' Condition.

Can anyone please tell me how can I achieve it ?

Regards

Alok

Accepted Solutions (0)

Answers (4)

Answers (4)

ratna_rajeshp
Active Participant
0 Kudos

Hi Alok,

It is not possible to make an OR conditon at the Screen level, Please do the validation in DO_VALIDATE method ,and throw a message if both are filled.

Thanks.

Rajesh.

former_member211707
Active Participant
0 Kudos

Hello Alok,

If you have two fields A and B as search parameter then use ADD_SELECTION_PARAM like below:--

  CALL METHOD LR_QS->ADD_SELECTION_PARAM

   EXPORTING

   IV_ATTR_NAME = 'fieldA'

   IV_SIGN      = 'I'

   IV_OPTION    = 'EQ'

   IV_LOW       = 'param1'.

and,

  CALL METHOD LR_QS->ADD_SELECTION_PARAM

   EXPORTING

   IV_ATTR_NAME = 'fieldB'

    IV_SIGN      = 'I'

    IV_OPTION    = 'EQ'

    IV_LOW       = 'param2'.

the query will internally take all these parameters as OR... You don't have to specify the OR anywhere.

Please check and let me know.

Thanks,

Amit

former_member267851
Participant
0 Kudos

Hi Amit,

R u sure that it act like 'OR' bcz when i m try to do

it act like 'AND' so i m getting wrong result .

Regards

Alok

ashik_k2
Contributor
0 Kudos

Hello Alok,

Is this your customer search component? If so,

then you have to read the selection parameters and before querying the table you to use OR condition to build the "where"  clause.

Thanks and Regards,

Ashik

former_member267851
Participant
0 Kudos

Thanks Ashik,

Nope , it is not custom component and there is no custom table to write where condition .

i am writing code in INIT Method .

I want result based on two field 'OR' Condition.

I think , u clear now what exactly my requirement.....

ashik_k2
Contributor
0 Kudos

Hello Alok,

Ok, in that case you have to check the implementation class of the search result

Eg: CL_BUPA_IL_HEADER_SEARCH=>IF_CRM_BUPA_IL_QUERY~GET_DYNAMIC_QUERY_RESULT( )

In this method IT_SELECTION_PARAMETERS parameter will contain input search criteria.

You have to debug  IF_CRM_BUPA_IL_QUERY~GET_DYNAMIC_QUERY_RESULT( ) and check where exactly the "WHERE" clause of the query is built and see if any BADI is available to change the parameter that is passed to  "WHERE" condition.

Hope it helps.

former_member267851
Participant
0 Kudos

Hi Ashik,

if i implement badi , i think it affect all search which happened in future.

Don't u think Ashik.

I want to change it in run time.

Regards

Alok

ashik_k2
Contributor
0 Kudos

No, you said only for two search criteria, you can check for those and apply necessary logic.

Regards,

Ashik

former_member267851
Participant
0 Kudos

Hi,

I am expecting answer ......

come on... any one!!!!!!!

devendervb
Contributor
0 Kudos

Hi Alok,

On the Searchpage , if we restrict the screen element with A or B, will that work for you?

Let me explain you in details there will be only 1 Screen element with drop down A & B, so, now end user had to select one of them only.

If this is fine then, I can send you other steps to follow

former_member267851
Participant
0 Kudos

Thanks devender.

Actually my requirement is not in Search page but i am writing code in INIT Method .

I want result based on two field 'OR' Condition.

I think , u clear now what exactly my requirement.....