2014 Jan 29 11:25 AM
I have asked last time how to use Read Dataset statement,My thread was closed I don't know the reason as everybody has replied for OPEN DATA SET but My question is How to use READ DATA SET statement inside OPEN DATA SET.,AS I have transferred one file in ftp and i want to read it again using READ DATA SET so how i can do so?
2014 Jan 29 11:33 AM
Hi
open dataset <file> for input in text mode encoding default message lw_mesg.
if sy-subrc = 0.
do.
read dataset <file> into lw_buffer. "lw_buffer string type
if sy-subrc <> 0.
close dataset <file>.
exit.
endif.
* Append the record
if lw_buffer is not initial.
ls_data_raw-data = lw_buffer. "here ls_data _raw is a table type consists of DATA as field of
"type string
append ls_data_raw to lt_data_raw.
clear: ls_data_raw.
endif.
enddo.
close dataset <file>.
else.
messagw E<num> with lw_mesg. " No data found
endif.
2014 Jan 29 11:33 AM
Hi
open dataset <file> for input in text mode encoding default message lw_mesg.
if sy-subrc = 0.
do.
read dataset <file> into lw_buffer. "lw_buffer string type
if sy-subrc <> 0.
close dataset <file>.
exit.
endif.
* Append the record
if lw_buffer is not initial.
ls_data_raw-data = lw_buffer. "here ls_data _raw is a table type consists of DATA as field of
"type string
append ls_data_raw to lt_data_raw.
clear: ls_data_raw.
endif.
enddo.
close dataset <file>.
else.
messagw E<num> with lw_mesg. " No data found
endif.
2014 Jan 29 11:36 AM
Hi Ronak,
To write a file in application server, you have to use
Open dataset filename for output
then
Transfer itab to filename.
Now you can able to see the records in application server using TCode AL11.
Then,
To read a file in application server, you have to use..
Open dataset filename for input.
Then
Do.
Read dataset filename into your internal table.
Enddo.
Arivazhagan S
2014 Jan 29 11:36 AM
Hi Ronak,
Please check the below code for read dataset inside open dataset.
DATA: file TYPE string VALUE `flights.dat`,
wa TYPE spfli.
FIELD-SYMBOLS <hex_container> TYPE x.
OPEN DATASET file FOR INPUT IN BINARY MODE.
ASSIGN wa TO <hex_container> CASTING.
DO.
READ DATASET file INTO <hex_container>.
IF sy-subrc = 0.
WRITE: / wa-carrid,
wa-connid,
wa-countryfr,
wa-cityfrom,
wa-cityto,
wa-fltime,
wa-distance.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET file.
Thanks
Bharathi
2014 Jan 29 11:39 AM
Hi Ronak,
Once open dataset statment is success.
use the below statment
READ DATASET FNAME INTO TEXT2 LENGTH LENG.
Here it reads the data from application server file fname and places in varaiable text2
Please use below link for further details:
http://help.sap.com/saphelp_470/helpdata/EN/fc/eb3d42358411d1829f0000e829fbfe/content.htm
Regards,
Vineesh.