‎2007 Mar 13 8:35 AM
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.
‎2007 Mar 13 11:57 AM
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.
‎2007 Mar 13 8:38 AM
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.
‎2007 Mar 13 8:40 AM
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.
‎2007 Mar 13 8:46 AM
Hi satya,
Your first question is not clear?
Message was edited by:
Chandrasekhar Jagarlamudi
‎2007 Mar 13 8:53 AM
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
‎2007 Mar 13 11:57 AM
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.