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

Behavior Implementations Part 2: Determinations and Validations Without Side Effects

Preview · a free account unlocks the full lesson

Key takeaway

Write determinations and validations that are safe to run any number of times: idempotent logic, the right triggers, set-based EML in local mode, no side effects outside the BO, and messages that disappear once fixed.

In this lessonShow sections

Explanation

Part 1 showed the structure of the behavior pool. Determinations and validations are the methods written most often — and the easiest to get subtly wrong.

RAP decides when these methods run, and crucially, they can run more than once: several triggers can fire in one request, draft Prepare runs them, and then save runs them again. This is what "without side effects" really means in practice. Determinations must be idempotent, so that running one twice gives the same result as running it once.

Validations must only read and report, never changing data. And neither may cause effects outside the BO — no database writes, no RFC or HTTP calls, no e-mails, no COMMIT — since effects like that belong in the save phase or after the commit instead.

The determination pattern follows a consistent shape: READ ENTITIES … IN LOCAL MODE for all keys, requesting only the fields actually needed; filter out any instances that need no change at all, such as ones whose status is already set — this filtering step is exactly what makes the determination idempotent; issue one MODIFY ENTITIES … IN LOCAL MODE for the remaining instances; and pass along any messages from that MODIFY into reported if needed.

It's worth avoiding determinations that modify the very fields that trigger them, since they can end up triggering themselves repeatedly, and keeping triggers narrow — "field Quantity, Price" rather than every field — helps avoid that trap.

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.