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: 

Avoiding select from a deep structure in a loop

Former Member
0 Kudos


Hi All,

I have a 3 level deep structure from which I have to select data. I need to use select statement outside the loop, but not able do that. i'm able to do select within the loop (using field-symbols) only.

please help me in this regard.

Regards,

SriLalitha.

1 ACCEPTED SOLUTION

former_member730258
Participant
0 Kudos

Use SELECT outside the loop using FOR ALL ENTRIES, then use READ TABLE within the loop.

Example:

  SELECT * FROM table1

         INTO result_tab

         FOR ALL ENTRIES IN ref_tab

         WHERE column1 = ref_tab-col1.

  LOOP AT ref_tab ASSIGNING <fs>.

    READ TABLE result_tab WITH KEY column1 = <fs>-col1.

  ENDLOOP.

4 REPLIES 4

Former Member
0 Kudos

Hi Sri Lalitha,

Please try like below code.

select <fields>

           --------

    from <tbname>

    into <mainstructure>-<subsrtucture>

where <condition>.

Regards,

Venkat.

0 Kudos

Hi,

I want to select from a deep structure to avoid its usage in a loop.

Thanks & Regards,

SriLalitha

0 Kudos

Create separate internal table like internal structure, and then select the data.

data newtable like table of struture2

newtable = stucture1-structure2.


read newtable into workarea with key <condition>.




former_member730258
Participant
0 Kudos

Use SELECT outside the loop using FOR ALL ENTRIES, then use READ TABLE within the loop.

Example:

  SELECT * FROM table1

         INTO result_tab

         FOR ALL ENTRIES IN ref_tab

         WHERE column1 = ref_tab-col1.

  LOOP AT ref_tab ASSIGNING <fs>.

    READ TABLE result_tab WITH KEY column1 = <fs>-col1.

  ENDLOOP.