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

How to use read table command on dynamic internal table???

Former Member
0 Likes
3,220

Hi all

How to use read table command on dynamic internal table???

Deepak

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,031

Hi,

It is not possible to loop at dynamic table with Where condition.

You can check the condition inside the loop in the following way:

Field-symbols: <fs_any>  type any.

         Loop at <dyn_tab> into <wa_dyn_tab>.
             Assign component 'FIELD' of structure <wa_dyn_tab> to <fs_any>.
             If sy-subrc = 0 and <fs_any> = 'VALUE'.
                <Code>
             Endif.
         Endloop.

Here FIELD refers to the fieldname which needs to be checked. VALUE refers to the value against which it should be checked.

Hope this helps!

Thanks,

Lakshmi

Edited by: Santhanalakshmi V on Nov 19, 2008 2:17 PM

6 REPLIES 6
Read only

Former Member
0 Likes
1,031

hi

i think u may not use read table but loop is possible

shiva

Read only

0 Likes
1,031

is it possible to use loop on dynamic table with where condition???

Read only

Former Member
0 Likes
1,031

Hi Deepak

Use this link this might help you.

Regards

Neha

Read only

Former Member
0 Likes
1,032

Hi,

It is not possible to loop at dynamic table with Where condition.

You can check the condition inside the loop in the following way:

Field-symbols: <fs_any>  type any.

         Loop at <dyn_tab> into <wa_dyn_tab>.
             Assign component 'FIELD' of structure <wa_dyn_tab> to <fs_any>.
             If sy-subrc = 0 and <fs_any> = 'VALUE'.
                <Code>
             Endif.
         Endloop.

Here FIELD refers to the fieldname which needs to be checked. VALUE refers to the value against which it should be checked.

Hope this helps!

Thanks,

Lakshmi

Edited by: Santhanalakshmi V on Nov 19, 2008 2:17 PM

Read only

0 Likes
1,031

Hi,

yes we all want a dynamic where-clause for loop and read table as we have for select where...

But, BTW


Field-symbols: <fs_any>  type any.
 
         Loop at <dyn_tab> into <wa_dyn_tab>.
             Assign component 'FIELD' of structure <wa_dyn_tab> to <fs_any>.
              If sy-subrc = 0 and <fs_any> = 'VALUE'.
                <Code>
             Endif.
         Endloop.

<fs_any> = 'VALUE' will cause a dump if <fs_any> is not assigned because the condition is evaluated completely.

You may write


         Loop at <dyn_tab> into <wa_dyn_tab>.
             Assign component 'FIELD' of structure <wa_dyn_tab> to <fs_any>.
              check:
                sy-subrc = 0,
                <fs_any> = 'VALUE'.
                <Code>
         Endloop.

Regards,

Clemens

Read only

Former Member
0 Likes
1,031

READ TABLE <l_table> INTO <l_line> INDEX 2.

Please see the post of Vijay in the link