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

regarding performace

Former Member
0 Likes
595

Hi friends,

1)which one is better in the below statements.

Read to get the data. Later using ' move ' to move to internal table

(or)

Loop moving the data to internal table...endloop

2) if i want the first two records to be displayed from my internal table what i have to do.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
574

hi,

1. Loop is used when you want to check the condition for all the table entries(more than one entry for some condition). and read is used when there is only in one record for the condition specified in your internal table(only one entry for condition).

2. You can simply read the records with index(provided you know the index).

read table itab index 1.

read table itab index 2.

However, this is only when you know which index to be read or if there is some condition then you can use where clause with binary search(You have to sort the internal table before this). Otherwise You have to use loop through the table.

Regards,

Richa.

5 REPLIES 5
Read only

Former Member
0 Likes
574
2) if i want the first two records to be displayed from my internal table what i have to do. 

  loop at itab from 1 to 2.
     write : / itab-field1.
  endloop.
Read only

Former Member
0 Likes
574

1 ->If you want to access one record then READ is the

best form to use.

If you have more than 1 record to be moved, the use

the LOOP.

2 ->Use the LOOP FROM .. TO.. form of loop statement.

Read only

Former Member
0 Likes
574

Hi satya,

Your first question is not clear?

Message was edited by:

Chandrasekhar Jagarlamudi

Read only

Former Member
0 Likes
574

Hi

read with binary search is always preferred for better performance..

sort the internal table with the required keys before using read on that table.

loops cant be avoided in specific conditions...

regards,

madhu

Read only

Former Member
0 Likes
575

hi,

1. Loop is used when you want to check the condition for all the table entries(more than one entry for some condition). and read is used when there is only in one record for the condition specified in your internal table(only one entry for condition).

2. You can simply read the records with index(provided you know the index).

read table itab index 1.

read table itab index 2.

However, this is only when you know which index to be read or if there is some condition then you can use where clause with binary search(You have to sort the internal table before this). Otherwise You have to use loop through the table.

Regards,

Richa.