2007 Jul 12 11:36 AM
Hello,
I need use a READ statement on an internal table ITAB (with feild var1) and check whether feild var1<= sydatum(i.e. var1 greater than or equal to sy-datum)....how can I implement this??
Regards,
Shashank.
2007 Jul 12 11:43 AM
Hi ,
use
loop at itab where var1 le sy-datum.
endloop.
regrds,
ananth
2007 Jul 12 11:43 AM
Hi ,
use
loop at itab where var1 le sy-datum.
endloop.
regrds,
ananth
2007 Jul 12 11:47 AM
2007 Jul 12 11:48 AM
<u>SORT ITAB.
READ TABLE ITAB WITH KEY VAR1 <= SYDATUM BINARY SEARCH.</u>
OR
<u>READ ITAB WITH KEY VAR1 <= SYDATUM</u>
YOU CAN USE ANY ONE READ STATEMENT
1ST ONE IS BINARY SEARCH IT IS BETTER IN PERFORMANCE
YOU HAVE TO SORT THAT ITAB BEFORE THIS STATEMENT
2ND ONE IS NORMAL SEARCHIN TECH IT IS NOT GOOD IN THE PERFORMANCE POINT OF VIEW
REGARDS
NARESH
2007 Jul 12 11:52 AM
Hi Shashank,
If you use READ statement, you would get only the first record that has the date less than sy-datum.
<= will result in more than one record and hence it is not advisable to use read statement with such conditions.
Ideally you should have only = for reading data.
if you want ALL the records which have date <= sy-datum, then use LOOP
loop at itab where datum <= sy-datum.
all the records which pass the condition willl come through.
endloop.
Regards,
Ravi
2007 Jul 12 11:45 AM
SORT ITAB.
READ TABLE ITAB WITH KEY VAR1 <= SYDATUM BINARY SEARCH.
OR
READ ITAB WITH KEY VAR1 <= SYDATUM
YOU CAN USE ANY ONE READ STATEMENT
1ST ONE IS BINARY SEARCH IT IS BETTER IN PERFORMANCE
YOU HAVE TO SORT THAT ITAB BEFORE THIS STATEMENT
2ND ONE IS NORMAL SEARCHIN TECH IT IS NOT GOOD IN THE PERFORMANCE POINT OF VIEW
REGARDS
NARESH
2007 Jul 12 11:51 AM
Hi Naresh,
We cannot use any of this read statement.I tried prior to posting this query.
Regards,
Shashank.
2007 Jul 12 12:05 PM
Hi,
try this short example.
DATA: BEGIN OF ITAB OCCURS 0,
DATE LIKE SY-DATUM,
END OF ITAB.
*
ITAB-DATE = '20000101'. APPEND ITAB.
ITAB-DATE = '20010101'. APPEND ITAB.
ITAB-DATE = '20020101'. APPEND ITAB.
ITAB-DATE = '20030101'. APPEND ITAB.
ITAB-DATE = '20040101'. APPEND ITAB.
ITAB-DATE = '20050101'. APPEND ITAB.
ITAB-DATE = '20060101'. APPEND ITAB.
ITAB-DATE = '20070101'. APPEND ITAB.
ITAB-DATE = SY-DATUM. APPEND ITAB.
ITAB-DATE = '20080101'. APPEND ITAB.
*
LOOP AT ITAB WHERE DATE < SY-DATUM.
WRITE: / 'before', ITAB-DATE.
ENDLOOP.
LOOP AT ITAB WHERE DATE = SY-DATUM.
WRITE: / 'equal ', ITAB-DATE.
ENDLOOP.
LOOP AT ITAB WHERE DATE > SY-DATUM.
WRITE: / 'after ', ITAB-DATE.
ENDLOOP.
Regards, Dieter
2007 Jul 12 12:08 PM
read statement is used to get value from the internal table based on key, therefore u cannot give <= or >= in read statement except =.
But you can still get the values using loop statement with where date LE sy-datum.