‎2019 Nov 13 9:08 AM
how to move values from a string variable into a structure (not string) in the corresponding cells?
the string variable contains values extracted from a file .csv
for example the string variable contains:
FP02;LF;FP01
‎2019 Nov 13 10:38 AM
If it is CSV, then I recommend to use cl_rsda_csv_converter - csv_to_structure method.
In constructor you will need to set separator to ";" instead of initial "," (and maybe delimiter if you know it).
‎2019 Nov 13 9:16 AM
Use below statement
SPLIT <L_VARIABLE> AT ';' INTO <WA-VAR1> <WA-VAR2> <WA-VAR3> etc....
‎2019 Nov 13 10:25 AM
thanks.
one method more fast for transfer into structure or table?
whitout doing : <WA-VAR1> <WA-VAR2> <WA-VAR3> etc....
but directly transfer the data to corrispondent cells
for example: SPLIT <L_VARIABLE> AT ';' INTO <war>
‎2019 Nov 13 10:35 AM
Warning! This completely ignores CSV delimiters.
‎2019 Nov 13 10:38 AM
If it is CSV, then I recommend to use cl_rsda_csv_converter - csv_to_structure method.
In constructor you will need to set separator to ";" instead of initial "," (and maybe delimiter if you know it).
‎2019 Nov 13 1:57 PM
but I have to create the object with cl_rsda_csv_converter=>create ?
‎2019 Nov 13 2:00 PM
SE24 cl_rsda_csv_converter
there is two constructor : CONSTRUCTOR or CLASS_CONSTRUCTOR
create is not a constructor, it is a "simple" method.
search for example, if you fill unconfortable with these constructors
‎2019 Nov 13 2:14 PM
luca.treva yes I meant this method. You need to use it to create a object. You can find examples on the internet (or maybe in your system) how to use this class.
‎2019 Nov 13 3:11 PM
‎2019 Nov 13 3:28 PM
luca.treva Did you search? It is VERY simple:
DATA(lo_csv_converter) = cl_rsda_csv_converter=>create(
i_delimiter = l_delimiter
i_separator = l_separator ).
LOOP AT lt_csv_lines INTO l_csv_line.
lo_csv_converter->csv_to_structure(
EXPORTING
i_data = l_csv_line "Your string
IMPORTING
e_s_data = ls_data ). "Your result structure
ENDLOOP.