Extending Dictionary Objects

Objectives

After completing this lesson, you will be able to:

  • Extend dictionary objects using append structures

Append Structures

You already learned that a database table definition in the ABAP dictionary corresponds to a physical table on the database. Changes to the dictionary object are conveyed to the database object during activation (ALTER TABLE) or through the database adjustment procedure.

Append Structures are a technique that make it possible to add fields to a database table without actually changing the table definition in the ABAP dictionary.

Let us consider a database table that is defined by a software provider, for example, SAP. A customer or partner wants to add fields to this database table.

Instead of adding the fields to the database table definition in the dictionary, they create an append structure. The append structure is a separate dictionary object, owned and maintained by the customer or partner. Technically, it is a structure type in the ABAP dictionary. However, it is linked to database table definition and defines additional fields for the related database table. When the append structure is activated, its components are added as fields to the table on the database.

You can say that the table on the database is defined by two dictionary objects: The database table definition and the append structure.

Note

One append structure belongs to exactly one database table . One database table, however, can have several append structures.

In ABAP Cloud, you can only create an append if the software provider released the table definition for extension.

But what happens if the software provider ships a new version of the database table definition?

Let us consider that in a future release, the database table will contain an additional field. The solution is simple: during the upgrade, the new field is simply added to the field catalog of the database table, using the ALTER TABLE statement. The different field sequence on the database and in the dictionary is not a problem for the ABAP environment.

Here is an example for an append structure.

The code on the left shows the definition of database table /DMO/AGENCY. The code on the right shows the definition of append structure Z00_EXT_AGENCY. The link between the two dictionary objects is established in the append structure by mentioning the database table after keyword EXTEND TYPE.

The append structure has one component zzcategory. It is added to the field list of database table /DMO/AGENCY.

There is a reason why the component of the append structure starts with "ZZ". Table fields and structure components starting with "ZZ" or "YY" lie in the customer namespace. SAP guarantees that tables shipped by SAP will never contain fields in the customer namespace. By choosing field names in the customer namespace, customers can avoid field name conflicts if SAP adds new fields to the target table.

The append technique not only works for database table definitions. You can also use append structures to add components to a structure type.

In this example, the append structure on the right extends dictionary structure /DMO/S_EXT_INCL_AGENCY with a field ZZCATEGORYZAG.

Extensibility Control for Dictionary Objects

To avoid later conflicts, the owner of a database table definition or structure type can restrict extensibility or even disallow it.

The software provider controls extensibility using the following subannotations of annotation @ABAPCatalog.enhancement:

category

Defines the enhancement category. The following values can be specified:

  • #NOT_CLASSIFIED - Not classified
  • #NOT_EXTENSIBLE - Cannot be enhanced
  • #EXTENSIBLE_CHARACTER - Can be enhanced (character-like)
  • #EXTENSIBLE_CHARACTER_NUMERIC - Can be enhanced (character-like or numeric)
  • #EXTENSIBLE_ANY - Can be enhanced (deep - only for structures)
fieldSuffix

Defines a 3-character element suffix. This suffix is to be used for all fields of an extension created by customers or partners. The purpose is to avoid field naming clashes.

quotaMaximumFields

Defines the maximum number of fields that can be appended to the corresponding object by customers and partners. In other words, it reserves a field count for customer and partner extensions.

quotaMaximumBytes

Defines the maximum byte capacity that can be appended to the corresponding object by customers and partners. In other words, it reserves a byte capacity for customer and partner extensions.

quotaShareCustomer and quotaSharePartner

Assigns a percentage of the defined field count and byte capacity to customer extensions and partner extensions. The customer quota share and the partner quota share must together add up to 100.

Note

For the complete documentation of extensibility annotations, refer to the ABAP keyword documentation.

SAP often uses extension control to enforce the use of extension includes.

Extension includes are specific structure types that are included in one or several database table definitions. If customers or partners want to add fields to the table, they have to create an append structure for this extension include rather than a direct append for the database table.

The main benefits are as follows:

  • The software provider can use the same extension include in several database table definitions and structure types. This ensures that additional fields are added to several tables in a consistent way.
  • The software provider can decide to release only the extension include and not the database table definition itself.

Let us have a look at an example for an indirect extension:

The append structure on the right does not extend data base table /DMO/AGENCY, directly. Instead, it extends structure type /DMO/S_EXT_INCL_AGENCY. As the structure is used as include structure in database table /DMO/AGENCY, any field added to the structure us also added to the database table.

Append Structure Creation

Creating an Append Structure

Play the video to see how to create an append structure.

How to Extend a Database Table Definition

Play the video to see how to extend a database table definition.

Log in to track your progress & complete quizzes