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

Select statement issue

Former Member
0 Likes
416

I have to select data from table ZABC, which has following fields & data

FieldA Field B

A X

B Y

A Y

C Z

My selection parameter SEL_TAB is a table type with FieldA and FieldB.

I want to write a select statement which gets only records matching both FieldA & FieldB, for example if I pass 'A' & 'X', it should get only first record.

Since my selection parameter contains thousands of records, do I need to write a select statement within loop? or is there a better way to handle this.

Loop at SEL_TAB intl l_sel_tab.

select * from ZABC where fieldA = l_sel_tab-fieldA

and fieldB = l_sel_tab-feildB.

Endloop

Thanks,

JB

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
389

Have a look at the SELECT ... FOR ALL ENTRIES ... statement, this does what you are looking for.

Thomas

3 REPLIES 3
Read only

ThomasZloch
Active Contributor
0 Likes
390

Have a look at the SELECT ... FOR ALL ENTRIES ... statement, this does what you are looking for.

Thomas

Read only

0 Likes
389

Thanks Thomas..I dont know how I forgot this option:-)

Anyway, have assigned you the points.

Read only

Former Member
0 Likes
389

Since those are simple select-options, you no need to loop them,


select-options: s_fielda for table1-fielda, 
                        s_fieldb for table1-fieldb. 

select * from table1 
             into table <internal table> 
            where fielda in s_fielda 
                and fieldb in s_fieldb. 

Thanks

Satyasuresh Donepudi