Sub topic 2
Why extend without modifying: clean core and upgrade stability
This chapter assumes you can navigate the SAP Fiori launchpad. It also assumes you know the main S/4HANA business objects (sales orders, business partners, products) and can read basic SQL or ABAP. You do not need to have created an extension yet. The goal is to understand why key user extensibility is built the way it is, so the later chapters on fields and logic make sense.
The problem: changes that block upgrades
Every business customizes its ERP system. It adds a field to a sales order, checks a rule before a document is saved, or shows a new column in a report. The question is how the change is made.
Historically, many SAP customers changed the standard code directly. This is called a modification. A modification edits an object that SAP delivered, such as a standard program, a standard table or a standard function module. Related practices include:
- Changing an SAP-delivered object and registering the change with a modification key.
- Appending fields to standard tables with unreleased techniques.
- Calling internal function modules and classes that SAP never promised to keep stable.
These changes work on the day they are made. The cost appears later. When SAP ships a new release, a support package or a patch, the delivered code can change. Your change may then conflict with the new code. Someone must find each conflict, decide which version wins, and retest the affected processes. Over the years, projects accumulate so many of these that an upgrade becomes a large, slow, expensive project. Some customers stay on old releases because upgrading is too risky.
What "clean core" means
Clean core is SAP's guideline for avoiding that outcome. The core is the standard S/4HANA system as SAP delivers it. Keeping it clean means your own code and configuration never alter the standard objects and never depend on their internals.
In practice, a clean core rests on these ideas:
- Extend, do not modify. Add your own objects next to the standard ones and connect through defined extension points.
- Use only released interfaces. SAP marks certain objects as released. A released object comes with a stability promise: SAP will not change it in an incompatible way, or it will announce and manage the change.
- Separate custom and standard artifacts. Custom objects have their own namespace or prefix, so you can always tell what is yours.
- Keep extensions upgrade-stable. An upgrade replaces the standard code, and your extensions continue to work because they only touched stable points.
Key user extensibility is the most restrictive and most protected form of this approach. The system itself enforces the rules, so a key user cannot break them even by accident.
Released objects and the stability contract
A released object carries a release state that says how you may use it. For key user extensibility, the important state is the one that allows use in cloud development and key user logic. SAP documents the released objects, and you can browse them in the ABAP Development Tools and in the released objects tools of the system.
Examples of released objects:
- Released CDS views, such as
I_Product, which expose product data in a stable structure. - Released BAdIs, which are defined places where custom logic can run.
- Released classes and interfaces that offer safe helper functions.
The contract works in both directions. SAP promises compatibility. You promise to use only objects that carry the promise. Key user tools enforce your side by checking the code you write and rejecting anything that uses an unreleased object.
The following ABAP reads product data through the released CDS view I_Product. It follows the clean core rule because it reads through a released object and never touches the underlying database tables directly.
" 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 @ sign marks host variables, which are ABAP variables used inside SQL. This is the escaped form that modern ABAP SQL requires. Also, sy-subrc is the return code, and a value other than 0 means the SELECT found no row. Always check it.
If the same logic read the table MARA directly, the key user check would reject it. MARA is an internal table, and SAP may restructure it in a later release.
How key user extensibility protects the core
Key user extensibility adds a layer between you and the standard system. It works in three ways.
Extensions are stored separately
When you create a custom field, the system does not alter the standard table definition by hand. It generates the extension objects itself, using a defined framework. The standard objects and your extension objects stay distinct. During an upgrade, SAP replaces the standard part and the framework reconnects your extension to the new version.
You can recognize these objects by their names. Custom fields created by key users carry the YY1_ prefix, so you can tell them apart from standard fields in field lists, reports and API responses.
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.Extension points are predefined
You cannot attach logic to any place in the system. You attach it to a released extension point, such as a BAdI that SAP has opened for this purpose. SAP chooses these points because they sit at stable moments in a process, for example just before a document is saved. The point has a defined interface: the data you receive and the data you may change.
The editor checks your code
The ABAP editor for key users runs in a restricted language mode. It allows a subset of ABAP and checks every statement against the list of released objects. You see a syntax error if you use something outside the list. This catches clean core violations while you type, long before an upgrade.
The diagram shows how the layers relate.
What happens during an upgrade
Consider two systems that both need a custom approval note on sales orders.
In the first system, a developer appended a field to a standard table with an unreleased technique. The upgrade changes the table structure. The field may be lost, or the upgrade tools stop and report a conflict. A team must analyze it, repair it and retest the sales order process.
In the second system, a key user created the field in the Custom Fields app. The upgrade replaces the standard part. The framework regenerates the connection to the new standard structure. The field and its data are still there, and the key user does nothing.
The second system is not magic. It works because the key user used only supported steps, and SAP tests those steps against its own releases. The effect is a shorter upgrade, fewer regression tests and lower risk.
Where clean core thinking has limits
Clean core is a trade-off, not a free benefit. Know the costs so you can decide when key user extensibility fits.
- Smaller scope. Key users can add fields and simple logic at released points. They cannot change a standard screen layout arbitrarily, rewrite a standard algorithm or reach into any table they like.
- Dependence on released objects. If SAP has not released the object you need, you cannot use it in key user logic. You may need to request a release, choose another released object, or move the work to developer or side-by-side extensibility.
- Possible deprecation. Released does not mean permanent. SAP can deprecate an object. It then announces this in advance and keeps the object working for a defined period, so you must monitor these notices.
- Governance still matters. The system prevents technical damage. It does not prevent poor design, such as dozens of rarely used fields or logic that slows down a process.
Choosing between extension styles
Use this table as a first filter. Later chapters go deeper on each option.
| Need | Suitable approach | Why |
|---|---|---|
| Add a field to a standard object and show it in UI, reports and APIs | Key user extensibility | Supported by the Custom Fields app and upgrade-stable |
| Run a small check or default a value at a released BAdI | Key user custom logic | Restricted ABAP, checked against released objects |
| Build complex custom code that uses released ABAP Cloud APIs | Developer extensibility | Full ABAP Cloud development with the same clean core rules |
| Build a separate application with its own lifecycle or user base | Side-by-side extensibility | Runs outside the core and connects through APIs |
Common mistakes
- Reading tables directly. Using
MARAorVBAKinstead of the released viewsI_ProductorI_SalesDocument. The check rejects this, and the habit causes trouble when you move to other tools. - Assuming a field is protected by its name only. The
YY1_prefix identifies a key user field. Compatibility comes from creating it with the supported app, not from the name. - Treating "works today" as "is supported". Some unreleased objects may technically be reachable in older or on-premise setups. They are not covered by the stability promise, so they can break at the next upgrade.
- Ignoring deprecation notices. A released object that is marked deprecated still works for now. Plan a replacement before the support period ends.
- Putting heavy processing in custom logic. Logic at a BAdI runs inside the standard process. Slow code makes users wait at every save.
Summary
Modifications tie your system to one version of SAP's code and make every upgrade costly. A clean core keeps your changes separate and limits them to released, stable interfaces. Key user extensibility enforces this by generating extension objects through a framework, offering predefined extension points, and checking your ABAP against the list of released objects. The price is a narrower scope. In return you get extensions that survive upgrades with little or no rework.
Exercise
A colleague wants to read the product type directly from the database table MARA in key user custom logic because it is faster to write. Explain why this conflicts with clean core, and name the better option from this chapter.
Show answer
MARA is an internal table that is not released, so SAP gives no stability promise for it and may change it in a later release. The key user ABAP check also rejects unreleased objects. The better option is to read through the released CDS view I_Product with ABAP SQL, using escaped host variables with the @ sign, and to check sy-subrc after the SELECT.
Exercise
A field named YY1CostCenterNotePRD exists in a system. Does the YY1_ prefix alone prove that the field is upgrade-stable? Give your reason.
Show answer
No. The prefix only marks the field as a key user extension and lets you tell it apart from standard fields. Upgrade stability comes from the field having been created with the supported Custom Fields app, which generates the extension objects through the framework. A field made by another technique could not legitimately carry this prefix, but the name alone is not the guarantee.
Exercise
Your team needs a new application with its own user interface, its own release schedule and its own database. Which extension style from the table fits best, and why not key user extensibility?
Show answer
Side-by-side extensibility fits best, because it runs outside the core and connects through APIs, so it can have its own lifecycle. Key user extensibility is limited to adding fields and simple logic at released points inside the standard system, so it cannot host a separate application.