Extend Released Data Sources by Database Fields That Are Not Exposed
- What are the 3 different ways to extend a data source
- How to identify the 3 cases you must follow
- How to extend a data source which is key user data source extensible (case 1)
- How to extend a data source which is released for extend (case 2)
- How to extend a data source that is not released for extend (case 3)
Prerequisites
- You have a license for an SAP S/4HANA or SAP S/4HANA Cloud, private edition release 2023 (both referred to as SAP S/4HANA from now on)
- You have a user in the system with full development authorizations and business role
SAP_BR_SALES_MANAGER - You are connected to your SAP S/4HANA system in ABAP Development Tools for Eclipse (ADT)
- You understand the Clean Core Extensibility Guide, see SAP blog ABAP Extensibility Guide – Clean Core for SAP S/4HANA Cloud - August 2025 Update
- You have set up developer extensibility as described in the official documentation Set Up Developer Extensibility. In particular: the
ZLOCALstructure package is available. - For productive use, you would develop your data source consumption in a development package below the productive structure package
ZCUSTOM_DEVELOPMENT(ABAP for Cloud Development Language Version, ABAP Cloud Development) in your SAP S/4HANA system as suggested in the Developer Extensibility guidelines to Create Structure Package. Extensions you would develop in a dedicated development package of software componentHOME(Standard ABAP Language Version, Custom Wrapper), for instance below structure packageZAPI_ENABLEMENT. For the scope of this tutorial, we follow a simplified approach using local development packagesZMYLOCALwithin structure packageZLOCALand$TMPrather than productive packages.
We suggest following this tutorial using a Fully-Activated Appliance in SAP Cloud Appliance Library for an easy start without the need for system setup, as the
ZLOCALstructure package is automatically available.
Additional info
Tutorial last updated with SAP S/4HANA release 2023 FPS03
- Step 1
Data sources that you want to use in cloud development (ABAP Cloud Development) need to have API State: Use System-Internally (Contract C1): Use in Cloud Development: Yes. This information can be found in the object’s properties in ADT as in this example for data definition
I_SalesOrder.
See also the documentation: SAP - ABAP Development Tools: User Guide > Released APIs > Use System-Internally (C1)
- Step 2
To test the consumption of the data source from ABAP Cloud Development we call it in a
classrun.-
In package
ZMYLOCALcreate an ABAP class with nameZCL_USE_EXTENDED_DDLSthat is implementing interfaceIF_OO_ADT_CLASSRUNand give the descriptionclass to test calling extended data sources.
-
Implement the method
mainof the interface to read the data source. In this example, the data sourceI_SalesOrderis protected but allows privileged access, make use of it, as shown here:ABAPCopyMETHOD if_oo_adt_classrun~main. out->write( |\nRead I_SalesOrder| ). SELECT FROM I_SalesOrder WITH PRIVILEGED ACCESS FIELDS SalesOrder, CreationDate INTO TABLE @DATA(lt_data) UP TO 5 ROWS. out->write( lt_data ). ENDMETHOD. -
Save and activate the class.
-
Run the class as ABAP Application (Console) (quickest via
F9). -
In the output you can see data for the selected fields:

-
- Step 3
It can happen that you might not find the database field you’re looking for immediately. In this example, we use example field
kdgrpin data sourceI_SalesOrder:
This could be caused by the data source referring to it over an association and/or with an alias name. To exclude this possibility, check in ADT if any of the referenced data sources expose the database field over an association and/or with an alias name.
Have a look into the base data source
I_SalesDocumentof the data source definitionI_SalesOrder:

This reveals that the field
kdgrpis indeed exposed with an alias, namelyCustomerGroup.Once you know the right name to access the field, the code completion in ADT will find it too, and it will show the database name.

Next, we have an example of a data source being referenced via an association. Open data source
I_GLAccountLineItem. You will find that it associates data sourceI_CompanyCodewhich itself exposes the fieldland1of database tablet001with aliasCountry.

Once you know the association and name to access the field, the code completion in ADT will find it too and show the database name.

If neither an association and/or an alias name exposes the field, you must extend the data source. Be aware that this referencing can happen through a huge hierarchy of data source definitions.
- Step 4
Find out the best of three ways to extend your data source. The three approaches are sorted from simplest to most complex and should be processed in that order if you want to identify the best approach for a data source you want to extend. For an ideal learning experience, please follow all cases.
A data source can be:
-
Case 1: Key User Data Source Extensible
The simplest case to extend a data source is if it’s enabled for data source extensibility within key user extensibility. This is the case if the data source can be found in the Custom Fields app > Data Source Extensions.
-
Launch the Custom Fields app in the SAP Fiori Launchpad.
-
Switch to the tab Data Source Extensions.
-
Start creating a new data source extension, use the data source value help and search
I_GLAccountLineItem. If it’s found it’s key user data source extensible
In this case, the solution is to create a data source extension via key user app directly in ABAP Cloud Development. This will be shown in Step 5: Case 1 - The Data Source is Key User Data Source Extensible (ABAP Cloud Development).
-
-
Case 2: Released for Extend (C0 contract, but not key user data source extensible)
If the data source is not enabled for key user data source extensibility, but is released for EXTEND (Contract C0) for use in cloud development or key user apps, then you can add the missing database field to the data source by creating a corresponding extension field from ADT in a Custom Wrapper using classic extensibility.
You can check if the data source is released for extend at the API state of a data source in ADT - as for
I_SalesOrder.Go to its properties and open API State.

There, you can see if the data source is released for EXTEND (Contract C0) for use in cloud development or key user apps. If at least one is true, then the data source associates a so-called extension data source.
The solution is to create an extension for the extension data source and add this as extension to the actual data source in ADT using classic extensibility. This will be shown in Step 6: Case 2.1 - The Data Source is Released for Extend (Custom Wrapper) and following steps for case 2.
If you want to freely browse through data sources released for extend, you can create a repository tree view on released data source objects (see YouTube video: Repository Trees in ADT. Configure your Project Explorer).
See also the documentation: SAP - ABAP Development Tools: User Guide > Released APIs > Extend (C0) -
Case 3: Not Released for Extend (no C0 contract)
In case the required data source has API State Contract C0: Not Released it’s not enabled for extensibility.
You can check that, for example, via the API release state of the data source
I_SalesOrderPartnerin ADT.
In this case, the solution is to create a data source in ADT in a Custom Wrapper that is wrapping the database table and exposing its missing field. Release it for usage in ABAP Cloud Development and create another data source in ABAP Cloud Development, which combines the non-extensible data source with the wrapping one. This way the combining data source can be used instead of the non-extensible one. This will be shown in Step 9: Case 3.1 - The Data Source is not Released for Extend and following steps of case 3.
Be aware that only read access is recommended for the added field as SAP might have determination and validation logic that changes the field again or bypasses needed checks after you changed it. This means that especially data definitions for transactional processing processing like
R_InspectionLotTP(@VDM.viewType #TRANSACTIONAL) must not be extended at all as their main purpose is to offer the entire business object functionality.
For more information, see also the documentation: SAP - ABAP RESTful Application Programming Model > Extensibility Architecture Overview
Wrap-Up
If a C1-released SAP Data Source (CDS View) does not include a standard field (delivered by SAP) but is required for ABAP Cloud Development, then you have the following options to add the field (in order of recommendation).
Characteristic of the data source Recommended Extension Technique The data source is enabled for data source extensibility. You can see this in the Custom Fields app. You cannot see in ADT if the data source is enabled for data source extensibility. Use the Custom Fields app to create a data source extension in ABAP Cloud Development. The data source is enabled for custom field extensibility. You can see this in ADT on the API State tab: the data source needs to be released for Extend (Contract C0) for use in cloud development or use in key user apps Extend the extension data source (E_) by creating a view extension and add the missing standard field. In Custom Wrapper, create a view extension for the extensible data source and expose the new field that was added to the “Extension data source (E_)”. The data source is neither enabled for data source nor custom field extensibility Create a wrapper for the data source that contains the missing field and release it for usage for ABAP Cloud Development, create a new data source combining the non-extensible data source with the wrapper. -
- Step 5
In this example the data source
I_GLAccountingLineItemis extended by the company’s country code.Disclaimer: Be aware that for this example you should not need to work with this approach, as the field could be read via association with
\_CompanyCode-Countryas well. We’ll work with this example for demonstration purposes.-
Launch the Custom Fields app in the SAP Fiori launchpad.
-
Switch to tab Data Source Extensions.
-
Start creating a new data source extension, search for and choose the data source
I_GLAccountingLineItem. -
Give the Description and the Extension ID
GEN_LEDGER_ACC_LITMand click Create.
-
In the opening editor and in the tab Field Selection, scroll down to
Company Code>Country/Region Key, tickCountry/Region Key(1), adapt the Field Name toZZ1_CompanyCountry(2), enable Custom Text (3) to adapt the Label and Tooltip texts toZZ1 Company Country(4), Save (5) and Publish (6). Note that publishing may take a while.
Now, you can make use of this field in read operations with the extended data source.
-
Enhance the ABAP class from Read a Data Source in Cloud Development (ABAP Cloud Development) by a read via data source
I_GLAccountLineItemABAPCopyout->write( |\nCase 1 - Key User extensibility on I_GLAccountLineItem + ZZ1_CompanyCountry | ). SELECT FROM I_GLAccountLineItem WITH PRIVILEGED ACCESS FIELDS CompanyCode, Company, ZZ1_CompanyCountry INTO TABLE @DATA(lt_data_case1) UP TO 5 ROWS. out->write( lt_data_case1 ). -
Run the ABAP class as Application and check that data is retrieved.
In the output you can see data for the added field:

For more information, see also the documentation: Creating Data Source Extensions.
-
- Step 6
In this example the data source
I_SalesOrderis extended byvbakfieldgwldt.Remember (see Step 4: Identify the Extension Case for a Data Source) that a data definition must not appear in the key user app for data source extensions for this to be the best approach. If it does appear there, follow Step 5: Case 1 - The Data Source is Key User Data Source Extensible (ABAP Cloud Development).
Contract C0-released implies that the extensible data source associates a so-called extension data source, in case of SAP data sources with name
E_*.Open data source definition
I_SalesOrderin ADT and search forE_. You will findE_SalesDocumentBasic.
Open
E_SalesDocumentBasic.
This extension data source is of
@VDM.viewType #EXTENSION. It exposes the database tablevbak. You can choose additional fields from this database to extend the extensible data sources. The extension data source defines the aliasPersistenceforvbak. - Step 7
The first step is to extend the extension data source. This has to be done in a Custom Wrapper as database tables like
vbakare not released for use in cloud development.-
Open the extension data definition
E_SalesDocumentBasic. -
Right-click the extension data definition in the navigation tree and choose New Data Definition from its context menu.

Give the package
$TMP, the nameZZ1_E_SALES_DOC_BASIC, the descriptionI_SALESDOCUMENTBASIC extensionand click Next.
-
Continue in the wizard until the Templates selection dialog and choose Extend View Entity.

Hint: If in contrast to
E_SalesDocumentBasic, the extension data definition was a view and not a view entity, you could also choose Extend View instead. Be aware that a view can still be migrated to a view entity by SAP. Migrate an existing Extend View to an Extend View Entity to avoid issues. -
Complete the code of the data source by adding the field that you want to extend your extensible data source with.
ABAPCopyextend view entity E_SalesDocumentBasic with { Persistence.gwldt as ZZ1_WarrantyStartDate }Reminder:
Persistenceis the alias defined for database tablevbakin the extension data source. -
Save and activate the data source. Note that this may take a few minutes.
For more information, see also the documentation: CDS Views Extension
-
- Step 8
Follow the same steps as in Step 7: Case 2.2 - Extend the Extension Data Source for the extensible data definition.
-
Right-click the interface data definition
I_SALESORDERin the navigation tree and choose New Data Definition from its context menu.
-
Give the package
$TMPthe nameZZ1_E_SALESORDERand the descriptionI_SALEORDER extension.
Hint: If in contrast to
I_SALESORDERthe extensible data definition was released for extend (C0) in Cloud Development, the extending data definition of this step should be created in an ABAP Cloud Development package. -
Continue in the wizard until the Templates selection dialog and choose Extend View.

Hint: If in contrast to
I_SALESORDERthe extensible data definition was a view entity, you had to choose Extend View Entity instead. Be aware that a view can still be migrated to a view entity by SAP. Migrate the existing Extend View to an Extend View Entity to avoid issues. -
Complete the code of the data source by providing a value for annotation
@AbapCatalog.sqlViewAppendName. Define the field that the interface data source should get extended by.
ABAPCopy@AbapCatalog.sqlViewAppendName: 'ZZ1_E_SO' @EndUserText.label: 'I_SALESORDER extension' extend view I_SalesOrder with ZZ1_E_SALESORDER { _Extension.ZZ1_WarrantyStartDate as ZZ1_WarrantyStartDate } -
Save and activate the data source. Note that this may take up to an hour.
Now, data source
I_SalesOrderwill also return the database field.-
Enhance the ABAP class from Step 2: Read a Data Source in Cloud Development (ABAP Cloud Development) by a another read via data source
I_SalesOrderABAPCopyout->write( |\nCase 2 - I_SalesOrder + ZZ1_WarrantyStartDate | ). SELECT FROM I_SalesOrder WITH PRIVILEGED ACCESS FIELDS SalesOrder, CreationDate, ZZ1_WarrantyStartDate INTO TABLE @DATA(lt_data_case2) UP TO 5 ROWS. out->write( lt_data_case2 ). -
Run the ABAP class as Application and check if data is retrieved.

-
- Step 9
In this example the data source
I_SalesOrderPartneris missingvbpafieldknref.Although this data source is not released for Extend (no C0 contract), you can still achieve an extension.
The approach is to wrap the database table in our data source in a Custom Wrapper, expose the missing fields in that data source and release it for system-internal usage (Contract C1) for ABAP Cloud Development. Afterwards, an ABAP Cloud Development data source is created which combines the original data source (missing a field) with the wrapper data source (exposing the missing field). With this, you can use the ABAP Cloud Development data source instead of the original one to get all its fields, adding the one that you’ve put in the wrapper.

This approach may require an object of type access control for the newly created combining data sources.
- Step 10
First, we create the data source that wraps the database table and exposes its missing field.
-
Create a data definition that is based on the database table
vbpacontaining the field that is missing and needs to be exposed. Give the package$TMPthe nameZZ1_W_VBPAand the descriptionVBPA wrapping and field exposing dta src.
-
Continue in the wizard until the Templates selection dialog and choose Define View Entity.

-
Adapt the code of the data source by leaving only the key field
vbelnand the fieldknrefin the list of inserted fields. These two fields are the fields that the wrapper should expose to ABAP Cloud Development. Provide them with the human-readable aliasesSalesDocumentIDandZZ1_CustDescrOfPartnerPlant.
ABAPCopy@AbapCatalog.viewEnhancementCategory: [#NONE] @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'VBPA wrapping and field exposing dta src' @Metadata.ignorePropagatedAnnotations: true @ObjectModel.usageType:{ serviceQuality: #X, sizeCategory: #S, dataClass: #MIXED } define view entity ZZ1_W_VBPA as select from vbpa { key vbeln as SalesDocumentID , knref as ZZ1_CustDescrOfPartnerPlant } -
Save and activate the data source.
-
Release the data source.
Go to Properties, open API State and add a release contract for system-internal usage (Contract C1) for use in Cloud development. Click Next >.


Continue in the wizard and click Finish.
-
- Step 11
Next, we create the interface data source for ABAP Cloud Development which combines the original and the wrapping/exposing data source and with that, exposes the fields of both.
-
Select New Data Definition from the context menu of the original data source
I_SalesOrderPartnerthat’s missing the database field we need. -
Change the package to
ZMYLOCALand give the nameZZ1_I_SO_PARTNERand the descriptioncomb I_SO_PARTNER+vbpa wrapper/exposure.
-
Continue in the wizard and choose the template Define View Entity.

-
Adapt the code of the data source:
4.1. As this data source should provide the very same protection as the original data source, change the value of the annotation
@AccessControl.authorizationCheckfrom#NOT_REQUIREDto#CHECK.4.2. Add the association for the original data source.
ABAPCopyassociation to I_SalesOrderPartner as _I_SO_PARTNER on $projection.SalesOrder = _I_SO_PARTNER.SalesOrder4.3. Define a second association for the wrapper data source.
ABAPCopyassociation to ZZ1_W_VBPA as _vbpa_wrapper on $projection.SalesOrder = _vbpa_wrapper.SalesDocumentID4.4. Add the additional database field that’s exposed via the wrapper:
_vbpa_wrapper.ZZ1_CustDescrOfPartnerPlant4.5. Expose the association alias of the original data source:
_I_SO_PARTNER
ABAPCopy@AbapCatalog.viewEnhancementCategory: [#NONE] @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'comb I_SO_PARTNER+vbpa wrapper/exposure' @Metadata.ignorePropagatedAnnotations: true @ObjectModel.usageType:{ serviceQuality: #X, sizeCategory: #S, dataClass: #MIXED } define view entity ZZ1_I_SO_PARTNER as select from I_SalesOrderPartner association to I_SalesOrderPartner as _I_SO_PARTNER on $projection.SalesOrder = _I_SO_PARTNER.SalesOrder association to ZZ1_W_VBPA as _vbpa_wrapper on $projection.SalesOrder = _vbpa_wrapper.SalesDocumentID { key SalesOrder, key PartnerFunction, _vbpa_wrapper.ZZ1_CustDescrOfPartnerPlant, Customer, Supplier, […] _PersonName, _SalesOrder, _I_SO_PARTNER } -
Save and activate the data definition.
-
- Step 12
Since the ABAP Cloud Development data source should provide the very same protection as the original data source, we’ll now create an access control for it. This access control will simply inherit the access control from the original data source.
-
Create an access control from the context menu of the ABAP Cloud Development data definition
ZZ1_I_SO_PARTNER.
-
Give the name
ZZ1_I_SO_PARTNER_ACLand the descriptionACL for SO Partner + vbpa exposing DDLS
-
Continue in the wizard until the Templates selection dialog and choose Define Role with Inheriting Conditions:

Implement the
whereclause by giving the source entityI_SalesOrderPartnerand adding a replacement for the root with the wrapper association.
ABAPCopy@EndUserText.label: 'ACL for SO Partner + vbpa exposing DDLS ' @MappingRole: true define role ZZ1_I_SO_PARTNER_ACL { grant select on ZZ1_I_SO_PARTNER where inheriting conditions from entity I_SalesOrderPartner replacing {root with _I_SO_PARTNER }; } -
Save and activate the access control.
The data source
ZZ1_I_SO_PARTNERwill also return the database field.-
Enhance the ABAP class from Step 2: Read a Data Source in Cloud Development (ABAP Cloud Development) by a read via data source
ZZ1_I_SO_PARTNERABAPCopyout->write( |\nCase 3 - ZZ1_I_SO_PARTNER associating I_SO_PARTNER and exposing Wrapper | ). SELECT FROM ZZ1_I_SO_PARTNER FIELDS SalesOrder, Partner, ZZ1_CustDescrOfPartnerPlant INTO TABLE @DATA(lt_data_case3) UP TO 5 ROWS. out->write( lt_data_case3 ). -
Run the ABAP class as Application and check if the data is retrieved. The data is retrieved even if the requested new field has no data.

If the select statement doesn’t return any result row at all, your user may be lacking the authorizations needed for the inherited protection from Access Control
I_SalesOrderPartner.To retrieve data, assign the necessary authorizations. You can do this by assigning the business role
SAP_BR_SALES_MANAGER, for example. Alternatively, call the select statementWITH PRIVILEGED ACCESS. -
- Step 13
If you want to restrict the use of the wrapper data source, you can protect it with an access control as well.
-
In the data source code itself, change the value of the
@AccessControl.authorizationCheckannotation from#NOT_REQUIREDto#PRIVILEGED_ONLY.
This enables you to still use the data source in privileged mode, but forbids access when using it without privileged mode. -
Save and activate the data source.
-
Right-click the data source
ZZ1_W_VBPAin the navigation tree and select New Access Control from the context menu. -
Give the name
ZZ1_W_VBPA_ACLand the descriptionACL for vbpa wrapping + exposing DDLS. -
Continue in the wizard until the Templates selection dialog and choose Define Role with Simple Condition and select Finish.

-
Within the code of the access control you’ve created, adapt the value for the label notation if the description was longer than 40 characters and add a
whereclause which will never be true:
ABAPCopy@EndUserText.label: 'ACL for vbpa wrapping+exposing DDLS' @MappingRole: true define role ZZ1_W_VBPA_ACL { grant select on ZZ1_W_VBPA where //forbid direct access to wrapper data source by never occurring condition ( ineffective in privileged mode ) SalesDocumentID is not initial and SalesDocumentID is initial ; } -
Save and activate the access control.
-
- Step 14
What is the best way to add a missing field to data definition I_Product?
- Verify that a Data Source is Usable in Cloud Development
- Read a Data Source in Cloud Development (ABAP Cloud Development)
- Check if the Field is Actually Missing
- Identify the Extension Case for a Data Source
- Case 1 - The Data Source is Key User Data Source Extensible (ABAP Cloud Development)
- Case 2.1 - The Data Source is Released for Extend (Custom Wrapper)
- Case 2.2 - Extend the Extension Data Source
- Case 2.3 - Extend the Extensible Data Source
- Case 3.1 - The Data Source is Not Released for Extend
- Case 3.2 - Create the Database Wrapper (Custom Wrapper)
- Case 3.3 - Create the Combining Data Source (ABAP Cloud Development)
- Case 3.4 - Protect the Combining Data Source
- Case 3.5 (Optional) - Restrict the Use of the Wrapper
- Test yourself