2009 Sep 07 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
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
2009 Sep 07 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
2009 Sep 07 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
2009 Sep 07 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
2009 Sep 07 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])
2009 Sep 08 10:27 AM
Hello!
I've already tried all four possibilities and none of them worked.
Regards,
Mário Espinheira
2009 Sep 08 10:44 AM
2009 Sep 08 10:46 AM
could you tell us what end of line character it is? did you determine it?
2009 Sep 08 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
2009 Sep 08 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?
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |