‎2008 Jan 22 7:43 PM
hi all,
I would like to know how this code is working.
I have give the parameter name for the file as p_flname and total it got 3 records.
In the first loop of DO it fetches the first record from p_flanme, its ok.
but, in the second Do loop how its knows that it has to fetch the second record as we have'nt given any condition in the READ statement.
This code is working porperly.
OPEN DATASET P_FLNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DO.
CLEAR L_LINE.
READ DATASET P_FLNAME INTO L_LINE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
SPLIT L_LINE AT ',' INTO W_UPLOAD-BUKRS
W_UPLOAD-EKORG
W_UPLOAD-KTOKK
W_UPLOAD-ANRED
W_UPLOAD-NAME1
W_UPLOAD-SORTL
W_UPLOAD-LAND1
W_UPLOAD-AKONT
W_UPLOAD-FDGRV
W_UPLOAD-WAERS.
APPEND W_UPLOAD TO T_UPLOAD.
CLEAR W_UPLOAD.
ENDDO.
ENDIF.
thanks & regards
shashikanth naram.
‎2008 Jan 22 7:45 PM
Hello
The READ DATASET statement reads an entire record of the file except you specify a fixed length.
Regards,
Uwe
‎2008 Jan 22 7:45 PM
Hello
The READ DATASET statement reads an entire record of the file except you specify a fixed length.
Regards,
Uwe
‎2008 Jan 22 7:48 PM
hi ,
thanks for reply,
Then what is the use of DO and ENDDO , when it reads the whole record.
regards
shashikanth naram
‎2008 Jan 22 7:51 PM
Shashi,
READ DATASET statement - The content is read from the file starting from the current file pointer. After the data transfer, the file pointer is positioned after the section that was read.
Regards,
Shaik
‎2008 Jan 22 8:15 PM
Hello
OPEN DATASET P_FLNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0. " ensure that the file exists and can be opened
DO.
CLEAR: l_line.
READ DATASET p_flname INTO l_line. " read one record of file (EOF)
IF ( syst-subrc NE '0' ). " no record read -> end of file
EXIT.
ENDIF.
" process read record
...
ENDDO. " continue reading next record until EOF
ENDIF.
Regards,
Uwe
‎2008 Jan 22 8:23 PM
It would probably help you a lot if you put your cursor on a READ statement and press F1. The documentation is quite good.
Rob