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

Ad hoc Query

Former Member
0 Likes
1,104

Does anyone know if it is possible to make an ad_hoc_query with some OR restrictions instead of AND?

With an ad_hoc_query all parameters used are followed by and, I mean, the results should fullfills ALL the restrictions imposed.

For example, I need to do an ad_hoc_query in which the first surname fullfills the restriction "PEREZ" OR "GUTIERREZ". How can I do it?

Thanks in advanced.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,066

If i understood your question, instead of parameters if you have select-options in your ad_hoc_query, you can specify in your single Value options "PEREZ" OR "GUTIERREZ" and it should bring either "PEREZ" or

"GUTIERREZ" right !

If i understood your question, instead of parameters if you have select-options in your ad_hoc_query, you can specify in your single Value options "PEREZ" OR "GUTIERREZ" and it should bring either "PEREZ" or

"GUTIERREZ" right !

7 REPLIES 7
Read only

Former Member
0 Likes
1,067

If i understood your question, instead of parameters if you have select-options in your ad_hoc_query, you can specify in your single Value options "PEREZ" OR "GUTIERREZ" and it should bring either "PEREZ" or

"GUTIERREZ" right !

Read only

0 Likes
1,066

I mean different fields. Perhaps I have'n found the rigth words to explain the problem. If I want to make an ad-hoc-query in which the results were the number of pernrs available in which the first surname was 'PEREZ' OR the second surname was 'GUTIERREZ' how can I do it?

Thanks for your answer.

Read only

0 Likes
1,066

query with a where condition. say first and second surnames go in fields s1 and s2.

<query> where s1 CS 'REZ' or s2 CS 'REZ'. Because both names that you gave me both have 'REZ' common. you might want to modify that and query. CS means contains string.

Regards,

Vijay

Read only

Former Member
0 Likes
1,066

Hello Maria,

If u want to make a query on the fly then u can use select stmt with where clause supplied with internal table which is popluated.

select * from mara

where (t_itab).

The content of t_tab is built in the program. If u want to generically search u can use OR or u can use LIKE with %.

Read only

0 Likes
1,066

You mean with programming but if I use an standard sap transaction which is S_PH0_48000513 which corresponds to Ad_hoc_query how can I do the OR with different fields if the transaction shows me one select option for each input field chosen and is joining the options in both fields with a supposed AND?. The results make me think there is an AND.

Example ; I chose first surname in the query and the second. The system propose me two select options in which I introduce for surname_1 (first select option) 'PEREZ' and for surname (second select option) 'GUTIERREZ'. I want the Personal numbers whose surname_1 were 'PEREZ' OR surname_2 were 'GUTIERREZ'.

Read only

Former Member
0 Likes
1,066

If you can change the infoset, there is provision Under Extras button to add custom code.

the custom code can look something like this.

CHECK parameter1 = 'PEREZ' or parameter2 = 'GUTIERREZ'.

Read only

0 Likes
1,066

Could you explain me a little more? Thank you.