Conversion exception when working with constructor expressions

I am working on a routine that moves string strings (in this case fui_elements) into an unknown type structure ( fcwa_struct).

DATA(li_temp) = ... "fill assignment table here

LOOP AT fui_elements ASSIGNING FIELD-SYMBOL(<lfs_element>).

    ASSIGN COMPONENT li_temp[ sy-tabix ] OF STRUCTURE fcwa_struct 
        TO FIELD-SYMBOL(<lfs_field>).

    IF sy-subrc <> 0.
        "somethings wrong with the fui_elements data
    ENDIF.
    <lfs_field> = <lfs_element>.
ENDLOOP.

If table i_field_customizing( STANDARD TABLE OF string) is not initial, I want to use its values.

Otherwise, I want to create an integer table (so that the loop works equally often, regardless of the values ​​of the table). Here lw_maxis the number of fields that the imported structure has:

DATA(li_temp) = COND #( WHEN i_field_customizing[] IS INITIAL
                        THEN VALUE t_integer_tt( FOR X = 1 
                                                 THEN X + 1 
                                                 WHILE X <= lw_max 
                                                 ( X ) )
                        ELSE i_field_customizing ).

But when I run the report with the i_field_customizingfollowing:

DATA(i_field_customizing) = VALUE t_string_tt( ( `KUNNR` ) ( `NAME1` ) ).

I get this exception in the line where I am trying to build li_temp:

CX_SY_CONVERSION_NO_NUMBER (KUNNR cannot be interpreted as a number)


, COND . - , ?

+4
1

, , , COND , .

. . , , , THEN. , , THEN ELSE, , , , , ASSIGN COMPONENT .

ELSE , .

DATA(li_temp) = COND #( WHEN i_field_customizing IS INITIAL
                        THEN VALUE t_integer_tt( ( 1 ) ( 2 ) )
                        ELSE CAST t_string_tt( REF #( i_field_customizing ) )->* ).

REF TO DATA, STANDARD TABLE.

REPORT zzy.

CLASS lcl_main DEFINITION FINAL CREATE PRIVATE.
  PUBLIC SECTION.
    CLASS-METHODS:
      main.
ENDCLASS.

CLASS lcl_main IMPLEMENTATION.
  METHOD main.
    TYPES:
      t_integer_tt TYPE STANDARD TABLE OF i WITH EMPTY KEY,
      t_string_tt TYPE STANDARD TABLE OF string WITH EMPTY KEY.
    FIELD-SYMBOLS:
      <fs_table> TYPE STANDARD TABLE.
    DATA: BEGIN OF l_str,
      kunnr TYPE kunnr,
      name1 TYPE name1,
      END OF l_str.

*      DATA(i_field_customizing) = VALUE t_string_tt( ( `KUNNR` ) ( `NAME1` ) ).
      DATA(i_field_customizing) = VALUE t_string_tt( ).

      DATA(li_temp) = COND #( WHEN i_field_customizing IS INITIAL
                              THEN CAST data( NEW t_integer_tt( ( 1 ) ( 2 ) ) )
                              ELSE CAST data( REF #( i_field_customizing ) ) ).

      ASSIGN li_temp->* TO <fs_table>.

      LOOP AT <fs_table> ASSIGNING FIELD-SYMBOL(<fs_temp>).
        ASSIGN COMPONENT <fs_temp> OF STRUCTURE l_str TO FIELD-SYMBOL(<fs_field>).
      ENDLOOP.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  lcl_main=>main( ).
+4

All Articles