01-19-2021 6:57 AM
Hello,
I'm trying to read the data of a .csv file located in the Application Server (AL11) into an internal table. I have done so as it follows:
OPEN DATASET lv_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
READ DATASET lv_filename INTO lv_data.
CLOSE DATASET lv_filename.
The .csv I'm using is the following:
Objetos;Error;Adv.;Infos;objeto
;1865;1812;760;C31
;;;;C30
..Grupo de funciones ZACT_VERFAB;1315;1006;498;C61
....Verif.sintaxis/Generación;1303;52;72;C60
......Verif.programas ampliada;1303;52;72;C71
........Error;1303;;;C70
..........Cód.mensaje 2500;1303;;;C50
However, whenever I execute my program, lv_data stores only the first line of the .csv, like this:
Objetos;Error;Adv.;Infos;objeto#
I have to add that lv_data has been defined as TYPE string, so its size has to be dynamical, so the problem is not there.
Thank you in advance,
Álvaro
01-19-2021 7:23 AM
That's because if you want to read multiple lines of e text file, which csv basically is, you need to do the read dataset in a loop until sy-subrc gives a value other than 0.
01-19-2021 6:57 AM
01-19-2021 7:23 AM
That's because if you want to read multiple lines of e text file, which csv basically is, you need to do the read dataset in a loop until sy-subrc gives a value other than 0.
01-19-2021 7:40 AM
Is there something you don't understand in the ABAP documentation?
NB: please do NOT declare internal tables with header lines, it's been obsolete for 20 years because it's error prone and it brings confusion.