PUT_DDLS

in abap-sdk/ZGOOG_SDK_UTILITIES/zgoog_bq_read_odata/zcl_bq_table_read_odata_gen.clas.abap [0:0]


  METHOD PUT_DDLS.
**********************************************************************
*  Copyright 2024 Google LLC                                         *
*                                                                    *
*  Licensed under the Apache License, Version 2.0 (the "License");   *
*  you may not use this file except in compliance with the License.  *
*  You may obtain a copy of the License at                           *
*      https://www.apache.org/licenses/LICENSE-2.0                   *
*  Unless required by applicable law or agreed to in writing,        *
*  software distributed under the License is distributed on an       *
*  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,      *
*  either express or implied.                                        *
*  See the License for the specific language governing permissions   *
*  and limitations under the License.                                *
**********************************************************************

    DATA(lo_form_specification) = mo_put_operation->for-ddls->add_object( p_view
      )->set_package( p_devc
      )->create_form_specification( ).

    DATA(lo_custom_entity) = lo_form_specification->set_short_description( |CDS View for BQ Table { is_bq_table-id }|
      )->add_custom_entity( ).

    lo_custom_entity->add_annotation( 'ObjectModel.query.implementedBy' )->value->build( )->add_string( |ABAP:{ p_qpcls }| ).
    lo_custom_entity->add_annotation( 'EndUserText.label' )->value->build( )->add_string( is_bq_table-id ).

    LOOP AT is_bq_table-schema-fields REFERENCE INTO DATA(ls_field).
      DATA(lv_field_tabix) = sy-tabix.
      DATA(lo_id_field) = lo_custom_entity->add_field( xco_cp_ddl=>field( CONV #( ls_field->name ) ) ).
      IF lv_field_tabix <= p_keys.
        lo_id_field->set_key( ).
      ENDIF.
      lo_id_field->set_type(
         COND #( WHEN p_strg IS INITIAL
                  THEN get_data_type( ls_field->type )
                 ELSE xco_cp_abap_dictionary=>built_in_type->string( 0 ) ) ).
      lo_id_field->add_annotation( 'EndUserText.label' )->value->build( )->add_string( ls_field->description ).
      lo_id_field->add_annotation( 'UI.lineItem' )->value->build(
        )->begin_array(
          )->begin_record(
            )->add_member( 'label' )->add_string( ls_field->description
          )->end_record(
        )->end_array( ).

    ENDLOOP.