populate_schema_struct

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


  METHOD populate_schema_struct.

    LOOP AT it_components REFERENCE INTO DATA(ls_components).
      DATA(lv_index) = sy-tabix.
      CASE ls_components->type->kind.
        WHEN cl_abap_structdescr=>kind_elem.
          ASSIGN COMPONENT lv_index OF STRUCTURE cs_schema TO FIELD-SYMBOL(<ls_comp_outer>).
          ASSIGN COMPONENT 1 OF STRUCTURE <ls_comp_outer> TO FIELD-SYMBOL(<lv_comp_inner>).

          <lv_comp_inner> = type_kind_to_swagger( ls_components->type->type_kind ).

        WHEN cl_abap_structdescr=>kind_struct.

          ASSIGN COMPONENT ls_components->name OF STRUCTURE cs_schema TO FIELD-SYMBOL(<ls_object_struc_outer>).

          ASSIGN COMPONENT 'TYPE' OF STRUCTURE <ls_object_struc_outer> TO FIELD-SYMBOL(<ls_object_struc_type>).
          <ls_object_struc_type> = 'OBJECT'.
          ASSIGN COMPONENT 'PROPERTIES' OF STRUCTURE <ls_object_struc_outer> TO FIELD-SYMBOL(<ls_object_struc_properties>).

          populate_schema_struct( EXPORTING it_components = CAST cl_abap_structdescr( ls_components->type )->get_components( )
                                  CHANGING  cs_schema = <ls_object_struc_properties> ).

        WHEN cl_abap_structdescr=>kind_table.

          ASSIGN COMPONENT ls_components->name OF STRUCTURE cs_schema TO FIELD-SYMBOL(<ls_array_struc_outer>).
          ASSIGN COMPONENT 'TYPE' OF STRUCTURE <ls_array_struc_outer> TO FIELD-SYMBOL(<ls_array_struc_outer_type>).
          <ls_array_struc_outer_type> = 'ARRAY'.
          ASSIGN COMPONENT 'ITEMS' OF STRUCTURE <ls_array_struc_outer> TO FIELD-SYMBOL(<ls_array_struc_items>).
          ASSIGN COMPONENT 'TYPE' OF STRUCTURE <ls_array_struc_items> TO FIELD-SYMBOL(<ls_array_struc_items_type>).
          <ls_array_struc_items_type> = 'OBJECT'.
          ASSIGN COMPONENT 'PROPERTIES' OF STRUCTURE <ls_array_struc_items> TO FIELD-SYMBOL(<ls_array_struc_properties>).


          populate_schema_struct( EXPORTING it_components = CAST cl_abap_structdescr(
                        CAST cl_abap_tabledescr( ls_components->type
                        )->get_table_line_type( ) )->get_components( )
                           CHANGING  cs_schema = <ls_array_struc_properties> ).

        WHEN OTHERS.
      ENDCASE.

    ENDLOOP.