This is a test message to test the length of the message box.
Login

Script: XCO Libraries - Quick Introduction [005]

193

In this episode, we'll give you a quick introduction to XCO Libraries. We'll look at their availability, discuss their design and usage, and offer other useful tips. This is a short version of the ABAPConf 2025 session "Behind XCO and much further".



In this episode, we'll take a brief look at the XCO libraries. If you want to see the full version, you should check out the ABAPConf 2025 recording. We'll give a brief introduction to the topic and then look at the libraries in detail. You'll find further links to this video in the description.

 

Introduction

XCO stands for Extension Components and describes a collection of libraries for using various functions in the system. In the past, there were different function modules for different functions, such as converting from String to XString, which had different interfaces and perhaps also functioned differently. The goal of XCO is to standardize interfaces to one or a maximum of two objects that perform similar or identical functions.

In this overview, we'll take a look at where you can find the XCO libraries. On the left, you can see the SAP S/4 HANA Cloud System, but this could also be an on-premises system. On the right, you'll find Side-by-Side Extensibility. The XCO library is therefore available as a local SAP API or side-by-side in the ABAP environment, where it contains the most current version.

 

Overview

If you look at the objects, you will initially be confused, as there are a very large number of XCO classes, interfaces and objects. Therefore, here is a brief overview of the three actual versions that exist. The first version is Standard ABAP, but also called classic ABAP. In this example, we see an overview of the XCO class. This contains numerous APIs and is therefore the largest class in terms of functionality. The class contains numerous attributes and methods, each defined as static. The second class is XCO_CP. As the name suggests, it is primarily available in the cloud platform, meaning it is ABAP Cloud ready. The first noticeable difference is that there are two fewer methods: in this case, the integer object and T100_DYN_MSG. Objects with this name should also have a C1 release contract. The third version is Key User Apps, or KU for short. As you can see, additional methods and attributes are missing here. The Key User classes are therefore primarily released for Key User Extensibility and cannot be used in ABAP Cloud. Classes beginning with XCO are therefore important in all three cases.

If you want to get an overview in the ABAP Development Tools, you can create a new ABAP Repository Tree. To do this, we define the object pattern according to the XCO star and set the type to class. If we then sort all classes by API status, we will see all libraries for the corresponding language versions at the end and have a good first introduction.

How do we use the XCO libraries? Here's a first example: In this case, we create a string object using the XCO_CP class and pass our test string to the method; in this case, we receive a string object back. The various methods of the class are essentially factory methods, meaning the methods return a new object. In the next case, we can then directly call other methods of the object, thus creating a chain of calls. This is the Fluent Interface Pattern. We can now call additional methods, such as Append, to append another substring. Finally, we call Split, but instead of receiving a String object, we receive a Strings object, a table of different strings. If we then want to access the contents of the object, we usually use the Value attribute, which in this case returns a String table. Here is the complete statement again without the XCO component. Our result would be in the Split variable at the end.

It's a bit more complicated, however, if we are looking for a specific format option, for example. In this example, we want to format a date and are looking for the appropriate format for the date. Since we have the interface information here, we can find the corresponding types using the type hierarchy. For example, let's look at the type for the ABAP format. Unfortunately, it's set to CREATE PRIVATE, and there's no public attribute to create this format. However, we see a global friend with the corresponding factory, which means we'll take a look at the factory in the next step. This is also set to CREATE PRIVATE, but again has a global friend. So we navigate to the next class. In XCO_CP_TIME, we find a public attribute called Format. If we look further down in the class constructor, we see that the factory is created accordingly when the object is called. So, we've finally found the appropriate class. We can then create an instance using the format attribute and find the ABAP format for formatting and output.

What about catching exceptions? In most cases, the framework already handles catching exceptions and wraps them in NO_CHECK exceptions. For example, if you remember the use of the UUID, we usually have to catch the exception if we want to create a new UUID. However, since an error when generating the ID is very rare, we avoid catching the exception and thus have a shorter call. If an exception were to occur, it would be triggered and cause our program to crash, which in this case would also prevent more serious errors.

But what about the libraries? What different libraries are there? Most developers who think of XCO will first think of object generation. However, there is also an information system with which you can obtain further information about classes and other objects, such as the contents of methods or specific definitions. There is also a specific class runner. Unlike the classic version, this can, for example, catch exceptions and easily output various XCO objects. There is a specific Excel component. This can read and create Excel files, and the latest version already has various formatting options. Overall, however, the Excel component is not as comprehensive as, for example, the open source project ABAP2XLSX. There is also a library for formatting JSON and a library for accessing various system information, such as the current date or the call stack. As already mentioned, there is also a library for generating UUIDs, for handling strings and XStrings, and for processing messages. However, this is only a rough overview of the various libraries. There are many more libraries to explore. You can find a link to a more extensive overview in the video description.

 

Conclusion

This was a rough overview of the XCO libraries and how you can use them effectively in your everyday work. Finally, we want to summarize that the XCO libraries are difficult to learn at first, especially if you come from a classical development background. Understanding the different types of formatting and relationships requires familiarizing yourself with the libraries. One advantage of the XCO libraries is that they are available across all platforms, regardless of whether it is a cloud edition or on-premises. One open request for SAP is to expand the libraries and provide missing functions. For example, there isn't an information object for all object types to better analyze the types and objects. Furthermore, the JSON library, for example, has problems converting Boolean values.

Therefore, my advice to you is to try out the new libraries and use them in your everyday life. I hope you learned something from it and see you next time.

 

YouTube
Video


Included topics:
YouTubeScriptXCO Library
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


Script: Recycling-Heroes - Software Components [009]

Category - YouTube

In this episode, we'll set up the software components for our project, define the package structure and different sections, and synchronize the project with Git. This allows you to keep track of the current status while working on the project at the same time.

07/20/2025

Script: Introduction to Recycling-Heroes [008]

Category - YouTube

What do the Recycling-Heroes actually do, and what do we have planned for them? In this episode, we take a look at the plan, the data model, and the background of the company.

07/13/2025

Script: OData Batch Creator [007]

Category - YouTube

Want to create and test batch requests in OData easily and without headaches? Without knowing the rules, it's going to be difficult. But with this little tool, it should be no problem in the future.

07/06/2025

Script: ABAP Tools - Debugging for Beginners [006]

Category - YouTube

The ABAP Development Tools debugger is already a powerful tool, but is avoided by many ABAP developers. In this episode, we'll look at its configuration and provide a brief introduction to debugging.

06/29/2025

Script: The Matrix for ABAP [004]

Category - YouTube

The ABAP Feature Matrix is designed to give you a simple overview of the various ABAP features available for each release. We'll look at the different system types and versions and give you a brief tour of the tool.

06/01/2025