Application Development 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: 

Loop with where statement containing *

Former Member
0 Kudos
124

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

former_member787646
Contributor
0 Kudos
100

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

ThomasZloch
Active Contributor
0 Kudos
100

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

peter_ruiz2
Active Contributor
0 Kudos
100

Hi,

using CP instead of the = sign.

regards,

Peter

Former Member
0 Kudos
100

Hi,

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

Sudheer. A

Former Member
0 Kudos
100

Hi,

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

Sudheer. A

Former Member
0 Kudos
100

use LIKE instead of =.

former_member787646
Contributor
0 Kudos
101

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