Fetching data from external tables

If we have selected some data into an internal table and now we 
have to fetch more data from other tables based on the entries in 
internal table, it's always advisable to use 'For all entries in Itab' 
option with Select statement rather than using loop endloop option.
****
And we should try to directly fetch data in internal table rather 
than fetching in a variable and then moving this variable into 
internal table.

data: begin of itab occurs 1000.
       equnr like v_equi-equnr.      
data: end of itab.

data: begin of itab2 occurs 1000.
       tplnr like v_equi-tplnr.
data: end of itab2.
*****
With out For all Entries option
******

Select equnr from afih into table itab where aufnr > '100000'.

loop at itab.
 select tplnr from v_equi where
         equnr = itab-equnr.
   itab2-tplne = v_equi-tplnr.
   append itab2.
   clear itab2.
 endselect.
endloop.

******
Now using 'For all entries option'

Select tplnr into table itab2 from v_equi for all entries in itab where]
   equnr = itab-equnr.

Here data will be fetched in single shot and communication server 
will be reduced which in turn will improve 
performance of the code.
********** 
  
  

    Requires Free Membership to View

This was first published in January 2002

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.

    Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.