Application Development 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: 

Pass values from Multiline Internal Table to one Variable in multiline format.

0 Kudos

Hi Experts,

I have a requirement where i want to pass the entries of an internal table to a variable in multiline format.

For eg: If the internal table has entries as :

a

b

c

then in the variable also it should store as:

a

b

c

The number of entries in the internal table will vary or is dynamic. How can i achieve this?

Thanks in Advance.

2 REPLIES 2

basantmhr
Participant
0 Kudos

Hi April,

I don't think it is possible to store the value in the format you want, but you can store the value in a linear format with a line separator separating different entries. Below given is an example of the same.

DATA: scarr_tab  TYPE SORTED TABLE OF scarr
                WITH UNIQUE KEY carrname,
      scarr_line TYPE scarr,
      lv_string  TYPE string.

SELECT *
       FROM scarr
       INTO TABLE @scarr_tab.

LOOP AT scarr_tab INTO scarr_line.
  CONCATENATE lv_string scarr_line-carrname INTO lv_string SEPARATED BY cl_abap_char_utilities=>cr_lf.
ENDLOOP.

cl_demo_output=>display( data = lv_string ).

The only issue with the above solution is that it is only perfect if the value of the variable has to be printed, but in case you want to perform operations on the different entries added to the variable, I would suggest you use internal table only.

gdey_geminius
Contributor
0 Kudos

Hi April, when you say multi-line format, what do you mean?