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 dynamic where clause

Former Member
0 Kudos

hi,

In a program we need to use a loop into an internal table with a where condition is decided on run time.

"Select" from database table is using dynamic where clause and it is working fine.

For the loop part does any one have any idea on this? if we can have dynamic where clause in a loop into internal tab?

Thanks

3 REPLIES 3

former_member194669
Active Contributor
0 Kudos

Hi,

May be you use field-symbols in place of internal table

ASSIGN COMPONENT <ls_cha> OF STRUCTURE <ls_thatcha> TO <l_thatfld>

aRs

marcelo_ramos
Active Contributor
0 Kudos

Hi,

You can't use 'loop where' dynamically .

Have you already tried to use Ranges and CHECK statement?

Like:

First mount range options;

Loop at <table>.

Check using the range.

endloop.

Maybe it's works for you !!

Marcelo Ramos

Former Member
0 Kudos

hi

good

go through this FM.

CLDY_DYN_SEL_WHERETAB_CREATE

DYNSQL_GENERATE_WHERE_CLAUSE

RH_DYNAMIC_WHERE_BUILD

in the IT_WHERE you need to write the correct conditions, like

IT_WHERE-FIELD1 = 'DATE1 = Sy-DATUM and'.

Append IT_WHERE.

IT_WHERE-FIELD1 = 'DATE2 = Sy-DATUM'.

Append IT_WHERE.

thanks

mrutyun^