ERPClimb logoERPClimb
Behavior Implementations
RAP / CDS / ODataintermediate 12 min read

Behavior Implementations Part 3: Actions, Results and User-Facing Messages

Preview · a free account unlocks the full lesson

Key takeaway

Implement every kind of RAP action correctly — instance actions with results, actions with parameters, factory actions with MAPPED — and give users clear, translatable messages from message classes.

In this lessonShow sections

Visual overview

Behavior Implementations Part 3: Actions, Results and User-Facing Messages — learning sheetFlow: Create message class ZPR with the texts your actions need → Implement approve (instance action), reject (parameter), copyRequest (factory) as in the code example → Test with EML: approve two requests where one exceeds the limit — expect one success and one failure with a message → Test the reject dialog in Fiori preview. Key ideas: INSTANCE ACTION WITH RESULT; ACTION WITH PARAMETER; FACTORY ACTION; STATIC ACTION. Watch out: Never trust the UI button state — use feature control.ERPClimb.com / RAP / LESSON 3/5 / LEARNING SHEETBehavior Implementations Part 3: Actions, Results andUser-Facing Messages1 · HOW IT FLOWS1Create messageclass ZPR withthe texts your…2Implementapprove(instance…3Test with EMLapprove two requestswhere one exceeds the…4Test the rejectdialog in Fioripreview2 · KEY IDEAS EXPLAINEDInstance Action With ResultPattern for "action approve result [1]$self":Action With ParameterFor "action reject parameter ZD_RejectReasonresult [1] $self", each key carries the inputin %param: keys[ … ]-%param-Reason. Validate the…Factory ActionFor "factory action copyRequest [1]",each key has a %cid supplied by the caller. Theimplementation creates new instances with MODIFY…Static ActionStatic actions have no instance keys; keys containonly %cid (and %param). Typical use: create from atemplate, or trigger a mass process. Authorization…3 · REMEMBER · WATCH OUTRememberAction pattern: check → MODIFY in local mode → READ → fill result.Parameters arrive in keys-%param.Factory actions use the caller's %cid and return MAPPED.!Watch outNever trust the UI button state —use feature control.4 · IN A REAL PROJECTAn Approve action updated every selected request, trusting that the Fiori button was only enabled forsubmitted requests. An integration later called the action through the API for requests in status New andapproved them, bypassing the workflow. Two changes fixed it: instance feature control for approve (so RAP…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 2 covered automatic logic. Actions are the explicit business steps that users and APIs trigger, and this part shows the implementation pattern for each action type along with how to communicate the results.

For an instance action with a result — "action approve result [1] $self" — the pattern is to optionally read and check preconditions that feature control doesn't already cover, such as amount limits, reporting failures per instance where needed, then run MODIFY ENTITIES … IN LOCAL MODE for the valid instances, and finally READ ENTITIES … ALL FIELDS for those instances to fill the result with %tky and %param set to the instance, so the UI refreshes without a reload.

IN LOCAL MODE matters here because the action changes read-only fields such as Status, which ordinary consumers aren't allowed to change directly.

The UI's button state should never be trusted on its own, since an API can call any action regardless of what the UI shows — feature control automatically rejects calls made in the wrong state, and any additional business checks belong inside the action itself, or in a precheck.

An action with a parameter, such as "action reject parameter ZD_RejectReason result [1] $self", receives its input in %param on each key — for example keys[ … ]-%param-Reason. The parameter should be validated, for instance making the reason mandatory and reporting a failure if it's missing, and Fiori Elements automatically shows a dialog built from the abstract entity's fields.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

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.