Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
patrick_winkler
Product and Topic Expert
Product and Topic Expert
781

Introduction

For a multi tenant application, system configuration data is stored in cross-client tables with delivery class "S". See also the multitenancy development guideline.
Read this blog post to learn how to maintain system configuration data with an executable class.
This blog is relevant for:

  • SAP BTP, ABAP Environment

Note: With ADT 3.40, you can also add the system table with object type = TABU to the transport request manually from the context menu of the Transport Organizer.

Example system table

You can use the following system table as an example:

@EndUserText.label : 'S table'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #S
@AbapCatalog.dataMaintenance : #ALLOWED
define table zstab {
  key name : abap.char(30) not null;
  value    : abap.char(30);
}

Executable class

You create an executable class that modifies the table data and records the changes in a workbench request.

CLASS zcl_option1 DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .
  PUBLIC SECTION.
    INTERFACES if_oo_adt_classrun .
ENDCLASS.

CLASS zcl_option1 IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
    DATA zstab_content TYPE TABLE OF zstab WITH EMPTY KEY.
    zstab_content = VALUE #( ( name = 'EEE' value = '555' ) ).
    MODIFY zstab FROM TABLE @zstab_content.
    DATA(transport_service) = cl_bcfg_cd_reuse_api_factory=>get_transport_service_instance(
       iv_objectname = 'ZSTAB'
       iv_objecttype = cl_bcfg_cd_reuse_api_factory=>simple_table ).
    TRY.
        transport_service->get_transport_recorder( )->add_tabu_content( zstab_content ).
        out->write( |Changes recorded in { transport_service->get_transport_request( )->get_task( ) }| ).
      CATCH cx_bcfg_transport_recorder
            cx_bcfg_transport_request INTO DATA(exc).
        out->write( exc->get_text( ) ).
    ENDTRY.
  ENDMETHOD.
ENDCLASS.

The transport API automatically determines a workbench request. If none is found, a new one is created automatically.

You have the option to set a specific workbench request. However, this is only working if the workbench request has the attribute SAP_CUS_TRANSPORT_CATEGORY set to DEFAULT_CUSY or MANUAL_CUSY:

transport_service->get_transport_request( )->set_transport( <transport> ).
transport_service->get_transport_recorder( )->add_tabu_content( zstab_content ).

You can also use the XCO API to programmatically determine a workbench request:

"Create the filters to be used for the transport query.
"Additional filters can be added
DATA(request_type_filter) = xco_cp_transport=>filter->request_type( xco_cp_transport=>type->workbench_request ).
DATA(status_filter) = xco_cp_transport=>filter->status( xco_cp_transport=>status->modifiable ).
DATA(attribute_filter) = xco_cp_transport=>filter->attribute(
  io_name_constraint = xco_cp_abap_sql=>constraint->equal( 'SAP_CUS_TRANSPORT_CATEGORY' )
  io_value_constraint = xco_cp_abap_sql=>constraint->between( iv_low = 'DEFAULT_CUSY' iv_high = 'MANUAL_CUSY' )
).
"When querying transports via XCO_CP_CTS=>TRANSPORTS, both transport requests
"and tasks are retrieved. The "request" resolution applied below groups the retrieved tasks
"and requests so that only the list of transport requests is returned.
DATA(transports) = xco_cp_cts=>transports->where( VALUE #(
    ( attribute_filter )
    ( request_type_filter )
    ( status_filter )
  ) )->resolve( xco_cp_transport=>resolution->request ).