Behavior Definitions Part 3: Actions, Functions, Determinations and Validations
Preview · a free account unlocks the full lesson
Declare business logic in the BDEF correctly: instance, static, factory and internal actions, actions with parameters, functions, determinations with the right triggers, validations, determine actions and side effects.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 2 covered operations and fields; this part covers the declarations that carry business logic, each of which becomes a method in the behavior pool, as shown in the Behavior Implementations series.
Actions represent explicit business steps. An instance action, written as "action approve result [1] $self;", works on selected instances and returns them. A static action, "static action createFromTemplate result [1] $self;", needs no instance.
A factory action, "factory action copyRequest [1];", creates new instances — for example a copy — and returns them via MAPPED, and a static factory action combines both with "static factory action createDefault [1];". An internal action, "internal action recalcTotal;", is only callable inside the BO.
Actions can take a parameter, as in "action reject parameter ZD_RejectReason result [1] $self;", where the parameter is an abstract CDS entity such as "define abstract entity ZD_RejectReason { Reason : abap.char(100); }", which Fiori renders as a dialog.
The result can be [1] $self for the same entity, [0..*] or [1] of another entity, or no result at all, and options like ( features : instance ), ( authorization : update ) and ( precheck ) refine the declaration further.
Functions are read-only operations. "function getApprovalPath result [0..*] ZD_ApprovalStep;" returns calculated data without changing anything, and is the right choice when a consumer needs computed information that shouldn't be a CDS field — for instance because it's expensive to calculate or depends on buffer state.
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
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.