2022 Sep 11 2:30 PM
Hi guys,
I loop into a table and i want to concatenate that data into a string.
LOOP AT lv_int ASSIGNING FIELD-SYMBOL(<fs_int>) .
CONCATENATE <fs_int>
INTO gv_orginal_string
separated by gv_comma_separator .
WRITE : / <fs_int> .
ENDLOOP.
I have the following error :
"Unable to interpret <fs_int>. Possible cause of error include incorrect spellings or comma errors.
what did i do wrong...
Thanks you...
Hi guys,
I loop into a table and i want to concatenate that data into a string.
LOOP AT lv_int ASSIGNING FIELD-SYMBOL(<fs_int>) .
CONCATENATE <fs_int>
INTO gv_orginal_string
separated by gv_comma_separator .
WRITE : / <fs_int> .
ENDLOOP.
I have the following error :
"Unable to interpret <fs_int>. Possible cause of error include incorrect spellings or comma errors.
what did i do wrong...
Thanks you...
2022 Sep 11 3:58 PM
Hi fotso
You have not selected the field that you want to concatenate the value of. You cannot use <fs_int> as it will have a structure type same as the internal table lv_int. (Do learn naming convention as well and try naming internal tables as lt_int or it_int instead of lv_int).Make the following changes in your logic.LOOP AT lv_int ASSIGNING FIELD-SYMBOL(<fs_int>).
CONCATENATE gv_original_string <fs_int>-field_name
INTO gv_orginal_string
separated by gv_comma_separator.
WRITE : / <fs_int>.
ENDLOOP.
Thanks 🙂
2022 Sep 11 4:16 PM
Concatenate is to concatenate at least 2 fields. You have indicated only 1 field.
Note: I prefer any of these 2 syntaxes rather than using CONCATENATE:
gv_orginal_string = |{ gv_orginal_string },{ <fs_int> }|.
gv_orginal_string = gv_orginal_string && ',' && <fs_int>.
2022 Sep 13 8:02 AM
gv_orginal_string = concat_lines_of( table = lt_int sep = ',' ).
2022 Sep 13 9:26 AM
DATA:
lr_strucdescr TYPE REF TO cl_abap_structdescr,
s_flight TYPE sflight,
v_output TYPE string.
s_flight-carrid = '123'.
s_flight-currency = 'USD'.
s_flight-fldate = sy-datum.
lr_strucdescr ?= cl_abap_typedescr=>describe_by_data( s_flight ).
LOOP AT lr_strucdescr->components INTO DATA(s_components).
ASSIGN COMPONENT s_components-name OF STRUCTURE s_flight TO FIELD-SYMBOL(<fs_field>).
IF v_output IS INITIAL.
v_output = <fs_field>.
ELSE.
v_output = |{ v_output },{ <fs_field> }|.
ENDIF.
ENDLOOP.
cl_demo_output=>display( v_output ).
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |