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 in range

hagit
Active Participant
0 Likes
1,495

Hello experts,

I need to loop on an internal table with a dynamic where. The where should contain 'in range'.

For example, Instead of writing

DATA: lrng TYPE RANGE OF bkpf-blart.
LOOP AT <lt_bkpf> ASSIGNING FIELD-SYMBOL(<ls_bkpf>) WHERE blart IN lrng.

I want to write something like:

rng_fld_name = 'LRNG'.
ASSIGN (rng_fld_name) TO FIELD-SYMBOL(<rng>).
DATA(lv_where) = 'BLART IN ' && <rng>.
LOOP AT <lt_bkpf> ASSIGNING FIELD-SYMBOL(<ls_bkpf>) WHERE (lv_where).

The problem is that the above raises a dump in runtime

err.png

The dump is logical. But how can I write it correctly?

Thanks in advance,

Hagit

1 ACCEPTED SOLUTION
Read only

joltdx
Active Contributor
1,421

Hi!

In this case, given the rest of your example, you should simply write

DATA(lv_where) = 'BLART IN LRNG'.

Or a bit more dynamic, using a string template:

DATA(lv_where) = |BLART IN { rng_fld_name }|.
3 REPLIES 3
Read only

joltdx
Active Contributor
1,422

Hi!

In this case, given the rest of your example, you should simply write

DATA(lv_where) = 'BLART IN LRNG'.

Or a bit more dynamic, using a string template:

DATA(lv_where) = |BLART IN { rng_fld_name }|.
Read only

hagit
Active Participant
0 Likes
1,421

jorgen_lindqvist41 Thanks for your quick answer.

I will try it

Read only

hagit
Active Participant
0 Likes
1,421

jorgen_lindqvist41 It works perfectly.

Thanks again.

Hagit