Sub topic 5
Anti-patterns that break the core
This chapter assumes you know what clean core means, what a released API is, and how the three extension options differ. It covers the practices that break clean core, why they hurt, and what to do instead.
Why these patterns matter
Every anti-pattern here has the same root cause. The extension depends on something SAP has not promised to keep stable. When SAP changes that thing in an upgrade, the extension breaks, or the upgrade becomes slow and expensive.
The common anti-patterns
Modifying SAP objects
A modification changes a standard SAP object directly, for example by editing delivered ABAP code with an access key. Your change sits inside SAP's own object. Each upgrade or support package can overwrite it or conflict with it, and you must adjust and retest by hand.
Using unreleased objects
An unreleased object is a table, class, function module, or CDS view that SAP has not published as an API for extensions. It works today, but SAP may rename it, change its behavior, or delete it without notice. Typical examples:
- Reading a standard table such as
MARAdirectly withSELECTinstead of using a released CDS view. - Calling an internal function module found by browsing the system.
- Calling an unreleased OData service because it was easy to find in the gateway catalog.
Writing directly to SAP tables
Updating standard tables with INSERT or UPDATE skips SAP's validations, authorizations, and business logic. The data can become inconsistent, and the result is hard to detect and hard to repair.
Copying core data into the extension
A side-by-side extension that replicates large parts of S/4HANA data into its own database creates a second source of truth. The copy goes stale, and you must handle synchronization, deletion, and data protection yourself. Keep data in the core and read it through a released API when you need it. Store only data that is new and owned by the extension.
Depending on internals through the back door
A side-by-side extension can still break the core if it relies on private behavior. Examples are scraping a UI, calling a custom RFC wrapper that reads unreleased tables, or hard-coding the shape of an unreleased service.
Comparing the patterns with the clean alternative
| Anti-pattern | Main risk | Clean alternative |
|---|---|---|
| Modification of SAP code | Overwritten or conflicting at upgrade | In-app or developer extension points |
| Unreleased object usage | Object changes or disappears | Released API or released CDS view |
| Direct table writes | Skipped validation, inconsistent data | Released API that runs business logic |
| Bulk data copy | Stale data, duplicate ownership | Remote service call or business events |
| UI scraping or private RFC | Breaks on any internal change | Released OData API |
How the failure happens
Spotting the problem in code
The first snippet depends on an unreleased table. The second uses a released API through a CAP remote service.
// Anti-pattern: bypasses the API contract by reading an internal table
// through a custom RFC wrapper that nobody at SAP supports.
const rows = await rfcClient.call('Z_READ_TABLE', { TABLE: 'MARA' })// Clean: reads through the released Business Partner API.
const bp = await cds.connect.to('API_BUSINESS_PARTNER')
const partners = await bp.run(SELECT.from('A_BusinessPartner').limit(10))How to check before you build
- Look up the object in the released API catalog (SAP Business Accelerator Hub) or check its release state in ADT.
- If it is not released, search for a released alternative before you consider anything else.
- If none exists, request a release from SAP or document the exception, and classify it using the clean core levels.
Exercise
A team builds a BTP application that nightly copies all sales orders from S/4HANA into its own database so it can run reports quickly. Name the anti-pattern and give one clean alternative.
Show answer
This is bulk data copying, which creates a second source of truth that goes stale and needs its own synchronization. A clean alternative is to read sales orders on demand through a released API using a CAP remote service. If the data must be reacted to, use business events and store only what the extension owns.
Exercise
Why is reading the table MARA directly with SELECT a clean core violation, even if it returns correct data today?
Show answer
MARA is not a released object. SAP can change its structure or behavior in any release without notice, so the extension may break at upgrade. A released CDS view provides a stable contract.