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

Pattern use in Select Queries

Former Member
0 Likes
1,846

Can we use pattern in the slect quiries with the FOR ALL ENTRIES clause.

Eg:

Select * into IT_MARA from MARA FOR ALL ENTRIES in IT_MARC where werks = IT_WERKS-WERKS.

IT_WERKS wil contain 10, 20, 30*

what option we can use instead of '=' in the select queries.

1 ACCEPTED SOLUTION
Read only

gaursri
Active Contributor
0 Likes
1,466

Hi Mohan,

In where addition we can use following comparison operator,between,like,in,is,in seltab,null,condition syntax,and or not , subquery, for all enteries.For the use of pattern i will prefer to validate the Werk field before using it in select query.Hoping your query resolves.We can use the pattern clause,though validating it before hand will be the best optyion as select query will not be complex.

Have a best day ahead.

6 REPLIES 6
Read only

gaursri
Active Contributor
0 Likes
1,467

Hi Mohan,

In where addition we can use following comparison operator,between,like,in,is,in seltab,null,condition syntax,and or not , subquery, for all enteries.For the use of pattern i will prefer to validate the Werk field before using it in select query.Hoping your query resolves.We can use the pattern clause,though validating it before hand will be the best optyion as select query will not be complex.

Have a best day ahead.

Read only

Former Member
0 Likes
1,466

Hi Mohanraj ,

In Select query instead of = you can use in for select-options. But it is better = for this current example.

Thanks and regards

Pinaki

Read only

Former Member
0 Likes
1,466

hi,

try this .

Select * into IT_MARA from MARA FOR ALL ENTRIES in IT_MARC where werks = IT_WERKS-WERKS.

IT_WERKS in (10, 20, 30* ).

OR

Select * into IT_MARA from MARA FOR ALL ENTRIES in IT_MARC where werks = IT_WERKS-WERKS.

IT_WERKS between 10* and 30*.

Read only

Former Member
0 Likes
1,466

Hi,

use the following code.

Data: IT_WERKS2 like IT_WERKS OCCURS 0 WITH HEADER LINE..

IT_WERKS2[] = IT_WERKS[].

LOOP AT IT_WERKS2.

DO.

REPLACE '*' WITH '%' INTO IT_WERKS2-WERKS.

IF sy-subrc NE 0.

EXIT.

ENDIF.

ENDDO.

MODIFY IT_WERKS2.

ENDLOOP.

Select * into IT_MARA from MARA FOR ALL ENTRIES in IT_MARC2

where werks LIKE IT_WERKS2-WERKS.

Read only

Former Member
0 Likes
1,466

Hi,

Try to create a RANGE (R_WERKS) with the values 10, 20, 30* to use it in the WHERE condition.

Select *

into IT_MARA

from MARA

FOR ALL ENTRIES in IT_MARC

where werks in R_WERKS.

Additionally, you must avoid the use of Select * sentence to only specify the fields that you need.

hope this information is help to you.

Regards,

José

Read only

Former Member
0 Likes
1,466

Thank you all!!!