Sub topic 1
Extensibility options in SAP S/4HANA
Prerequisites
This chapter assumes you can do the following:
- Navigate the SAP Fiori launchpad and open apps from tiles and the search field.
- Recognize SAP S/4HANA business objects such as sales orders, business partners and products.
- Understand basic data types: text, number, date and amount.
- Read simple SQL or ABAP. This helps in later chapters on custom logic, but you don't need it here.
You don't need to have created an extension before. This chapter gives you the map. Later chapters cover each step in detail.
Why extensibility exists
SAP S/4HANA ships with standard processes for sales, procurement, finance and other areas. Almost every company needs something the standard doesn't cover. Typical examples:
- An extra field on a sales order, such as a customer's internal project number.
- A check that blocks saving a document when a field combination is invalid.
- A report that combines standard data with a custom field.
Extensibility is the set of supported ways to add such things without changing SAP's delivered code. The key question is not whether you can extend, but which technique to use. Each technique differs in who can use it, where it runs and how well it survives upgrades.
The three extensibility models
SAP S/4HANA offers three main models. They are often combined in the same project.
Key user extensibility
Key user extensibility is done by business-oriented users, called key users, in the browser. They use Fiori apps, such as Custom Fields and Logic, and need no development environment. Extensions run inside the S/4HANA system itself.
Typical tasks:
- Adding custom fields to standard business objects, UIs, reports, forms and APIs.
- Writing small pieces of custom logic that hook into standard processes through BAdIs (Business Add-Ins, which are predefined extension points).
- Creating custom CDS views for reporting, and custom business objects for simple own data.
The ABAP you can write here is restricted. You may use only released objects, which are objects SAP has declared stable for customer use.
Developer extensibility
Developer extensibility is done by professional ABAP developers in ABAP Development Tools (ADT) in Eclipse. Extensions also run inside the S/4HANA system. Developers have far more freedom than key users: they can build custom classes, CDS views, RAP business objects and services. The restriction remains that they must use released APIs only, in the ABAP language version for cloud development (ABAP Cloud).
Developer extensibility fits cases that need structured code, more complex data models or custom applications on the S/4HANA data.
Side-by-side extensibility
Side-by-side extensibility means the extension runs outside the S/4HANA system, usually on SAP Business Technology Platform (SAP BTP). It communicates with S/4HANA through released APIs and events. You can build it with ABAP Cloud (the SAP BTP ABAP environment), with CAP (Cloud Application Programming Model) or with other technologies.
Typical reasons to choose it:
- The extension serves users or systems that don't belong in the S/4HANA system, such as partners or consumers.
- It needs its own lifecycle, scaling or technology stack.
- It integrates several systems, not only S/4HANA.
Comparison
| Aspect | Key user | Developer | Side-by-side |
|---|---|---|---|
| Who works on it | Key user (business expert) | ABAP developer | Developer on SAP BTP |
| Tool | Fiori apps, such as Custom Fields and Logic | ABAP Development Tools in Eclipse | SAP BTP tools, ADT, other IDEs |
| Where it runs | Inside S/4HANA | Inside S/4HANA | On SAP BTP |
| Typical scope | Fields, small logic, custom CDS views | Classes, RAP business objects, apps | Separate apps, integrations |
| Access to SAP objects | Released objects only | Released objects only (ABAP Cloud) | Released APIs and events |
| Effort | Low | Medium to high | Medium to high |
What stays the same across all models
All three models follow the same principle: you extend through stable, released interfaces and never change SAP's delivered code. This is the basis of the clean core approach, covered in the next chapter. Because extensions depend only on released objects, SAP can change internal code during an upgrade without breaking them.
Note that "classic" extension techniques also exist, such as modifications, implicit enhancements and direct access to internal tables. They can still be found in older systems, but they are not upgrade-safe, and they are not available in the key user model at all.
What key user extensibility looks like in practice
A key user typically works through these steps for one requirement:
- Open the Custom Fields app (part of Custom Fields and Logic) from the launchpad.
- Pick an extensibility business context, which decides the business object and the places where the field can appear.
- Create the field, choose a data type and a label.
- Publish the field so it becomes active in the system.
- Optionally add custom logic that fills or validates the field.
- Move the extension to other systems through transport.
Fields created this way get a recognizable ID.
Custom field ID pattern: YY1_<FieldName>_<suffix>
Example: YY1_CostCenterNote_PRD
The YY1_ prefix marks key user extensions. The suffix is generated by the system from the business context.You can use the prefix to tell custom fields from standard ones in field lists, reports and API responses.
Custom logic is plain ABAP restricted to released objects. The following reads a product type through the released CDS view I_Product:
" Read data through a released CDS view, as allowed in key user custom logic.
DATA lv_product TYPE matnr VALUE 'TG11'.
DATA lv_product_type TYPE I_Product-ProductType.
SELECT SINGLE ProductType
FROM I_Product
WHERE Product = @lv_product
INTO @lv_product_type.
IF sy-subrc <> 0.
" No product found: handle the case here, for example by raising a message.
ENDIF.Two details matter here. The @ before host variables is required in this ABAP SQL syntax. And the data source is I_Product, a released CDS view. A direct SELECT from a database table such as MARA would be rejected, because the table is not released for this use.
Decision criteria
Start with the lowest-effort model that satisfies the requirement, and move up only when you hit a real limit.
Use key user extensibility when:
- You need a custom field on a standard object and want it in UIs, reports, forms or APIs.
- The logic is short, such as a validation or a derivation from a few released data sources.
- A business expert should be able to maintain the extension without a developer.
Move to developer extensibility when:
- The logic needs multiple classes, reuse or automated unit tests.
- You need a custom data model with its own behavior, beyond what a custom business object offers.
- You need a custom Fiori app or service on top of S/4HANA data.
Move to side-by-side extensibility when:
- The functionality should run outside the core system for scaling, security or lifecycle reasons.
- Users or systems that don't belong in S/4HANA must access it.
- It combines S/4HANA data with other systems.
Common mistakes
- Assuming that every standard object offers every extension option. Which fields, BAdIs and release states exist depends on the business context and the object. Check the available contexts in the Custom Fields app before you plan.
- Treating key user extensibility as a smaller version of ABAP development. It isn't. The released-object restriction applies, and code that works in a classic report may not compile.
- Putting heavy logic into key user custom logic. BAdI implementations run inside standard transactions, so slow code slows down the business process.
- Choosing by tool preference. Choose by the requirement, the users, and where the extension should run.
- Forgetting that custom fields need to be published before they appear. Creating a field is not enough. The publication chapter covers this.
Summary of the map
The remaining chapters follow the key user path. You will look at clean core and roles, then work through the Custom Fields and Logic app, business contexts, creating and publishing a field, released objects, BAdI logic, custom CDS views and business objects, transport, and troubleshooting.
Exercise
A sales team wants a free-text "Customer project number" on sales orders. It should appear in the sales order UI and in a report. A second team wants a standalone web app, used by external partners, that reads open sales orders from S/4HANA and shows delivery forecasts. Which extensibility model fits each request, and why?
Show answer
The first request fits key user extensibility. It needs only a custom field on a standard business object, published to the UI and reports, and a key user can do this in the Custom Fields app without development. The second request fits side-by-side extensibility. The app is used by external partners, so it should run outside the S/4HANA system, for example on SAP BTP, and read open sales orders through released APIs.
Exercise
A developer tries to write key user custom logic with SELECT SINGLE matnr FROM mara .... Why does this fail, and what is the supported alternative?
Show answer
MARA is a database table that is not released for use in key user custom logic. Key user and developer extensions may use only released objects. The supported alternative is to read from a released CDS view, such as I_Product, using ABAP SQL with @-escaped host variables.