ERPClimb logoERPClimb
Draft Handling
RAP / CDS / ODataadvanced 9 min read

Draft Handling Part 4: Validations, Determinations and Side Effects in Draft

Preview · a free account unlocks the full lesson

Key takeaway

Place business logic correctly in draft-enabled objects: which determinations run on modify, which on save, how Prepare surfaces validation errors, how messages stay in sync with %state area, and how side effects keep the UI current.

In this lessonShow sections

Visual overview

Draft Handling Part 4: Validations, Determinations and Side Effects in Draft — learning sheetFlow: Check each determination: on modify (user sees it) or on save (only once)? → Put all user-relevant validations into Prepare → Add %state_area and %element to every validation message → Add side effects for every derived field. Key ideas: DETERMINATIONS ON MODIFY; DETERMINATIONS ON SAVE; VALIDATIONS AND PREPARE; MESSAGES THAT BEHAVE IN DRAFT. Watch out: WATCH OUT: an on-save determination that draws a number during every Prepare would waste numbers — keep number assignment on save (or late numbering).ERPClimb.com / RAP / LESSON 4/5 / LEARNING SHEETDraft Handling Part 4: Validations, Determinations andSide Effects in Draft1 · HOW IT FLOWS1Check eachdeterminationon modify (user sees it)or on save (only once)?2Put alluser-relevantvalidations into…3Add %state_areaand %element toevery validation…4Add side effectsfor everyderived field2 · KEY IDEAS EXPLAINEDDeterminations On ModifyRun after each triggering change in the draft (afield change is a request).Use for values the user must see immediately:default status, item totals, derived descriptions.Determinations On SaveRun once during activation (save sequence,finalize).Use for values that must be assigned only once oronly when the data becomes real: numbers from anumber range, final approval data.Validations And PrepareValidations always run in the save sequence atactivation.In draft, users need errors before activation:list validations in "draft determine actionPrepare { validation … ; }". Fiori calls…Messages That Behave In DraftEach validation first appends an empty messagewith its %state_area for every checked instance(this clears older messages from the same…Then it appends errors with the same %state_area,%element for the field and a message class text.3 · REMEMBER · WATCH OUTRememberon modify determinations run on every draft change — the user seesresults while typing.on save determinations run only at activation (e.g. document numbers).Validations run when listed in Prepare (Save click) and again atactivation.!Watch outWATCH OUT: an on-save determinationthat draws a number during everyPrepare would waste numbers — keepnumber assignment on save (or latenumbering).4 · IN A REAL PROJECTIn a draft app, request numbers had large gaps: 4711, 4719, 4726. The number assignment was implemented as adetermination on modify, so every draft — including abandoned ones — consumed a number, and some drafts drewnumbers several times. Moving it to an on-save determination (later to late numbering for strict gap-free…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Determinations marked "on modify" run on every draft change, so the user sees the results while still typing. Determinations marked "on save" run only once, at activation — appropriate for things like document numbers. Validations run when they're listed in Prepare, which fires on a Save click, and again at activation. Side effects are what make Fiori reload derived fields immediately rather than leaving them stale.

Parts 1 through 3 covered draft mechanics. Draft changes when your logic actually runs, because users make many small changes before ever activating, so this part is about where each piece of logic belongs in that timeline.

Determinations on modify run after each triggering change in the draft — a single field change counts as one request. They're the right place for values the user needs to see immediately: a default status, item totals, derived descriptions. Because they may run dozens of times in a single session, they need to be cheap and idempotent. Combined with side effects, they let the UI show a new value without any manual refresh.

Determinations on save run exactly once, during activation, as part of the save sequence's finalize step. They belong wherever a value must be assigned only once, or only once the data becomes real — a number drawn from a number range, or final approval data. One thing to watch for: an on-save determination that draws a number on every single Prepare call would waste numbers, so number assignment should stay on save, or use late numbering instead.

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.