‎2007 Apr 03 6:17 PM
Will the below snippets are same,if not what is the difference,(performance??)
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZVAR1'.
< logic x>
ENDLOOP
READ I_T_VAR_RANGE INTO LOC_VAR_RANGE
with Key VNAM = 'ZVAR1'.
IF sy-subrc = 0
< logic x>
endif
thanks
_R
‎2007 Apr 03 6:20 PM
Hi,
If there is more than one record with the condition VNAM = 'ZVAR1'. Then LOOP AT I_T_VA_RANGE will process all the records that matches the condition..
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZVAR1'.
< logic x>
ENDLOOP
The READ TABLE will get the first occurence of that condition...If there are more than one record..It will get the first record...
READ I_T_VAR_RANGE INTO LOC_VAR_RANGE
with Key VNAM = 'ZVAR1'.
IF sy-subrc = 0
< logic x>
endif
Thanks,
Naren
‎2007 Apr 03 6:21 PM
They are not the same if there are more than one record satisfying the WHERE condition. They are same if you know for sure that there is only one record satisfying that WHERE condition.
‎2007 Apr 03 6:23 PM
‎2007 Apr 03 6:23 PM
Hi,
The LOOP statement will process the records of the internal table where VNAM = 'ZVAR1'.
On the other hand, the READ statement will read the first suitable row where VNAM = 'ZVAR1' even you have more tan 1 records in the internal where VNAM = 'ZVAR1'.
Regards,
Ferry Lianto