Fiori Elements Part 4: Extending Apps with the Flexible Programming Model
Lessons are open to try during our launch period. Some advanced content may move to Pro later. AI practice limits apply separately.
Learn how to add custom logic, actions, and UI fragments to a generated Fiori Elements app without breaking the annotation-driven contract, using the flexible programming model's controller extensions and extension points.
In this lessonShow sectionsHide sections
Visual overview
Expert visual walkthrough
Extending Apps with the Flexible Programming Model
Fiori Elements · Chapter-specific technical teaching map
Architecture hierarchy
App view
Controller / model
OData binding
Backend service
Tutor's chapter takeaway
Learn how to add custom logic, actions, and UI fragments to a generated Fiori Elements app without breaking the annotation-driven contract, using the flexible programming model's controller extensions and extension points.
In a real project
On a sales order management RAP app, business asked for an 'Escalate to Manager' button that appears only for orders over a threshold value and in 'Pending' status, sends a custom action to update escalation flag and log a…
Watch out for
• Implementing an entire custom action in JavaScript on the frontend instead of exposing it as a proper RAP custom action, bypassing draft and authorization consistency checks • Forgetting Common.SideEffects annotations after…
The situation: a real project scenario
On a sales order management RAP app, business asked for an 'Escalate to Manager' button that appears only for orders over a threshold value and in 'Pending' status, sends a custom action to update escalation flag and log a note, then automatically refreshes the approval status field and re-evaluates the exception icon in the list report line.
Explanation
Part 3 covered what annotations can do. Some requirements go beyond them, and the flexible programming model handles those without ever leaving the Fiori Elements floorplan.
The flexible programming model is available for Fiori Elements on OData V4, and it lets generated floorplans be mixed with custom UI5 fragments and controller code at defined extension points, while the app still stays a genuine Fiori Elements app — floorplan updates continue to apply as usual.
Several extension points are available: a custom section on the object page, built as a fragment with its own content; a custom column in a table, for something like a chart or special formatting; a custom action in a toolbar or header, handled by a controller; controller extensions, such as onBeforeSave hooks, for lifecycle logic; and building blocks, or macros, like Table, Chart and Field, usable inside custom sections.
Configuration happens in manifest.json, where extensions get registered under the page target's settings — content, body, sections, controlConfiguration, actions. SAP Fiori tools' Page Map generates these entries and stubs automatically, and each extension is best kept in its own fragment or controller file.
Where the logic belongs matters a great deal: business rules stay in the RAP BO — validations, determinations, feature control — while UI extension code should only present or orchestrate. A custom action that changes data should call a RAP action rather than ever writing data itself.
Annotations should always come first: before reaching for an extension, the annotation reference should be checked for a standard solution, since every extension is code that has to be tested and maintained through each UI5 upgrade — and it's worth documenting why a given extension was actually needed.
In practice: confirm the requirement genuinely can't be met with annotations, use the Page Map to add a custom section or action, implement the fragment or controller calling the OData V4 model or a RAP action, and test both with draft and with a user who lacks authorization. With that, the custom section appears on the object page and the standard Edit/Save flow still works as expected.
Code example
// ===== manifest.json: custom section on the object page (flexible programming model) ====="sap.ui5": { "routing": { "targets": { "PurchaseRequestObjectPage": { "type": "Component", "name": "sap.fe.templates.ObjectPage", "options": { "settings": { "contextPath": "/PurchaseRequest", "content": { "body": { "sections": { "approvalHistory": { // custom section "template": "zpurchreq.ext.fragment.ApprovalHistory", "title": "Approval History", "position": { "placement": "After", "anchor": "Items" } // anchors the custom section relative to a standard one by its facet id } } } }, "controlConfiguration": { "_Item/@com.sap.vocabularies.UI.v1.LineItem": { "actions": { "checkStock": { // custom table action "press": "zpurchreq.ext.controller.ItemActions.onCheckStock", "text": "Check Stock", "requiresSelection": true // button stays disabled until at least one row is selected } } } } } } } } }} <!-- ===== ext/fragment/ApprovalHistory.fragment.xml ===== --><core:FragmentDefinition xmlns:core="sap.ui.core" xmlns="sap.m"> <List items="{path: '_ApprovalLog', parameters: {$orderby: 'ChangedAt desc'}}"> <StandardListItem title="{ApprovedBy}" description="{Comment}" info="{ChangedAt}" /> </List></core:FragmentDefinition> // ===== ext/controller/ItemActions.js =====sap.ui.define(["sap/m/MessageToast"], function (MessageToast) { "use strict"; return { onCheckStock: function (oContext, aSelectedContexts) { // keep logic small; business checks belong in a RAP action MessageToast.show(aSelectedContexts.length + " item(s) checked"); } };}); // Rule: annotations first -> building blocks / extensions only for the restWatch out
Common mistakes
- Implementing an entire custom action in JavaScript on the frontend instead of exposing it as a proper RAP custom action, bypassing draft and authorization consistency checks
- Forgetting Common.SideEffects annotations after a custom action changes dependent fields, leaving the UI showing stale data
- Modifying generated fragment/controller files directly instead of using controller extensions, which breaks on the next code regeneration or app update
- Mixing key-user adaptation changes with developer extensions in a way that creates layer conflicts and unpredictable precedence at runtime
- Not testing custom actions with concurrent drafts, causing lock or ETag conflicts in production that were never seen in single-user dev testing
Do this
Best practices
- Prefer annotation-driven solutions (UI.Applicable, UI.Hidden, Validation, Determination) before reaching for controller extensions
- Always pair a custom action or determination that changes dependent fields with an explicit Common.SideEffects annotation
- Keep custom logic in the RAP behavior pool, not scattered in frontend JavaScript, to preserve consistency, authorization checks, and testability
- Use manifest.json extension points and controller extensions rather than touching generated artifacts directly
- Document each extension point used and its extensibility category (key user vs developer) for upgrade impact assessments
In the interview
Interview angle
Interviewers probe whether you understand the difference between annotation-only design and flexible programming model extensions, and whether you know when NOT to extend (i.e., prefer declarative solutions). Be ready to explain SideEffects, extension points in manifest.json, and the layered extensibility model (key user vs developer, cloud vs on-premise) as this signals real hands-on RAP+Fiori Elements delivery experience rather than tutorial-level exposure.
Practice this lesson
Quick check
0 of 3 questions attempted
Question 1 of 3
A requirement needs an approval-history section that annotations cannot express. What is the recommended approach?
Question 2 of 3
In a RAP-based Fiori Elements application, what is the main purpose of side effects annotations?
Question 3 of 3
Which annotation allows a field's editability to be determined dynamically at runtime based on the value of another field, rather than being statically fixed in the UI?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1Where should business validations live in a RAP-based Fiori Elements application?
2A requirement cannot be met with annotations alone. How do you extend a Fiori Elements app?
See it in code
Each example starts from a requirement, shows the design, then the code step by step with a plain-language explanation of every part.
Was this lesson helpful?
Keep exploring
Interview questions on this topic
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.