2005 Oct 27 12:04 PM
Hi All,
I am new to ABAP ,could any one explain me the READ statment,
1. Is it specific any internal table type
2. How is readind data different from using loop.
Thanks in advance.
AS
2005 Oct 27 12:07 PM
Why dont you use the online help? Just position the cursor on the keyword read and press F1, all your questions will be answered there.
2005 Oct 27 12:12 PM
Hi Aima,
when you use LOOP, you will read all the data of the table. When you use READ, you will read only one line of the table.
for example a loop can be replace by.
describe table it_data lines v_count.
do.
v_countb = v_countb + 1.
if v_countb gt v_count.
exit
endif.
read table it_data index v_countb.
enddo.
(I didn't check the code)
Read allow condition of selection, but you must be sure that this condition will only answer one line. Or you will not be sure that the answer will be the good one.
Have a look of the transaction ABAPDOCU for all advanced documentation.
Regards
Frédéric
2005 Oct 27 12:13 PM
Hi Aima,
READ is for reading record from any type of internal table using index or with fields.
LOOP statement will loop through the internal table record by record, based on the condition given if any.
Hope this is clear.
Cheers
Vinod
2005 Oct 27 12:17 PM
Hi,
Suppose, the records in an internal table(it_table) with field ID are
1 2 3 4 5.
if we say:
Read table it_table with key id = '3'.
the number of records processed will be only 3.
if we say :
loop at it_table where id = '3'.
endloop.
the number of records processed will be 5.
the number of records processed in case of both read and loop will be same if record is not found.
2005 Oct 27 12:35 PM
Hi ,Firstly thanq for all ur replies,
Is it possible to use read statement for checking a validity date,i mean every syntax of READ uses '=' while checking the condition but for me the validaity date lies between two fields and specifing the condition like
datab =< wa_st-datum and datbi >= wa_st-datum
this will work.
Thanks,
AS
2005 Oct 27 12:38 PM
You have to use the loop statement with condition gt ge lt le .. (> >= < <= ) and to exit to the first line.
for example
loop at it_table where datab =< wa_st-datum and datbi >= wa_st-datum.
exit.
endloop.
if sy-subrc eq space.
... had your code ...
endif.
2005 Oct 27 12:18 PM
Hi,
Using read statement,you can only read single record.
But using loop,you can read more than one record.