‎2007 Jan 05 4:47 PM
i am having errors with the following statement.
READ TABLE IT_A901 WITH KEY BZIRK = IT_KNVV-BZIRK
VKORG = IT_KNVV-VKORG
KDGRP = IT_KNVV-KDGRP
DATBI GE IT_BSID-BUDAT
DATAB LE IT_BSID-BUDAT.
Any suggestions.
madhu.
‎2007 Jan 05 4:54 PM
Hi,
Yes..If the record is found then the EXIT statement will come out of the LOOP in the first iteration itself..If there is no record found..Then it will directly come out of the LOOP.
Thanks,
Naren
‎2007 Jan 05 4:49 PM
Hi,
You cannot use GE operator in the READ statement..
Instead use LOOP AT..EXIT..ENDLOOP.
LOOP AT IT_A901 WHERE BZIRK = IT_KNVV-BZIRK
AND VKORG = IT_KNVV-VKORG
AND KDGRP = IT_KNVV-KDGRP
AND DATBI GE IT_BSID-BUDAT
AND DATAB LE IT_BSID-BUDAT.
EXIT.
ENDLOOP.
IF SY-SUBRC <> 0.
RECORD NOT FOUND.
ELSE.
RECORD FOUND.
ENDIF.
Thanks,
Naren
‎2007 Jan 05 4:51 PM
Thanks Naren. However i am assuming that the Exit command would loop the Internal table only once and would exit even if multiple entries found for the same condition.
Madhu.
‎2007 Jan 05 4:54 PM
Hi Madhu,
Istead of using 'EXIT' inside loop, U can perform the action whichever u want
in that loop. It will work only for the matching records.
Thanks,
Sreenu
‎2007 Jan 05 4:54 PM
That is right, but you were trying to use the READ statement which tells us that you only want to get one record, which is why Narren has added the EXIT statement. If you want all record that satisfy the condition, simply remove the EXIT statement.
Narren's solution is to get around the limitation of using GE or LE in a READ statement, this is the reason for the LOOP and the EXIT statements.
Regards,
Rich Heilman
‎2007 Jan 05 4:54 PM
Hi,
Yes..If the record is found then the EXIT statement will come out of the LOOP in the first iteration itself..If there is no record found..Then it will directly come out of the LOOP.
Thanks,
Naren
‎2007 Jan 05 4:57 PM
Sort the table and then do a binary search. If an entry is found, continue with indexed reads.
Rob
‎2007 Jan 05 5:03 PM
Hi,
In Read statement we should not use 'GE' or 'LE'. And why your are using Exit statement.
try like this
LOOP AT IT_KNVV-VKORG
READ TABLE IT_A901 WITH KEY BZIRK = IT_KNVV-BZIRK
VKORG = IT_KNVV-VKORG
KDGRP = IT_KNVV-KDGRP
DATBI > IT_BSID-BUDAT
DATAB < IT_BSID-BUDAT.
IF SY-SUBRC = 0. (RECORD FOUND)
WRITE YOUR CODE.
ELSE (RECORD NOT FOUND)
WRITE YOUR CODE.
ENDLOOP.
Thnak you
Gopal