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 query

Former Member
0 Likes
1,061

Hi,

following is my select query. I dont want the select query inside the loop. Please tell me how can i do this.

loop at gt_tvrot.

select tvro~route

tvro~trazt

tvro~traztd

tvro~tdvzt

tvro~tdvztd

tvro~tdvznd

tvro~fahztd

tvro~distz

tvro~medst

tvrot~bezei

appending table gt_tvro

from tvro join tvrot

on tvroroute eq tvrotroute

where tvrot~spras eq sy-langu

Thanks.

and tvro~route eq gt_tvrot-route.

endloop.

8 REPLIES 8
Read only

Former Member
0 Likes
991

Hi

Use the below code

select tvro~route

tvro~trazt

tvro~traztd

tvro~tdvzt

tvro~tdvztd

tvro~tdvznd

tvro~fahztd

tvro~distz

tvro~medst

tvrot~bezei

appending table gt_tvro

*for all entries of gttvrot*_

from tvro join tvrot

on tvroroute eq tvrotroute

where tvrot~spras eq sy-langu

and tvro~route eq gt_tvrot-route.

If you want further clarity on this, got to SE30, Press TIPS and TRICKS push button on the application tool bar. This will help you a lot.

BR

Sree

Read only

0 Likes
991

HI,

I didn't get ur answer can u please clarify. i dont want to write the select query inside the loop.

Thanks

Read only

0 Likes
991

Yes if you use "for all entries" then you can write the select query outside the loop.

Please read the related documentation for the "for all entries"

key word. there you can find some examples also.

BR

Sree

Read only

0 Likes
991

Hi Ramya,

Instead of using LOOP..ENDLOOP se FOR ALL ENTRIES with select query as told above.

Regards,

Atish

Read only

0 Likes
991

hi

For all entries will join the internal tables on a select statement.

but at least one entry should be in itab else select wont take the joining itab.

regards

Jose

Read only

Former Member
0 Likes
991

instaed of LOP put a READ statment then it will be very easy

Read only

Former Member
0 Likes
991

Hi,

You can use for all entries as mentioned above. You need to check if there are any entries in the table mentioned in for all entries. If it is initial the query might give a dump.

Read only

Former Member
0 Likes
991

hi,

Use For ALL Entries Keyword.

But Keep In Mind That .

Check That First Table Contains Data and Use Where Condition.