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 cond in loop - error

prabhu_s2
Active Contributor
0 Likes
723

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
Read only

Former Member
0 Likes
671

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

Rob

4 REPLIES 4
Read only

Former Member
0 Likes
672

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

Rob

Read only

0 Likes
671

is there a work around for this?

Read only

0 Likes
671

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

Read only

Former Member
0 Likes
671

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