← Back to Clean Core Architecture Hub
CLEAN CORE ARCHITECTURAL GUIDE #12

SAP S/4HANA Key-User In-App Extensibility Architecture & Rules

Author: Andrea Antonio Perrelli Scope: SAP S/4HANA Cloud (Public/Private) & On-Premise 2022+ Extensibility Tier: Tier-1 In-App (Low-Code / No-Code)
Core Principle: In the SAP Clean Core paradigm, Tier-1 In-App Extensibility empowers functional business analysts and key users to add custom fields, business logic, and UI adjustments directly in the SAP Fiori launchpad without writing ABAP reports, creating Dynpro screens, or modifying core database tables.
Limited Time Deal

Master S/4HANA Clean Core Architecture & Extensibility

Get the Complete SAP Enterprise Architecture Suite: 40 Retina architecture diagrams, 61 production-grade code listings, and decision frameworks. Use code FLASH80 at checkout for 80% OFF.

1. The 3-Tier Extensibility Placement of Key-User In-App

SAP defines three distinct extensibility tiers. Determining whether an extension belongs in Tier-1 In-App vs. Developer Extensibility is the first governance gate of Clean Core architecture:

Dimension Tier-1: Key-User In-App Tier-1: Developer Extensibility Tier-3: Side-by-Side (BTP)
Target Persona Business Key Users, Functional Consultants SAP Professional Developers, ABAP Architects Cloud Developers, Full-Stack Engineers
Tooling SAP Fiori Custom Fields & Custom Logic Apps ABAP Development Tools (ADT) in Eclipse SAP Business Application Studio (BAS), VS Code
Language / Runtime Restricted ABAP (Cloud Language Version 2) ABAP Cloud (Language Version 5) Node.js (CAP), Java (Spring Boot / CAP), Python
Namespace YY1_* prefix (strictly enforced) Customer Z* / Y* or Partner namespace Custom microservice domain / CF Space
Lifecycle / Transport Export / Import Software Collection (Fiori) Standard Transport Organizer (Workbench Request) Git CI/CD Pipeline (Cloud Transport Mgmt)
Clean Core Score 100% (Level A) — Upgrade-safe zero regression 100% (Level A) — Contract-based releases 100% (Level A) — Complete physical decoupling

2. Business Contexts: The Extensibility Foundation

In SAP S/4HANA, custom fields cannot be arbitrarily attached to database tables via classic APPEND STRUCTURE. Instead, SAP provides pre-engineered Business Contexts that bundle:

Standard Enterprise Business Context Examples

Business Context Identifier Domain / Entity Underlying Tables Extracted Available Extensibility Points
SALESDOCUMENT Sales Order Header VBAK Fiori VA01/02/03, OData API_SALES_ORDER, Cloud BAdI
SALESDOCUMENTITEM Sales Order Item VBAP Item UI, Pricing Determination, BAdI Calculations
PURCHASINGDOCUMENT Purchase Order Header EKKO ME21N/22N/23N Fiori equivalents, Cloud BAdI Validation
PURCHASINGDOCUMENTITEM Purchase Order Line Item EKPO Accounting derivation, Confirmation interfaces
BUSINESS_PARTNER Business Partner Master BUT000 Manage Business Partner Fiori App, BP SOAP/OData API
PRODUCTMASTER Product / Material Master MARA Manage Product Master Data, Stock valuation views

3. The Restricted ABAP Sandbox: Syntax Rules

Key-User Custom Logic executes in a sandboxed, security-hardened environment known as Restricted ABAP (Language Version 2). This guarantees that custom business logic cannot crash the application server, corrupt memory, or introduce SQL injection vulnerabilities.

Strict Prohibition: Any statement that performs imperative database mutations (INSERT, UPDATE, DELETE), triggers database commits (COMMIT WORK), opens classic dynpro screens (CALL SCREEN), or accesses unreleased standard tables is completely disabled at compile time.

Allowed vs. Forbidden Statements in Restricted ABAP

Category Permitted Statements (Allowed) Forbidden Statements (Blocked at Syntax Check)
Database Operations Read-only SELECT on C1-released CDS Views; READ ENTITIES OF (EML) on released RAP BOs. INSERT, UPDATE, MODIFY, DELETE, EXEC SQL, Open SQL on raw tables.
Transaction Control None. Transaction commit is managed strictly by the caller framework. COMMIT WORK, ROLLBACK WORK, CALL TRANSACTION, SUBMIT.
Flow Control & Logic IF / ELSEIF / ENDIF, CASE / WHEN, LOOP AT ... INTO, CHECK, RETURN. GOTO, CALL FUNCTION 'BAPI_*', CALL SCREEN, LEAVE TO TRANSACTION.
Internal Tables APPEND, INSERT INTO TABLE, READ TABLE ... WITH KEY, SORT, DELETE ... WHERE. Obsolete Header Lines, Tables with obsolete types, uncontrolled pointer manipulation.
String & Math CONCATENATE, SPLIT, CONDENSE, TRANSLATE, built-in string functions. Direct memory manipulation, EXPORT / IMPORT MEMORY ID.
System Information cl_abap_context_info=>get_user_technical_name( ), get_system_date( ), get_system_time( ). Direct read/write on system variables (sy-uname, sy-datum directly modified).

4. Production Code Blueprint: Key-User Custom Logic

The following is a production-grade implementation of an S/4HANA Key-User Custom Logic enhancement for the SALESDOCUMENT context, calculating order prioritization and validating compliance:

" Business Context: SALESDOCUMENT
" Extension Point: BAdI Definition 'SD_SLS_MODIFY_HEAD' (Sales Order Header Modification)
" Language Version: Restricted ABAP (Language Version 2)

CLASS zcl_keyuser_sales_logic DEFINITION PUBLIC FINAL CREATE PRIVATE.
  " In Key-User Custom Logic, class scaffolding is handled by SAP Fiori
ENDCLASS.

" Implementation logic injected into Custom Logic Fiori App:
DATA: lv_user      TYPE syuname,
      lv_sys_date  TYPE sydatum,
      lv_amount    TYPE p DECIMALS 2.

" 1. Retrieve runtime context via released system utility
lv_user     = cl_abap_context_info=>get_user_technical_name( ).
lv_sys_date = cl_abap_context_info=>get_system_date( ).

" 2. Guard Clause: Skip execution if sales order is already locked for billing
CHECK salesdocument-billingblockstatus IS INITIAL.

" 3. Custom Field Derivation (YY1_ApprovalRequired_SDH)
" If net amount exceeds threshold, enforce mandatory VP approval flag
IF salesdocument-totalnetamount > 50000.
  salesdocument-yy1_approvalrequired_sdh = abap_true.
  salesdocument-yy1_approvernotes_sdh    = 'High-value order exceeding 50,000 EUR threshold'.
ELSE.
  salesdocument-yy1_approvalrequired_sdh = abap_false.
ENDIF.

" 4. Audit Trail Population
salesdocument-yy1_lastauditedby_sdh   = lv_user.
salesdocument-yy1_lastauditeddate_sdh = lv_sys_date.

" 5. Validation Check: Raise business message if delivery block missing on restricted accounts
IF salesdocument-yy1_customerrisklevel_sdh = 'HIGH' AND salesdocument-deliveryblockreason IS INITIAL.
  " Raise message into SAP Fiori message log
  messages-add_message(
    iv_msgid = 'ZSD_CLEAN_CORE'
    iv_msgno = 001
    iv_msgty = 'E'
    iv_msgv1 = 'High-risk customer requires an active Delivery Block reason'
  ).
ENDIF.

5. The Custom Field Enablement Pipeline

Creating a custom field via the Custom Fields app is only the first step. To make it functional, it must be published through the enablement pipeline:

  1. Field Definition: Enter Field Label, Tooltip, and select Data Type (Text, Number, Date, Amount, or Code List).
  2. Business Context Binding: The system automatically assigns the YY1_ prefix and provisions the field in the underlying CDS views.
  3. UIs & Reports Enablement: Enable visibility on target SAP Fiori applications (e.g., Manage Sales Orders, Manage Customer Returns).
  4. OData APIs & SOAP Enablement: Expose the field to standard released OData APIs for Tier-3 BTP consumption.
  5. CDS Views Exposing: Automatically propagate the custom field into analytical cube and projection views without manual DDL edits.
  6. Publishing: Trigger automated generation of active CDS artifacts and DDL extensions.
  7. Transport Packaging: Add the field to an Export Software Collection for staging and production import.

6. Decision Tree: Key-User vs. Developer vs. Side-by-Side

Use this architectural decision tree to determine the correct placement for any incoming extension request:

Extensibility Placement Gate:

  1. Does the requirement only involve adding descriptive fields, simple validations, or adapting standard Fiori UI screens?
    YES → Tier-1 Key-User In-App Extensibility (Custom Fields & Logic App).
  2. Does the requirement need custom tables, RAP business objects, complex background processing, or developer BAdIs?
    YES → Does it require tight transactional coupling with core ERP data?
    • YES → Tier-1 Developer Extensibility (ABAP Cloud in ADT).
    • NO → Tier-3 Side-by-Side Extensibility (SAP BTP CAP / Event Mesh).

Recommended Clean Core Developer Tools

Explore free client-side interactive utilities to accelerate your S/4HANA migration:

🛠️ Key-User In-App Builder 🧭 Decision Wizard & ADR 🎯 Readiness Assessment 🧩 Developer BAdI Generator

Accelerate Your SAP Transformation

Get complete architectures, downloadable code listings, and decision frameworks in the official handbooks.