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

dynamic where condition in loop statement

Former Member
0 Likes
2,672

loop at itab where (condi).

......

endloop.

can i have a dynamic where clause for a loop statement and HOW?

5 REPLIES 5
Read only

Former Member
0 Likes
866

what do you mean by dynamic where clause?

Read only

Former Member
0 Likes
866

Hi,

Try like this.

TYPES: cond(72) TYPE C.

DATA: condtab TYPE TABLE OF cond.

APPEND 'CARRID = ' 'LH' ' AND' TO condtab.

APPEND 'CITYTO = ' 'NEW YORK' ' .' TO condtab.

loop at itab where (condtab).

......

endloop.

otherwise u can use the FM 'RH_DYNAMIC_WHERE_BUILD' for building the dynamic where clause.

Rewards points if helpful.

Regards,

Srinivas Ch

Read only

JozsefSzikszai
Active Contributor
0 Likes
866

.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
866

Taken directly from F1 help.

Addition 3

... WHERE log_exp

Effect

WHERE can be specified with all table-types. After WHERE, you can specify any logical expression log_exp in which the first operand of any singular comparison is a component of the internal table. For this reason, all logical expressions are possible except for IS ASSIGNED, IS REQUESTED and IS SUPPLIED. Dynamic specification of a component through bracketed character-type data objects is not possible. Loops at sorted tables must have compatible operands of the logical expression. All rows are read for which the logical expression is true.

Regards,.

Rich Heilman

Read only

0 Likes
866

Hi mate your question is your answer. You can have a syntax like what u specified.

loop at Itab where rec1 = 'xyz'.

endloop.

So what this loop does is ..It will loop only records where the rec1 is 'XYZ'.

Regards,

Raghav