Workik.

SAP S/4HANA Custom Code Migration: An ABAP Developer's Guide

Clean Core and ABAP Cloud for Migrated Systems

Examine clean core levels A to D and adopt ABAP Cloud fundamentals to build upgrade-stable extensions using released APIs and modern CDS view entities.

When you adapt custom code for SAP S/4HANA (SAP Business Suite 4 SAP HANA), your immediate goal is to make existing programs run without errors. Once your system conversion stabilizes, you face a strategic choice for ongoing development. You can keep writing ABAP (Advanced Business Application Programming) the old way, or you can adopt clean core principles so that future upgrades require far less remediation effort.

Previous lesson: ABAP on SAP HANA: Sorting, Database Hints and Code Pushdown | Next lesson: Testing, Cutover and AI-Assisted Custom Code Remediation


Clean Core and the Four Extensibility Levels

Clean core is an architectural strategy that separates custom business logic from the underlying SAP system code. When custom code accesses SAP database tables directly or calls undocumented function modules, any SAP upgrade or support package can break that code. Clean core prevents this break by routing all custom interactions through defined, stable boundaries.

In August 2025, SAP defined four clean core extensibility levels to help you classify and evaluate custom development:

  • Level A: Extensions that use only publicly released, stable SAP interfaces with formal stability contracts. This level includes side-by-side extensions built on SAP BTP (SAP Business Technology Platform) and on-stack extensions built with ABAP Cloud. SAP commits to keeping these interfaces stable, so upgrades are very unlikely to break Level A code.
  • Level B: Extensions that use Level A methods plus classic, documented SAP APIs (Application Programming Interfaces) and traditional development technologies. These interfaces are documented and generally upgrade stable, but they lack formal release contracts.
  • Level C: Extensions that access internal SAP objects, such as unreleased function modules or direct reads on SAP tables. This code is partially compliant and represents legacy scenarios. SAP plans to provide a changelog for SAP objects to help developers identify upgrade risks in Level C objects.
  • Level D: Extensions that are not recommended. Examples include modifications to standard SAP code, direct write access to standard SAP tables, implicit enhancements, and the use of obsolete objects. Level D carries the highest technical debt and the greatest risk of failure during upgrades.

Common Mistake: You do not need to rewrite your entire custom code base in ABAP Cloud during a system conversion. Brownfield conversions bring over classic code that runs as Standard ABAP (often sitting at Level B or Level C). Clean core is your target for new custom applications and targeted refactoring, not an overnight mandate for every existing report.


ABAP Cloud versus Classic Standard ABAP

ABAP Cloud is SAP's development model for building cloud-ready, upgrade-stable applications. It is available in SAP S/4HANA Cloud and modern on-premise releases of SAP S/4HANA. It enforces clean core architecture at the compiler level.

Classic ABAP uses the language version known as "Standard ABAP". Under Standard ABAP, you have access to the entire legacy runtime. You can create executable reports with SE38, design Dynpro screens, use classic selection screens, and execute Open SQL queries against almost any standard SAP table.

ABAP Cloud uses the restricted language version known as "ABAP for Cloud Development". In this environment, the compiler blocks outdated statements and unreleased dependencies:

  • You cannot create Dynpro screens, subroutines, classic list statements (such as WRITE), or executable reports.
  • You cannot write direct SQL queries against unreleased SAP tables like VBAK, MARA, or ACDOCA.
  • You cannot call unreleased function modules or BAPIs (Business Application Programming Interfaces).
  • You must use ADT (ABAP Development Tools, the Eclipse-based IDE) because SE80 and SE38 cannot edit ABAP Cloud objects.

You set the ABAP language version per development object in ADT. In the object properties view, open the General tab, look for ABAP Language Version, and select either "Standard ABAP" or "ABAP for Cloud Development".

Pro Tip: When Harbor Supply Co. migrates to S/4HANA, existing custom programs like ZSD_ORDER_STATUS continue to run as Standard ABAP. However, if the development team builds a new customer-facing status portal, they should set the language version to ABAP for Cloud Development and use released CDS views.


Working with Released APIs and CDS Views

In ABAP Cloud, you can only reference SAP objects that carry a formal release contract. For ABAP Cloud development, the contract to look for is C1, which means the object is released for use in cloud development and SAP keeps it stable across upgrades.

If your program needs data from the sales order tables, you do not query table VBAK directly. Instead, you query a released CDS (Core Data Services) view entity provided by SAP. SAP names many of these released interface views with the prefix I_.

Here is how data retrieval changes when moving from classic ABAP database queries to an ABAP Cloud development model:

Standard ABAP:

abap
Copy

ABAP Cloud:

abap
Copy

If you try to write SELECT FROM vbak inside an object set to "ABAP for Cloud Development", the syntax check reports an error because VBAK is not a released object.

You can inspect released APIs directly inside ADT. In the Project Explorer, open the system library and navigate to the Released Objects node. You can search by object type to locate released CDS views, released classes, and released data types.


Extension Architectures: On-Stack and Side-by-Side

Clean core provides two distinct architectural paths for building new functionality: on-stack extensions and side-by-side extensions.

On-Stack Extensions with RAP

On-stack extensions run directly inside the SAP S/4HANA system database and application layer. You use this model when custom logic requires high-speed access to large volumes of local enterprise data or needs to execute within standard database transactions.

The modern transactional framework for on-stack ABAP Cloud development is RAP (ABAP RESTful Application Programming Model). RAP replaces old frameworks such as BOPF (Business Object Processing Framework) and classic dialog transactions. In RAP, you define:

  1. CDS view entities for the data model.
  2. Behavior definitions to declare transactional capabilities such as create, update, and delete.
  3. Behavior implementation classes written in ABAP to implement custom validation and calculation logic.
  4. Service definitions and service bindings to expose the application as an OData service for SAP Fiori user interfaces.

Side-by-Side Extensions on SAP BTP

Side-by-side extensions run outside the S/4HANA system on SAP BTP. You use this architecture for independent apps, external partner portals, mobile applications, or applications that integrate with multiple non-SAP systems.

SAP BTP communicates with SAP S/4HANA using secure protocols such as OData services or RFC (Remote Function Call) connections managed through the SAP Cloud Connector. Because the extension runs on BTP, its workload does not use compute resources on your S/4HANA system, and S/4HANA upgrades have less impact on the external application.


Managing Your Migrated Custom Code Base

During a system conversion, Harbor Supply Co. brings thousands of custom objects into S/4HANA. How should your development team organize and manage this code? A practical custom code strategy follows three paths:

1. Maintain in Standard ABAP (Level B/C)

Programs like ZMM_STOCK_MOVES and ZSD_PRICE_EXPORT are remediated for data model changes (such as MATDOC and PRCD_ELEMENTS) and kept in Standard ABAP. They continue to run as classic reports. You do not spend time rewriting working batch jobs into RAP or ABAP Cloud unless a major business change requires a complete redesign.

2. Encapsulate Legacy Access

If custom programs must access unreleased SAP objects or legacy tables, wrap those reads inside a custom wrapper class. This design keeps Level C dependencies isolated in one place. When SAP later releases a standard API for that function, you only need to update the wrapper class rather than multiple calling programs.

3. Build New Developments in ABAP Cloud (Level A)

Create a dedicated ABAP software component or custom package tree in ADT with the language version set to ABAP for Cloud Development. Mandate that all brand-new reporting, interfaces, and SAP Fiori transactional apps are created in this package. This practice prevents the accumulation of fresh technical debt.


Try It Yourself

Explore how ADT manages language versions and released APIs by completing this exercise in your S/4HANA system:

  1. Open ADT (Eclipse) and connect to your development system.
  2. In the Project Explorer, expand your system connection, open System Library, and expand Released Objects.
  3. Locate Core Data Services and browse the released view entities available under Data Definitions. Check the properties of view I_SalesOrder to see its release state (Contract C1).
  4. Create a test package named ZTEST_CLEAN_CORE or use an existing sandbox package.
  5. In the Properties view of the package, locate the ABAP Language Version setting. Notice whether it is set to Standard ABAP or ABAP for Cloud Development.
  6. Create a simple test class inside this package. Try writing a SELECT statement directly against table VBAK.
  7. Change the class ABAP Language Version property to "ABAP for Cloud Development" and run the syntax check (Ctrl+F2). Observe the error message produced by the compiler.
  8. Replace the direct VBAK query with a SELECT from I_SalesOrder using modern syntax, and run the syntax check again.

In the next lesson, Testing, Cutover and AI-Assisted Custom Code Remediation, you will learn how to plan regression tests, manage cutover transports, monitor short dumps after go-live, and use AI-assisted tools responsibly during remediation.

Was this lesson helpful?