In legacy ECC systems, developers modified standard logic by inserting code into user exits (USEREXIT_...), implicit enhancements (Enhancement Spots), or modifying SAP include programs. This created severe regression risks during system upgrades.
In SAP S/4HANA Clean Core, modifying standard code is forbidden. For released SAP standard RAP business objects (such as I_SalesOrderTP or I_PurchaseOrderTP_2), SAP provides Behavior Extensions powered by two distinct capabilities:
augment): Allows customer extensions to inject additional data or child entities into a standard operation before the standard behavior logic executes.precheck): Allows customer extensions to evaluate custom business rules and reject invalid requests early, before standard determinations, validations, or enqueue locks take place.| Execution Phase | Hook Type | Triggered In | Primary Architectural Purpose |
|---|---|---|---|
| Phase 1: Early Filter | precheck |
Extension Behavior Handler | Validate custom business invariants without locking resources |
| Phase 2: Data Injection | augment |
Extension Behavior Handler | Append custom child records, default values, or sustainability tags |
| Phase 3: Core Execution | Standard create / update |
SAP Standard Managed BO | Standard validation, determination, and pricing engine execution |
| Phase 4: Late Validation | validation |
Extension Behavior Handler | Cross-field validations during draft prepare / save |
augment
When an end user creates a Sales Order via SAP Fiori, the augment method intercepts the incoming payload. The extension can dynamically create dependent custom extension entities using MODIFY AUGMENTING ENTITIES:
CLASS lhc_salesorder IMPLEMENTATION.
METHOD augment_create.
DATA lt_children TYPE TABLE FOR CREATE I_SalesOrderTP\_CarbonScore.
LOOP AT entities ASSIGNING FIELD-SYMBOL(<entity>).
APPEND VALUE #(
%cid_ref = <entity>-%cid
%target = VALUE #( (
%cid = |EXT_{ <entity>-%cid }|
CarbonScorePPM = 120
) )
) TO lt_children.
ENDLOOP.
MODIFY AUGMENTING ENTITIES OF I_SalesOrderTP
ENTITY SalesOrder
CREATE BY \_CarbonScore FROM lt_children.
ENDMETHOD.
ENDCLASS.
precheck for High Performance
The precheck method runs before the transactional buffer is modified and before SAP Enqueue locks are engaged. Rejecting an invalid transaction inside precheck incurs negligible CPU overhead compared to triggering a full rollback during late validations.
METHOD precheck_create.
LOOP AT entities ASSIGNING FIELD-SYMBOL(<entity>).
IF <entity>-NetAmount > 50000.
APPEND VALUE #( %cid = <entity>-%cid ) TO failed-salesorder.
APPEND VALUE #(
%cid = <entity>-%cid
%msg = new_message_with_text(
severity = if_abap_behv_message=>severity-error
text = 'Order value exceeds maximum threshold (Clean Core Governance)'
)
) TO reported-salesorder.
ENDIF.
ENDLOOP.
ENDMETHOD.
precheck. It must be a pure, read-only decision gate.%cid_ref Mappings: In augment, failing to link child entities to the root using %cid_ref causes RAP to lose correlation, resulting in unassigned orphan records.C1 (Use in Cloud Development). Extending unreleased internal standard BDEFs creates upgrade breaks.Generate validated BDEF extension definitions, augment methods, and pre-check handlers with our interactive tool.
Launch Augmentation Architect ⚡ Get Architecture Suite (80% Off)