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 SELECT with FOR ALL ENTRIES IN

Former Member
0 Kudos

Hello Xperts,

we are having a bit of trouble with the following SELECT


FIELD-SYMBOLS:
        <itab1>      TYPE standard table. 

  ASSIGN ATTR_T_I->* TO <itab1>.

    select
      FIELD1
      FIELD2
    from DBTAB1
    into CORRESPONDING FIELDS OF table <itab1>
    FOR ALL ENTRIES IN <itab1>
    where
      FIELD3     =   <itab1>-FIELD3    and
      FIELD4     =   <itab1>-FIELD4 
      .

ATTR_T_I is a static attibute of type table.

The syntax check throws the following message:

The specified type has no structure and therefore no component called FIELD3.

Any ideas out there how to solve this issue?

Thanx!

1 ACCEPTED SOLUTION

rahul_mb
Active Participant

Hi Martin,

Change your code like this and try.

DATA: itab2 TYPE TABLE OF string.
FIELD-SYMBOLS:
        <itab1>      TYPE standard table. 
 
  ASSIGN ATTR_T_I->* TO <itab1>.

APPEND 'FIELD3     =   <itab1>-FIELD3    and' TO itab2.
APPEND 'FIELD4     =   <itab1>-FIELD4' TO itab2.
 
    select
      FIELD1
      FIELD2
    from DBTAB1
    into CORRESPONDING FIELDS OF table <itab1>
    FOR ALL ENTRIES IN <itab1>
    where
      (itab2)
      .

Regards,

Rahul Muraleedharan.

4 REPLIES 4

Former Member
0 Kudos

You can use a solution like this:

FIELD-SYMBOLS: <lfv_valuefield3> TYPE ANY.

 ASSIGN COMPONENT field3 OF STRUCTURE <itab1> TO <lfv_valuefield3>.

Then, do the select comparing FIELD3 = <lfv_valuefield3>

Former Member
0 Kudos

Hi Martin,

Please try with this. Declare your field symbol type any instead of standard table and then assign it accordingly.

This might help.

Thanks,

Guru.

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Martin,

You have to use a dynamic token in the WHERE clause. Check this question which i had posted:

Cheers,

Suhas

rahul_mb
Active Participant

Hi Martin,

Change your code like this and try.

DATA: itab2 TYPE TABLE OF string.
FIELD-SYMBOLS:
        <itab1>      TYPE standard table. 
 
  ASSIGN ATTR_T_I->* TO <itab1>.

APPEND 'FIELD3     =   <itab1>-FIELD3    and' TO itab2.
APPEND 'FIELD4     =   <itab1>-FIELD4' TO itab2.
 
    select
      FIELD1
      FIELD2
    from DBTAB1
    into CORRESPONDING FIELDS OF table <itab1>
    FOR ALL ENTRIES IN <itab1>
    where
      (itab2)
      .

Regards,

Rahul Muraleedharan.