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: 

Dynamic where in range

hagit
Active Participant
0 Kudos
659

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

joltdx
Active Contributor
585

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

joltdx
Active Contributor
586

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 }|.

hagit
Active Participant
0 Kudos
585

jorgen_lindqvist41 Thanks for your quick answer.

I will try it

hagit
Active Participant
0 Kudos
585

jorgen_lindqvist41 It works perfectly.

Thanks again.

Hagit