Most of the time we-developers- start developing ABAP programs by creating domains, data elements that use them, and tables that use these data elements. Sometimes this number gets too big.
In this example I will show you simply copying an existing domain using the XCO library, then using this domain in a data element, and then 🙂 using this data element in a table.
Thanks Andre Fischer to has proven us how this simple example can be turned into a great product and application.
Check out RAP Generator.
"The XCO library is organized as a collection of (largely) independent modules (corresponding to ABAP packages). The public API of each module is exposed via a special class, called the API “class” of the module. It is distinguished from all other XCO classes and interfaces in that it starts with “XCO_CP_”. The API class acts as the single point of entry for the functionality offered by a given module."
"Starting with the API class, code completion can be used to easily discover the scope of a given module."
CLASS zcl_generate_dictionary IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
CONSTANTS:
co_package TYPE sxco_package VALUE 'ZXCO_EXAMPLES'.
DATA(lo_transport_target) = xco_cp_abap_repository=>package->for( co_package
)->read(
)-property-transport_layer->get_transport_target( ).
"Create a TR
DATA(lo_transport_request) = xco_cp_cts=>transports->workbench( lo_transport_target->value
)->create_request( 'Generated transport request' ).
DATA(lo_put_operation) = xco_cp_generation=>environment->dev_system( lo_transport_request->value
)->create_put_operation( ).
"Add copied domains to the PUT operation.
DATA(lo_template) = xco_cp_generation_doma=>template->for_domain(
iv_name = '/DMO/CUSTOMER_ID'
io_read_state = xco_cp_abap_dictionary=>object_read_state->active_version
).
lo_put_operation->for-doma->add_object( 'ZCOPIEDID_DOMAIN'
)->set_package( 'ZXCO_EXAMPLES'
)->set_template( lo_template ).
"Add data elements(with copied domain) to the PUT operation.
DATA(lo_specification) = lo_put_operation->for-dtel->add_object( 'ZDATA_ELEMENT'
)->set_package( 'ZXCO_EXAMPLES'
)->create_form_specification( ).
lo_specification->set_short_description( 'My generated data element with XCO' ).
lo_specification->set_data_type( xco_cp_abap_dictionary=>domain( 'ZCOPIEDID_DOMAIN' ) ).
lo_specification->field_label-short->set_text( 'ID' ).
lo_specification->field_label-medium->set_text( 'New ID' ).
lo_specification->field_label-long->set_text( 'New User identifier' ).
lo_specification->field_label-heading->set_text( 'New User identifier' ).
" Add the database table and data elements to the PUT operation.
DATA(lo_database_table) = lo_put_operation->for-tabl-for-database_table->add_object( 'ZTBL_XCO_EXAMPLE'
)->set_package( co_package
)->create_form_specification( ).
lo_database_table->set_short_description( 'My generated database table with XCO' ).
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( 'MANDT'
)->set_key_indicator(
)->set_type( xco_cp_abap_dictionary=>built_in_type->clnt
)->set_not_null( ).
lo_database_table->add_field( 'ID'
)->set_key_indicator(
)->set_type( xco_cp_abap_dictionary=>data_element( 'ZDATA_ELEMENT' )
)->set_not_null( ).
" Further fields (including information about foreign keys, search helps, etc.) can be
" added following the same pattern.
lo_put_operation->execute( ).
ENDMETHOD.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |