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: 

dynamic cond in loop - error

prabhu_s2
Active Contributor
0 Kudos

Hi,

i have a declaration as follows:


TYPES: BEGIN OF ty_filter,
         cond(72)  TYPE c,
       END OF ty_filter.

DATA: ta_filter TYPE STANDARD TABLE OF ty_filter.

...
...
    LOOP AT ta_tran_upd
      ASSIGNING <fx_tran>
      WHERE ( ta_filter ).

the above one is issue an error message "Unable to inetpret ')' but when i replace the dynamic where with some condition it is working fine...any idea on it. couldnt get the source of the error.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

I don't think you can use a dynamic WHERE in a LOOP.

Rob

4 REPLIES 4

Former Member
0 Kudos

I don't think you can use a dynamic WHERE in a LOOP.

Rob

0 Kudos

is there a work around for this?

0 Kudos

Dynamic WHERE in LOOP is possible as of NW 7.02.

I think you can use field symbols to create kind of dynamic loop. Refer this for example:


DATA: l_filter TYPE string VALUE 'CARRID',
      l_value  TYPE string VALUE 'LH'.

DATA: it_sflight TYPE TABLE OF sflight WITH HEADER LINE.

SELECT * FROM sflight INTO TABLE it_sflight  UP TO 10 ROWS  .

FIELD-SYMBOLS <fs> TYPE ANY.

LOOP AT it_sflight.
  ASSIGN COMPONENT l_filter OF STRUCTURE it_sflight TO <fs>.
  CHECK sy-subrc = 0.
  IF <fs> = l_value.
    WRITE / 'Found one'.
  ELSE.
    CONTINUE.
  ENDIF.
ENDLOOP.

Regards

Marcin

former_member641978
Active Participant
0 Kudos

Hi

I think that you can't do dynamic where but if you use it you should declare it as (condition)

and not ( condition ).

SELECT ***

FROM***

INTO*********

WHERE (ta_filter).

Best Regards

Yossi