DATA(lo_package) = xco_cp_abap_repository=>package->for( 'Z_MY_PACKAGE' ).
DATA(lv_transport_target) = lo_package->read(
)-property-transport_layer->get_transport_target(
)->value.
DATA(lo_transport_request) = xco_cp_cts=>transports->workbench( lv_transport_target
)->create_request( 'My generated transport request' ).DATA(lo_put_operation) = xco_cp_generation=>environment->dev_system( lo_transport_request->value
)->create_put_operation( ).
" Add the database table to the PUT operation.
DATA(lo_database_table) = lo_put_operation->for-tabl-for-database_table->add_object( 'ZMY_DBT'
)->set_package( lo_package->name
)->create_form_specification( ).
lo_database_table->set_short_description( 'My generated database table' ).
lo_database_table->set_delivery_class( xco_cp_database_table=>delivery_class->l ).
lo_database_table->set_data_maintenance( xco_cp_database_table=>data_maintenance->allowed ).
lo_database_table->add_field( 'KEY_FIELD'
)->set_key_indicator(
)->set_type( xco_cp_abap_dictionary=>built_in_type->char( 30 )
)->set_not_null( ).
" Further fields (including information about foreign keys, search helps, etc.) can be
" added following the same pattern.
" Add the data definition for the CDS view entity to the PUT operation
DATA(lo_data_definition) = lo_put_operation->for-ddls->add_object( 'ZMY_VIEW_ENTITY'
)->set_package( lo_package->name
)->create_form_specification( ).
lo_data_definition->set_short_description( 'My generated view entity' ).
DATA(lo_view_entity) = lo_data_definition->add_view_entity( ).
lo_view_entity->data_source->set_view_entity( 'ZMY_DBT' ).
DATA(lo_key_field) = lo_view_entity->add_field( xco_cp_ddl=>field( 'KEY_FIELD' ) ).
lo_key_field->set_key( )->set_alias( 'keyField' ).
lo_key_field->add_annotation( 'EndUserText.label' )->value->build( )->add_string( 'Key field' ).
lo_put_operation->execute( ).
Generated database table

Generated view entity
DATA(lo_name_constraint) = xco_cp_abap_sql=>constraint->contains_pattern( 'ZMY_%' ).
DATA(lo_name_filter) = xco_cp_abap_repository=>object_name->get_filter( lo_name_constraint ).
" This query will retrieve all database tables whose name starts with ZMY_ that are contained
" in the package denoted by LO_PACKAGE.
DATA(lt_database_tables) = xco_cp_abap_repository=>objects->tabl->database_tables->where( VALUE #(
( lo_name_filter )
) )->in( lo_package )->get( ).
LOOP AT lt_database_tables INTO DATA(lo_database_table).
" LS_CONTENT is a structure comprised of the header attributes of the
" database table such as the delivery class or the technical settings.
DATA(ls_content) = lo_database_table->content( )->get( ).
" LT_FIELDS is a table of objects representing the fields of the database
" table. As with the header information, the field objects can be used to
" access the content of the field (e.g. its type or foreign key).
DATA(lt_fields) = lo_database_table->fields->all->get( ).
ENDLOOP.DATA(lt_transport_tasks) = lo_transport_request->get_tasks( ).
LOOP AT lt_transport_tasks INTO DATA(lo_transport_task).
IF lo_transport_task->get_status( ) EQ xco_cp_transport=>status->modifiable.
lo_transport_task->release( ).
ENDIF.
ENDLOOP.
lo_transport_request->release( ).You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 4246 | |
| 3357 | |
| 2603 | |
| 2153 | |
| 1983 | |
| 1255 | |
| 1164 | |
| 1122 | |
| 1100 |