09-12-2007 8:45 PM
Hi guru,
i am reading file from application server which is seprated by semicolumn.
How can i read this file.
Thnaks
Neo
09-12-2007 8:48 PM
Declare an itab with one field of type string. Read the file into this itab using OPEN DATASET statement.. then loop at this itab & SPLIT the <fld> at ';' into diff fields of a work area.. append that work area to another itab of the desired structure.. get it?
Arya
09-12-2007 8:49 PM
OPEN DATASET LV_FILENAME FOR INPUT IN TEXT MODE MESSAGE MSG.
DO.
*-- Read Dataset and Populate Input file data to Internal Table
READ DATASET LV_FILENAME INTO IT_DATA2.
IF SY-SUBRC EQ 0.
*-- Append and Initialize table
APPEND IT_DATA2.
CLEAR IT_DATA2.
ELSE.
*-- Exit Out of DO loop if READ is unsuccess
EXIT.
ENDIF.
ENDDO.
*-- Close Dataset
close datset lv_filename.
loop at it_data2.
split it_data2-line at ';' into it_data-field1 it_data-field2....
append it_data.
endloop.
09-12-2007 8:49 PM
You are going to want to do something like this.
report zrich_0001.
data: str type string.
data: begin of itab occurs 0,
fld1(10) type c,
fld2(10) type c,
fld3(10) type c,
end of itab.
data:
dsn(500) value '/usr/sap/TST/sys/test.txt'.
clear itab. refresh itab.
* Read the data.
open dataset dsn for input in binary mode.
do.
read dataset dsn into str.
if sy-subrc = 0.
split str at ';' into itab-fld1 itab-fld2 itab-fld3.
append itab.
else.
exit.
endif.
enddo.
close dataset dsn.
Loop at itab.
write:/ itab-fld1, itab-fld2, itab-fld3.
endloop.
Regards,
Rich Heilman