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

Behavior Definitions Part 2: CRUD, Field Control, Numbering, Locking and Authorization

Preview · a free account unlocks the full lesson

Key takeaway

Master the syntax options for standard operations, field characteristics, numbering, locking and authorization — including internal operations, prechecks, readonly:update, mandatory:create and authorization:none.

In this lessonShow sections

Visual overview

Behavior Definitions Part 2: CRUD, Field Control, Numbering, Locking and Authorization — learning sheetFlow: For each field of your BO, decide: readonly, readonly:update, mandatory, mandatory:create, dynamic, or unrestricted → For each operation, decide: public, internal, feature-controlled, prechecked → Write the declarations; activate; generate methods with Ctrl+1 → Test with EML: try to set a readonly field — RAP rejects it without any code. Key ideas: STANDARD OPERATIONS AND THEIR OPTIONS; FIELD CHARACTERISTICS; NUMBERING; LOCKING. Watch out: authorization : none must be deliberate and documented.ERPClimb.com / RAP / LESSON 2/5 / LEARNING SHEETBehavior Definitions Part 2: CRUD, Field Control,Numbering, Locking and Authorization1 · HOW IT FLOWS1For each fieldof your BO,decide…2For eachoperation…public, internal,feature-controlled…3Write thedeclarations;activate…4Test with EMLtry to set a readonlyfield — RAP rejects it…2 · KEY IDEAS EXPLAINEDStandard Operations And Their Optionscreate; update; delete; — available to allconsumers.internal create/update/delete — only callable frominside the BO (IN LOCAL MODE), e.g. a child thatis only created by an action.Field Characteristicsreadonly — consumers can never set it; the BO setsit (status, totals, admin fields).readonly : update — can be set on create, notchanged later (e.g. an external document number).Numberingfield ( readonly, numbering : managed ) Key; —managed UUID key.early numbering (entity header) — yourearlynumbering_create method assigns keys atcreate.Lockinglock master — this entity is locked (normally theroot).lock dependent by _Parent — lock via the parentassociation.3 · REMEMBER · WATCH OUTRememberreadonly, readonly : update, mandatory, mandatory : create, features :instance.precheck rejects input before it enters the buffer.internal operations are callable only inside the BO.!Watch outauthorization : none must bedeliberate and documented.4 · IN A REAL PROJECTA requisition BO had about 400 lines of code in its update handler logic (validations and a precheck-likeroutine) whose only purpose was to reject changes to system fields and to the external reference aftercreation. Reviewing the BDEF, the team replaced this code with three lines: field ( readonly ) for the system…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 1 showed the overall structure of the behavior definition. This part works as a reference for the most frequently used options, covering for each one what it means and when to use it.

For the standard operations, create, update and delete are available to all consumers by default. Marking an operation internal create, internal update or internal delete restricts it to being callable only from inside the BO itself, in IN LOCAL MODE — useful, for instance, for a child that is only ever created by an action.

The option ( features : instance ) lets an operation be enabled or disabled per instance via get_instance_features. The option ( precheck ) runs a precheck method before the operation reaches the buffer, which is useful for rejecting obviously invalid input early, such as before draft data gets written.

The option ( authorization : none ) switches off the authorization check for that operation entirely, and should be used deliberately and documented. The option ( authorization : update ) lets an action or operation be checked using the same instance authorization as update.

Field characteristics follow the syntax field ( <characteristic> ) Field1, Field2;. readonly means consumers can never set the field — it's the BO itself that sets it, for things like status, totals, or admin fields. readonly : update means the field can be set on create but never changed afterward, such as an external document number. mandatory means the field must be filled, with Fiori marking it and RAP reporting any missing value, while mandatory : create narrows that requirement to create only. features : instance defers the readonly/mandatory decision to runtime, inside get_instance_features. numbering : managed has the framework assign a UUID key, typically combined with readonly. suppress hides a field from the BO interface entirely, and is available on newer releases.

As much of this as possible should be declared here rather than checked in code.

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.