construct_schema_struct

in src/zgoog_i_demo_struct_output_imp.prog.abap [0:0]


  METHOD construct_schema_struct.

    LOOP AT it_components REFERENCE INTO DATA(ls_components).

      CASE ls_components->type->kind.
        WHEN cl_abap_structdescr=>kind_elem.
          DATA(lo_property_inner_field) =
            cl_abap_structdescr=>get(
              VALUE #(
                ( name = 'TYPE' type = cl_abap_elemdescr=>get_string( ) ) ) ).

          APPEND VALUE #( name = ls_components->name
                          type = lo_property_inner_field )
                          TO ct_components.

        WHEN cl_abap_structdescr=>kind_struct.

          DATA: lt_struct_components TYPE abap_component_tab.

          construct_schema_struct(
              EXPORTING it_components = CAST cl_abap_structdescr( ls_components->type )->get_components( )
              CHANGING ct_components = lt_struct_components ).

          APPEND VALUE #( name = ls_components->name
                     type = cl_abap_structdescr=>get( VALUE #(
                         ( name = 'TYPE' type = cl_abap_elemdescr=>get_string( ) )
                         ( name = 'PROPERTIES' type = cl_abap_structdescr=>get( lt_struct_components ) ) ) ) )
            TO ct_components.

        WHEN cl_abap_structdescr=>kind_table.

          DATA: lt_table_components TYPE abap_component_tab.

          construct_schema_struct(
              EXPORTING it_components =
                     CAST cl_abap_structdescr(
                        CAST cl_abap_tabledescr( ls_components->type
                        )->get_table_line_type( ) )->get_components( )
              CHANGING ct_components = lt_table_components ).

          APPEND VALUE #( name = ls_components->name
                          type = cl_abap_structdescr=>get( VALUE #(
                           ( name = 'TYPE' type = cl_abap_elemdescr=>get_string( ) )
                           ( name = 'ITEMS' type = cl_abap_structdescr=>get( VALUE #(
                              ( name = 'TYPE' type = cl_abap_elemdescr=>get_string( ) )
                              ( name = 'PROPERTIES' type = cl_abap_structdescr=>get( lt_table_components ) ) ) ) ) ) ) )
                 TO ct_components.

        WHEN OTHERS.
      ENDCASE.

    ENDLOOP.