Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

move values from a string variable into a structure

Former Member
0 Likes
4,305

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

1 ACCEPTED SOLUTION
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
3,405

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).

-- Tomas --
9 REPLIES 9
Read only

Former Member
3,405

Use below statement

SPLIT <L_VARIABLE> AT ';' INTO <WA-VAR1> <WA-VAR2> <WA-VAR3> etc....

Read only

0 Likes
3,405

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>

Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
3,405

Warning! This completely ignores CSV delimiters.

-- Tomas --
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
3,406

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).

-- Tomas --
Read only

0 Likes
3,405

but I have to create the object with cl_rsda_csv_converter=>create ?

Read only

0 Likes
3,405

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

Read only

0 Likes
3,405

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.

-- Tomas --
Read only

0 Likes
3,405

have you a pratical example please?

Read only

3,405

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.
-- Tomas --