Sub topic 2
Why extend without modifying: clean core and upgrade stability
This chapter assumes you can navigate the SAP Fiori launchpad and know the main S/4HANA business objects, such as sales orders and products. You don't need to write ABAP yet. The short code sample only illustrates a rule.
What a modification is
A modification changes SAP-delivered code or objects directly. Examples are editing a standard program, changing a standard table definition, or overwriting a delivered object with your own version.
An extension adds something next to the standard without changing it. A custom field and a BAdI implementation are extensions. A BAdI (Business Add-In) is a hook that SAP places in standard code for customer logic.
The difference shows up at upgrade time. SAP replaces the delivered objects with new versions. Your extension is stored separately, so the upgrade leaves it alone. A modification sits inside the object being replaced, so someone has to compare the old and new versions and merge them by hand.
What clean core means
Clean core is SAP's guideline for keeping the standard system free of customer changes. Custom code and data models stay outside the standard code. They talk to it only through stable, documented interfaces.
Four ideas make up the guideline:
- The standard code stays unchanged.
- Extensions use only released objects. SAP has marked these as stable for customer use, and it keeps them compatible across releases. Released objects include APIs, CDS views such as
I_Product, and BAdIs. - Extensions are kept separate from the standard, so they can be found, transported and removed.
- Upgrades don't need manual adjustment of customer changes.
Why this matters for upgrades
Modified systems get expensive to upgrade. Every changed object is a conflict to resolve before the new release goes live, and the work grows with each release. Teams often delay upgrades to avoid it, and then they fall behind on new features and fixes.
Extensions built on released objects change this. SAP commits to keeping released interfaces compatible, or to announcing a deprecation first. When a new release arrives, your extension should keep working without rework.
| Aspect | Modification | Extension on released objects |
|---|---|---|
| Where the change lives | Inside the standard object | Separate from the standard |
| Effect of an upgrade | Conflicts to merge by hand | Normally none |
| Dependence on SAP internals | High, on tables and function modules that can change | Low, on stable interfaces |
| Allowed in the key user tools | No | Yes |
Where key user extensibility fits
SAP S/4HANA offers several extension styles: key user (in-app), developer, and side-by-side on SAP Business Technology Platform. All three follow clean core. Key user extensibility is the lightest one. You work inside the running system with browser-based apps, and you don't need a development environment.
The tools enforce clean core for you. Logic written in the Custom Fields and Logic app can use released objects only. The editor rejects access to unreleased tables and function modules. The same rule is why the API in the sample below is available to you.
" Allowed: read through a released CDS view.
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.
" Not allowed in key user logic: reading the underlying table MARA directly.
" It is an internal table, not a released object, and SAP may change it.Reading the product type from I_Product is safe across upgrades because the view is released. The underlying tables are implementation details, and SAP may restructure them.
How the layers relate
Common mistakes
- Treating a custom field as a modification. It isn't one. The field is stored in an extension structure that the upgrade doesn't touch.
- Looking for a workaround to a released-object restriction. The restriction is what makes the extension upgrade-safe. If a needed object is not released, check whether SAP offers a released alternative or whether the requirement fits a different extension style.
- Assuming released means permanent. SAP can deprecate released objects. It does so with advance notice and a successor, so check release notes before an upgrade.
Exercise
A colleague proposes adding a field by editing a standard table definition so that it appears in a standard report. Why does this conflict with clean core, and which key user alternative would you suggest?
Show answer
Editing the standard table is a modification. An upgrade replaces the delivered table definition, so the change would be lost or would need manual merging. The key user alternative is a custom field created in the Custom Fields and Logic app. It is stored as an extension, so upgrades leave it intact, and it can be published to the relevant UIs and reports.
Exercise
Your custom logic needs a product's type. Why should it read the released view I_Product and not the table MARA?
Show answer
I_Product is a released object, so SAP keeps it compatible across releases and the key user logic editor allows it. MARA is an internal table that is not released. SAP may change it in a future release, and key user logic cannot access it.