07-16-2006 1:47 PM
Hi,
I need to read all the records in a file from the Application server.I have coded and it reads the same record( the first one ) and runs into an infinite loop.
OPEN DATASET w_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.
<b> DO.</b>
READ DATASET w_path INTO i_tab.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
APPEND i_tab.
clear i_tab.
<b> ENDDO.</b>
Please suggest.
07-16-2006 2:58 PM
hi shiva,
give
DO.
READ DATASET w_path INTO i_tab.
IF SY-SUBRC <> 0.
EXIT.
<b>else.</b>
APPEND i_tab.
clear i_tab.
ENDIF.
ENDDO.
07-16-2006 2:02 PM
Hi Sivakumar,
Form the code it seems that your i_tab is some internal table . This doesnot get all the records. You should declare it of type <b>tedata-data</b>.
Note : TEDATA-DATA is declared as length 5000(char). You can also use STRING, but using this(TEDATA-DATA ) is the standard practise.
Do it in this way.
DATA : msg(200). "For holding messages during OPEN DATASET
<b>DATA : i_tab LIKE tedata-data.</b>
*Lets assume that <b>i_int</b> is your internal table header line.
OPEN DATASET w_path FOR INPUT IN TEXT MODE ENCODING DEFAULT <b>MESSAGE msg</b>.
IF sy-subrc NE 0.
MESSAGE w_osmsg TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
DO.
READ DATASET w_path INTO i_tab.
<b> IF sy-subrc EQ 0.</b>
i_int = i_tab.
APPEND i_int.
CLEAR i_int.
<b> ELSE.</b>
EXIT.
<b> ENDIF.</b>
ENDDO.
CLOSE DATASET w_path.
Regards,
Arun Sambargi
Message was edited by: Arun Sambargi
07-16-2006 2:05 PM
Try the following:
data: itab type table of string.
data: wa type string.
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
append wa to itab.
enddo.
endif.
close dataset d1.
hith
Sunil Achyut
07-16-2006 2:58 PM
hi shiva,
give
DO.
READ DATASET w_path INTO i_tab.
IF SY-SUBRC <> 0.
EXIT.
<b>else.</b>
APPEND i_tab.
clear i_tab.
ENDIF.
ENDDO.
07-16-2006 3:15 PM
Thanks Priya. It worked. I 've missed giving it in else part. But I couldnlt understand the reason that the "Do loop" is performed more than n number of times where n = number of recs in the file.
Regards,
Siva
07-16-2006 3:21 PM
The file may have blank lines appended in the end. check the file