Sub topic 7
Developer extensibility with ABAP Cloud
This chapter assumes you know the clean core principle, what a released API is, and the clean core levels A to D from earlier chapters. You should also be able to read basic ABAP, including SELECT statements and classes. You do not need to know RAP in detail.
What developer extensibility is
Developer extensibility lets ABAP developers write custom code that runs inside the SAP S/4HANA system while staying clean core compliant. The code is written in the ABAP Cloud development model. This model limits what your code may use, so that upgrades do not break it.
Developer extensibility is also called on-stack extensibility, because the custom code runs on the same stack as the S/4HANA application. Side-by-side extensions run on SAP BTP instead.
The ABAP Cloud model rests on three rules:
- Custom code uses only released APIs and released objects.
- Custom code is written in the ABAP language version "ABAP for Cloud Development", a restricted subset of ABAP.
- Custom code is developed in ABAP Development Tools (ADT) for Eclipse, with ABAP Test Cockpit (ATC) checks that enforce the rules.
Where it fits
Developer extensibility sits between in-app extensibility and side-by-side extensions. In-app extensibility covers what key users can configure with tools such as custom fields and custom logic. Side-by-side extensions are separate applications on SAP BTP.
Choose developer extensibility when you need all of these:
- Custom logic that runs in the same transaction as the standard process.
- Low-latency access to S/4HANA data.
- Behavior that key user tools cannot express.
Typical use cases:
- Validations and determinations that must run inside the standard save sequence.
- Custom business objects with their own tables, built with the ABAP RESTful Application Programming Model (RAP).
- Custom CDS views that combine released views.
- Implementations of released BAdIs.
- Custom OData services built on your own RAP objects.
Released objects and the stable contract
A released object carries a release contract. The most common one for developer extensibility is C1, "Use System-Internal". It tells you that you may use the object in your custom code on the same system. SAP commits to keeping it stable, or to deprecating it with notice.
Released objects include:
- CDS view entities such as
I_BusinessPartnerandI_SalesOrder. - Classes and interfaces, for example
cl_abap_context_infoorxco_cpclasses. - Data elements and structures.
- BAdIs.
- RAP business objects with released behavior.
You can check the release state of any object in ADT. Open the object and look at the API State tab in the Properties view. You can also search the Released Objects view of the SAP Business Accelerator Hub.
A first example
This ABAP class reads blocked business partners through the released CDS view I_BusinessPartner. It runs as a console application from ADT with F9.
CLASS zcl_bp_blocked_demo DEFINITION
PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS zcl_bp_blocked_demo IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
SELECT BusinessPartner,
BusinessPartnerFullName,
BusinessPartnerIsBlocked
FROM I_BusinessPartner
WHERE BusinessPartnerIsBlocked = @abap_true
INTO TABLE @DATA(blocked_partners)
UP TO 10 ROWS.
out->write( blocked_partners ).
ENDMETHOD.
ENDCLASS.The code reads from a released view and not from a database table. If you replace I_BusinessPartner with the table BUT000, the syntax check rejects the statement, because the table is not released for ABAP Cloud.
The same CDS view is the source behind the A_BusinessPartner OData API you used from CAP in the side-by-side chapters. The difference is the access path: here you call it in-process, and there you call it over HTTP.
Software components and language versions
Every development object belongs to a software component. The component's ABAP language version decides which rules the syntax check applies.
| Setting | Effect |
|---|---|
| ABAP for Cloud Development | Only released APIs. Classic statements such as `WRITE` and dynpro calls are not allowed. This is the clean core setting. |
| Standard ABAP | Full classic ABAP. Not allowed in clean core extensions. |
| Standard ABAP with unrestricted access | Used only by classic custom code. In ABAP Cloud, it is not available. |
In SAP S/4HANA Cloud Public Edition, you can only create ABAP Cloud software components. In private cloud and on-premise systems, you can also have classic Z code, so the language version is the guard that keeps new code clean. Set it on the software component, and keep new extensions in a separate component from legacy code.
Tools you use
- ADT for Eclipse is the only IDE for ABAP Cloud development. SAP GUI transactions such as SE80 do not support it.
- ATC runs the cloud readiness checks. Run it before each transport. A finding on an unreleased object is a clean core violation.
- abapGit and gCTS are common options for source control and transport of the extension.
- The Released Objects tool in ADT shows which objects you may use.
For custom UIs, you build a RAP business object with CDS behavior definitions, a service definition, and a service binding. Then you expose the object as an OData V4 UI service, which Fiori elements can render without extra frontend code.
What to do when a needed object is not released
You will sometimes need something that has no released API. The ordered options are:
- Search for a released alternative. SAP often publishes a released CDS view or class that replaces the classic object.
- Request a release from SAP. You can submit a "Request for release" through the SAP Customer Influence channel. The request needs a business reason.
- Build a wrapper (clean core level B). You put the classic call in a wrapper class that you release yourself for use in ABAP Cloud, with the C1 contract. The wrapper itself uses unreleased code, so you must mark it, own it, and retest it at every upgrade.
- Move the logic side-by-side if the data is available through a released OData API.
A wrapper is an exception. It reintroduces upgrade risk, only in a smaller area. Keep the wrapper thin and document it.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| "Use of <object> is not permitted" at a `SELECT` | The table or view is not released | Use the released CDS view that exposes the data |
| Syntax error on a classic statement such as `WRITE` or `CALL TRANSACTION` | The component uses ABAP for Cloud Development | Replace the statement with a released class or a RAP feature |
| BAdI not found in the implementation wizard | The BAdI is not released | Use another released BAdI or a RAP behavior extension |
| ATC passes in the dev system but fails after import | Different release levels between systems | Align the ATC check variant, and run checks in the target system |
| Extension breaks after an upgrade despite using only released objects | The released object was deprecated, and the deprecation warning was ignored | Treat deprecation findings as work items |
Trade-offs against side-by-side
Developer extensibility gives you in-transaction logic and direct data access. The cost is that your code consumes S/4HANA system resources and follows the S/4HANA release cycle. A defect in a custom class can affect the dialog performance of standard work.
A side-by-side extension on SAP BTP isolates your code and lets you choose the runtime, but every call crosses the network and needs destinations, authentication, and error handling.
| Criterion | Developer extensibility | Side-by-side on BTP |
|---|---|---|
| Runs in the S/4HANA transaction | Yes | No |
| Data access | In-process through released CDS views | HTTP through released APIs or events |
| Language and tools | ABAP and ADT | Any, often CAP with Node.js or Java |
| Impact on core resources | Shares them | Isolated |
| Release cycle | Tied to S/4HANA | Independent |
A good rule is to use developer extensibility when the logic must be part of the standard transaction, and to use side-by-side when the logic can run after the transaction or serves external users.
Exercise
A team must reject saving a sales order when a custom credit rule fails, and the rule must run inside the same save transaction. The rule needs the customer's blocked status. Which extension approach fits, and how should the code read the blocked status?
Show answer
Developer extensibility with ABAP Cloud fits, because the check must run inside the standard save sequence, which a side-by-side extension cannot join. The code should read the blocked status from a released CDS view such as I_BusinessPartner (field BusinessPartnerIsBlocked) with ABAP SQL, not from an unreleased table such as BUT000. If no released object exposes the field, the team looks for a released alternative, then requests a release, and only then builds a thin wrapper (level B).
Exercise
ATC reports that your class uses an unreleased function module. You add a pragma to hide the finding. Why is this a poor choice, and what are two better options?
Show answer
The pragma hides the finding but leaves the dependency, so an upgrade can still break the code and the clean core level stays C or D. Better options are to use a released replacement API, or to wrap the function module in a thin, released wrapper class that you test at every upgrade. Requesting a release from SAP is another valid route.