The SAP XCO library is a general-purpose ABAP library that provides an efficient ABAP development experience.
It provides tools for generating development objects programmatically by providing a hierarchy of APIs based on classes.
This blog post will learn more about this new efficient and more powerful XCO ABAP development library.
SAP XCO Library
The ABAP XCO (“Extension Components”) library is a general-purpose development library designed to make ABAP development as efficient as possible. The SAP XCO library is organized as a collection of independent modules.
There are several modules within the XCO library, each of which focuses on a different functional area. Every module exposes its public API through a particular class, called the API “class” of the module.
In each module, the API class serves as the point of entry to all offered functionality. The name of the API class starts with “XCO_CP_” (or) “XCO_KU_.”
History of SAP ABAP XCO Library
XCO library was initially introduced in SAP BTP ABAP Environment (aka Steampunk) 2005 and ABAP Platform on-premise S/4 HANA 2020.
With the 2008 release, the SAP XCO Library is now publicly available on the SAP Cloud Platform ABAP Environment (aka Steampunk).
Overview of XCO Modules
The library comprises three types of modules
- Cloud Platform(CP) edition
- Key User edition
- On-premise edition
1. Key User Extensibility XCO Modules:
Below are the 4 ABAP Key User XCO modules. The key user (KU) edition of the SAP XCO library provides a set of functions that support typical In-App Extensibility scenarios.
|API Class Name||Description|
|XCO_KU_JSON||It works with JSON data as simply as possible|
|XCO_KU_REGULAR_EXPRESSION||It works with POSIX and PCRE regular expressions in ABAP|
|XCO_KU_STRING||This API works with strings like splitting and joining|
|XCO_KU_UUID||It provides a simple way to translate between different UUID formats|
2. Cloud Platform(CP) XCO Modules:
Below is the list of XCO APIs available as part of the ABAP Cloud Platform edition.
|API Class Name||Description|
|XCO_CP_ABAP||It provides access to conceptual abstractions for classes and interfaces and representations of ABAP built-in and generic types.|
|XCO_CP_ABAP_DICTIONARY||It provides access to conceptual abstractions for ABAP Dictionary elements (Database tables, data elements, structures, table types, and domains) and representations of ABAP Dictionary built-in types and their corresponding reference types.|
|XCO_CP_ABAP_OBJECTS||It provides access to enumerations specific to ABAP Objects.|
|XCO_CP_ABAP_REPOSITORY||It provides APIs and abstractions for retrieving and filtering development objects of the ABAP Repository.|
|XCO_CP_ABAP_SQL||It provides methods for building ABAP SQL constraints to be used in conjunction with filtering functionality.|
|XCO_CP_DATA_DEFINITION||It provides access to enumerations and text attributes specific to CDS data definitions.|
|XCO_CP_DATA_ELEMENT||It provides access to text attributes specific to data elements|
|XCO_CP_DATABASE_TABLE||It provides access to database table-specific enumerations, e.g., the size category of a database table.|
|XCO_CP_DOMAIN||It provides access to text attributes specific to domains.|
|XCO_CP_DDL||It provides ways to build DDL (Data definition language) expressions to be used when generating DDLS objects.|
|XCO_CP_DCL||It provides ways to build DCL (Data control language) expressions to be used when generating DCLS objects|
|XCO_CP_CDS||It provides access to enumerations specific to the field of Core Data Services (CDS) and conceptual abstractions for behavior definitions, data definitions, metadata extensions, and CDS entities.|
|XCO_CP_CDS_ANNOTATION||It provides ways to build CDS annotation values when generating DDLS, DDLX, or SRVD objects.|
|XCO_CP_AMDP||It provides access to enumerations in the context of ABAP-managed database procedures.|
|XCO_CP_ARS||It provides standard abstractions in the context of the API Release (ARS) framework when programmatically setting or getting API states.|
|XCO_CP_BAL||It provides APIs for creating, deleting, and searching logs and standard abstractions for integrating logging functionality into the custom application logic.|
|XCO_CP_BEHAVIOR_DEFINITION||It provides access to enumerations specific to behavior definitions.|
|XCO_CP_BEHAVIOR_IMPLEMENTATION||It provides access to enumerations specific to behavior implementations.|
|XCO_CP_GENERATION||Provides access to the XCO Generation APIs, i.e., allows obtaining a generation environment that can be used to create PUT and DELETE operations.|
|XCO_CP_I18N||Provides access to the XCO I18N APIs, i.e., allows obtaining a domain, data element, data definition, and message class targets used to maintain language-dependent texts programmatically.|
|XCO_CP_JSON||Provides access to facilities used when working with JSON data in the context of the XCO standard library, such as the JSON builder or standard JSON transformations.|
|XCO_CP_MESSAGE||It provides access to enumerations specific to messages, such as the message type.|
|XCO_CP_METADATA_EXTENSION||It provides access to enumerations specific to metadata extensions.|
|XCO_CP_PACKAGE||It provides access to enumerations specific to packages.|
|XCO_CP_REGULAR_EXPRESSION||Provides access to abstractions used when working with regular expressions, such as different regular expression engines.|
|XCO_CP_SERVICE_BINDING||It provides access to enumerations specific to service bindings.|
|XCO_CP_SOFTWARE_COMPONENT||It provides access to enumerations specific to software components.|
|XCO_CP_STRING||It provides access to abstractions used when working with strings, such as string builders or standard compositions and decompositions.|
|XCO_CP_SYSTEM||It provides access to abstractions for system-wide entities such as software components or application components.|
|XCO_CP_TABLE||It provides access to enumerations specific to tables (i.e., structures and database tables).|
|XCO_CP_TABLE_TYPE||It provides access to enumerations specific to table types.|
|XCO_CP_TRANSPORT||It provides access to enumerations and abstractions specific to transports.|
|XCO_CP_UUID||It provides access to abstractions used when working with UUIDs, such as different UUID formats.|
3. ABAP On-premise XCO Modules
Below is the list of XCO modules we can use with on-premise S/4 HANA 2020. Most of the CP and on-premise edition APIs are similar.
|API Class Name||Description|
|XCO_ABAP_DICTIONARY||It provides access to conceptual abstractions for ABAP Dictionary elements (Database tables, data elements, structures, table types, and domains) and representations of ABAP Dictionary built-in types and their corresponding reference types.|
|XCO_ABAP_LANGUAGE_VERSION||It provides APIs for the ABAP language version.|
|XCO_ABAP_OBJECTS||It provides access to enumerations specific to ABAP Objects.|
|XCO_ABAP_REPOSITORY||It provides APIs and abstractions for retrieving and filtering development objects of the ABAP Repository.|
|XCO_ABAP_REPOSITORY_TD||It provides APIs for the Double Test framework|
|XCO_ABAP_SQL||It provides methods for building ABAP SQL constraints to be used in conjunction with filtering functionality.|
The RAP Generator
RAP Generator makes it easier for the developer to programmatically create the complete stack of objects needed to implement a RAP business object.
Now that we know how powerful ABAP development is, the XCO library, the famous RAP Generator by Andre Fischer, is based on this XCO framework.
Let’s write some ABAP code to create an ABAP repository object programmatically; SE11 Table using XCO Generation, a part of the XCO (“Extension Components”) ABAP development library.
Below is the sample code which creates a DDIC table using XCO APIs; we make it simple to understand.
CONSTANTS: co_package TYPE sxco_package VALUE 'ZDEMO'. DATA(lo_transport_target) = xco_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 the database table to the PUT operation. DATA(lo_database_table) = lo_put_operation->for-tabl-for-database_table->add_object( 'ZTBL_XCO_DEMO' )->set_package( co_package )->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. lo_put_operation->execute( ).
You will create the following database table (or their update for those that already exist) and their activation as one mass activation by executing this code.
Congrats!! You have successfully learned SAP XCO( “Extension Components” ).
- What is the SAP XCO Library?
- What are the different SAP XCO Modules and APIs?
- How to create, update and delete ABAP repository objects programmatically using XCO Library?