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

Loop with where statement containing *

Former Member
0 Likes
1,049

Hello experts,

I have this statement:

LOOP AT i_sorg WHERE q = quality

AND s = size

AND v = variant.

....

....

APPEND i_result.

ENDLOOP.

However for the size I need to give the user to enter wild cards "*"as well as ?. If the size contains "" the loop doesn't find the record. If I translate the "" in to "%" it doesn't run either so what should I do that the WHERE statement find the record.

Thanks

1 ACCEPTED SOLUTION
Read only

former_member787646
Contributor
0 Likes
1,025

Hi,

Try this...

Data: vSize(10).

IF size = ''.

vSize = '*'.

ENDIF.

LOOP AT i_sorg WHERE q = quality AND s CP vSize AND v = variant.

....

....

APPEND i_result.

ENDLOOP.

Hope it helps.

Murthy

6 REPLIES 6
Read only

ThomasZloch
Active Contributor
0 Likes
1,025

use the LIKE operator instead of "=" combined with the wild cards "%" and "_".

Thomas

Edit: operator CP with "*" and "+" should work as well.

Edited by: Thomas Zloch on Aug 13, 2008 12:51 PM

Read only

peter_ruiz2
Active Contributor
0 Likes
1,025

Hi,

using CP instead of the = sign.

regards,

Peter

Read only

Former Member
0 Likes
1,025

Hi,

Inside loop put check for the charecter '*' using FIND and use sy-subrc for your action.

Sudheer. A

Read only

Former Member
0 Likes
1,025

Hi,

Inside loop check fop the charecter '*' using FIND and then if sy-subrc = 0 then do your action.

Sudheer. A

Read only

Former Member
0 Likes
1,025

use LIKE instead of =.

Read only

former_member787646
Contributor
0 Likes
1,026

Hi,

Try this...

Data: vSize(10).

IF size = ''.

vSize = '*'.

ENDIF.

LOOP AT i_sorg WHERE q = quality AND s CP vSize AND v = variant.

....

....

APPEND i_result.

ENDLOOP.

Hope it helps.

Murthy