09-07-2009 5:45 PM
Hi all!
I'm using OPEN DATASET to read CSV files (created using Excel 2007), that contain multiple lines, the problem is when I use READ DATASET it transfers the hole content of the CSV file into the variable instead of transfering line by line.
The source code is the following:
data: lv_lines type string.
open dataset x_file for input
in text mode
encoding default.
if sy-subrc eq 0.
do.
clear lv_lines.
read dataset x_file into lv_lines.
if sy-subrc eq 0.
append lv_lines to y_outtab.
else.
exit.
endif.
enddo.
else.
message e001(ztim_fi)
with x_file
raising general_fault.
endif.
close dataset x_file.
Can anyone help me with this?
Kind regards,
Mário Espinheira
09-07-2009 5:54 PM
Hello,
I hope y outtab is the internal table you are using.
If not append to an internal table.
Try this
data: lv_lines type string.
open dataset x_file for input
in text mode
encoding default.
if sy-subrc eq 0.
do.
clear lv_lines.
read dataset x_file into lv_lines.
if sy-subrc eq 0.
append lv_lines to t_outtab. // t_outtab is internal table
else.
exit.
endif.
enddo.
else.
message e001(ztim_fi)
with x_file
raising general_fault.
endif.
close dataset x_file.
Hope this helps.
Regards,
pallavi
09-07-2009 5:56 PM
Hi
It depends on how that file was created, u make sure the sign of end of record is set at the end of every line
Max
09-07-2009 6:06 PM
That's what I think, because if I create the file using Notepad it works fine. When I use the Excel generated files it doesn't work.
By the way, Y_OUTTAB is an Internal Table of type String.
Regards,
Mário Espinheira
09-07-2009 8:47 PM
Determine what is the end of line character, and you may indicate it in the OPEN DATASET statement (check [abap doc for open dataset end of line character|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_LINEFEED.htm])
09-08-2009 10:27 AM
Hello!
I've already tried all four possibilities and none of them worked.
Regards,
Mário Espinheira
09-08-2009 10:44 AM
09-08-2009 10:46 AM
could you tell us what end of line character it is? did you determine it?
09-08-2009 10:48 AM
Hi!
In debug, when I see the content of LV_LINES (that has all the data in the file) the Linefeed is #.
Regards,
Mário Espinheira
09-08-2009 6:29 PM
is usually the replacement character when the character cannot be displayed. Could you switch to hexadecimal view and tell us the code?