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.
Showing results for 
Search instead for 
Did you mean: 

Internal Table dynamic query

0 Kudos


I have an internal table which needs to be queried with set of attributes which change dynamically. How can I do it?

Eg: Internal Table i_tab contains attributes a,b,c,d,e etc... Now I should extract a single line from the table based based on the values I supply for the attributes.

Say if I give a=23 b='' c='abc' d='' e=''. Then the query should be able to return be the line where all the initial field attributes (here in this case b,d, and e) should not be considered for the query.

It shoud be

read table i_tab with key a= 23 c='abc'.

The next time a query can be shooted with the foll values

a='' b='SAP' c='ERP' d='' e=''.

Then the query shd be

read table i_tab with key b= 'SAP' c='ERP'.

In short can I get the functionality of the "select statement dynamic search string"?

select * from tab where ( search string ) .

and search string would be generated dynamically based on the inputs?

I would be really thankful if you can provide me an immediate answer.

Thanks and Regards,



Former Member
0 Kudos

I think one of the simplest way is to define ranges for the variables a, b, c, d and e.

ranges : r_a for a, r_b for b...r_e for e.

refresh : r_a, r_b, r_c, r_d, r_e.

clear : r_a, r_b, r_c, r_d, r_e.

if a is not initial.

r_a-sign = 'I'.

r_a-option = 'EQ'.

r_a-low = value.

append r_a.


....similarly build for b, c, d and e.

Loop at itab.

check itab-a in r_a.

check itab-b in r_b.


check itab-e in r_e.

move-corresponding itab to <b>urval</b>.



Former Member
0 Kudos



go through these links, which ll give you brief idea abou the dynamic internal table creation.