2022 Dec 12 1:21 AM
Hi all;
I want to convert an internal table to string, but I can't find one way to realize it.
By the way, the table more than on field.
Like this
2022 Dec 12 7:15 AM
data: l_sep,
l_result type string.
LOOP AT lt_data assinging field-symbol(<wa_data>).
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <wa_data> TO field-symbol(<fs>).
IF sy-subrc <> 0.
EXIT.
ENDIF.
l_result = |{ l_result }{ l_sep }{ <fs> }|.
l_sep = ','.
ENDDO.
ENDLOOP.
2022 Dec 12 6:54 AM
Concatenate fields str1 to str14 together, then use REDUCE to concatenate each record in the internal table, with whatever separator you choose.
It's a strange structure to have. It has no benefit that I can see over simple using a string_table type.
2022 Dec 12 7:15 AM
data: l_sep,
l_result type string.
LOOP AT lt_data assinging field-symbol(<wa_data>).
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <wa_data> TO field-symbol(<fs>).
IF sy-subrc <> 0.
EXIT.
ENDIF.
l_result = |{ l_result }{ l_sep }{ <fs> }|.
l_sep = ','.
ENDDO.
ENDLOOP.
2022 Dec 13 12:33 AM
2022 Dec 12 7:58 AM
Please post the code as text instead of image, so that one can easily answer by copying your code in order to complete it.
2022 Dec 12 8:02 AM
Many ways. I would opt for REDUCE. But just to simplify my answer I show you how to concatenate strings:
DATA(concat_all_lines) = ``.
LOOP AT lt_mail REFERENCE INTO DATA(r).
DATA(concat_one_line) = r-str1 && r-str2 && r-str3 && r-str4 && r-str5 && r-str6 && r-str7
&& r-str8 && r-str9 && r-str10 && r-str11 && r-str12 && r-str13 && r-str14.
concat_all_lines = concat_all_lines && concat_one_line.
ENDLOOP.
2022 Dec 13 12:35 AM
2022 Dec 13 9:09 AM
Or something like that:
CONCATENATE LINES OF VALUE string_t( FOR <s> IN lt_mail ( <s>-str1 && <s>-str2 && <s>-str3 ) ) INTO DATA(result).
2022 Dec 14 12:35 AM