RAP action versus function: Match the service operation to its effect
A manufacturer's RAP application offers a read-only preview and a state-changing operation around a component request.
START HERE · NO PRIOR TOPIC KNOWLEDGE NEEDED
What it is. Why it matters.
RAP is SAP’s ABAP model for business objects and services. An action performs an operation; a function provides a read-oriented operation under its contract, so clients must call the right kind.
Completely new to SAP?
Manufacturers use SAP to connect work such as buying components, recording inventory, planning production, shipping equipment and accounting for costs. SAP S/4HANA is an enterprise resource planning system: it connects these activities through shared business data.
ABAP is SAP’s programming language for business applications. A program reads data, applies rules and produces a result. Start with the objects involved before investigating code.
A transaction code, or t-code, is a shortcut to a task in classic SAP GUI. Fiori apps provide another way to work. Names and screens depend on the product and release; you do not need a live system to learn the concepts in this guide.

Scope and source-review notes
Scope and evidence
Source review by FAST SAP SOLUTIONS® editorial. This badge describes our editorial review; it does not represent SAP certification or independent endorsement.
RAP non-standard actions/functions in supported backend releases; projection, feature/authorization and OData exposure vary by release and binding.
Primary documentation reviewed on 14 November 2026 using official indexed excerpts. Documentation review only; authored examples were not compiled or executed in an SAP system.
A MANUFACTURING EXAMPLE
Separate a component availability preview from a reservation
Is the operation changing state?
Read the example values
- Operation A
- Approve an order
- Operation B
- Read a calculated result
- Service contract
- Action or function
- Client call
- Must fit the exposed operation
A REAL SCREEN TO RECOGNIZE

SAP’s RAP workshop shopping-cart application illustrates requests for purchasing. This is a custom workshop app, not the classic ME53N screen. Recognize the requested items and actions; creating a request and creating a supplier order are separate business stages.
© 2025 SAP SE or an SAP affiliate company and abap-platform-rap110 contributors. Apache-2.0 (repository REUSE annotation). Reproduced unchanged for educational commentary. This is a source example, not a capture of your system.Words you’ll meet in this guide
- Program
- A set of instructions executed by a computer.
- Class
- A reusable unit that groups data with operations called methods.
- Database
- Organized information kept beyond one program execution.
- Internal table
- A list of rows held temporarily in an ABAP program’s memory.
- Key
- One or more fields used to identify or find a record.
- ABAP
- SAP’s programming language for business applications.
- RAP
- ABAP RESTful Application Programming Model: a way to build business objects and services.
- OData
- A standard for reading and updating data through a web API.
- Fiori
- SAP’s approach to business application design.
- API
- A defined interface through which programs exchange data or request actions.
- HTTP
- The request-and-response protocol used by web applications and APIs.
Preview the practical steps
SEE THE CONNECTION
See it in a simple example.
A small example to make the idea concrete.
Separate a component availability preview from a reservation
A manufacturer's RAP application offers a read-only preview and a state-changing operation around a component request.
Choose by business effect, not by the operation name
A RAP function is a custom read operation.
Scope and prerequisites
The guide concerns ABAP RAP business objects and non-standard operations in supported backend releases.
Worked case: preview 3 units, then reserve 3 units
Fictional request R100 asks for 3 units of material M10.
Separate a component availability preview from a reservation
A manufacturer's RAP application offers a read-only preview and a state-changing operation around a component request.
Inspect the exposed operation contract and intended side effects before having a client call one as if it were the other.
| Reader | Business question | Evidence to carry forward |
|---|---|---|
| SAP developers and application teams supporting manufacturers | Separate a component availability preview from a reservation | Inspect the exposed operation contract and intended side effects before having a client call one as if it were the other. |
01 Choose by business effect, not by the operation name
A RAP function is a custom read operation. A RAP action is a non-standard modifying operation. If CheckAvailability only calculates an answer, a function can fit. If it reserves stock, records an approval or changes status, it belongs to a modifying contract even when the button still says Check. [1] [2]
The distinction affects implementation rules, service exposure, client invocation and failure handling. This tutorial separates availability preview from reservation for one fictional request, then follows the behavior definition through projection, service metadata and verification. A correctly named handler is only one layer of that contract.
02 Scope and prerequisites
The guide concerns ABAP RAP business objects and non-standard operations in supported backend releases. Action/function syntax, result options, feature control and protocol exposure have evolved. Verify the installed RAP BDL feature set and binding type; do not infer OData V2 behavior from a V4 example or assume every current function capability exists in an older backend.
You should understand a behavior definition, behavior pool, projection and service binding. The sample object names and inventory figures are illustrative. The partial BDL and operation algorithms are design examples, not compiled code or a tested warehouse implementation. Use released APIs and the appropriate RAP transaction contract in an actual extension.
03 Worked case: preview 3 units, then reserve 3 units
Fictional request R100 asks for 3 units of material M10. Available quantity at preview time is 8 PC. A read-oriented PreviewAvailability returns requested 3, available 8 and sufficient=true without changing stock or request status. A later Reserve action can create the supported reservation or move the request into a reserved state according to the application's business contract.
After another user consumes 6 PC, availability becomes 2 before Reserve executes. The earlier preview is no guarantee. Reserve must recheck the current business preconditions under the appropriate concurrency/transaction design and reject or otherwise handle insufficient availability. This temporal gap explains why a function cannot secretly hold stock merely to make its displayed answer remain true.
| Time | Operation | Expected state/effect |
|---|---|---|
| T1 | PreviewAvailability for 3 PC | Returns available 8; no reservation |
| T2 | Another supported operation consumes 6 PC | Availability becomes 2 |
| T3 | Reserve for 3 PC | Rechecks; cannot promise original 8 |
| T4 | Controlled rejection | Request/stock follow documented failure contract |
04 Understand the read-only implementation boundary
SAP documents functions as calculations or reads without modifying/persisting data or issuing locks. Their implementation belongs to a read handler contract. Do not update a “last checked” business field or call a remote reservation API from a function and describe it as a harmless read. [2]
If the requirement includes an audit/business record of the check, decide whether that is part of a modifying operation and model it explicitly. Technical logging follows its supported framework rules, but it must not become a hidden business-state transition. The consumer should be able to repeat a preview without creating another reservation or changing approval state.
05 Define parameters and results as a public business contract
Model input structures with meaningful quantity/unit and context, not a loosely typed string that clients must interpret. For instance-bound operations, identify R100 through its binding context and declare additional parameters only where needed. Avoid supplying the same instance key twice through conflicting contracts.
The partial behavior sketch uses abstract input/result entities whose definitions must be provided separately. An action returning $self should fill the modeled result with the relevant resulting instance. A function's declared result also needs implementation output; declaring cardinality[1] does not automatically synthesize a calculation or populate a missing result. [3]
// Within a supported behavior definition for the request entity:
function PreviewAvailability
parameter ZA_AvailabilityInput
result [1] ZA_AvailabilityResult;
action Reserve
parameter ZA_ReservationInput
result [1] $self;
// Input/result abstract entities and handler methods are separate artifacts.06 Trace the exposure chain through projection and binding
An operation defined in a base behavior is not automatically usable through every service projection. Include the required action/function in the applicable projection behavior and expose the relevant result entities according to the documented rules. Projection-specific operations and result remapping have their own release constraints. [3]
Then inspect service metadata from the actual binding. Confirm operation kind, namespace, instance binding, parameters and return type. Construct the client request from that metadata. A handler test through EML can pass while the OData consumer fails because an operation or result type was not exposed correctly. Keep provider implementation and public service contract as separate checks.
07 Implement the action through RAP business-state handling
Reserve should read the authoritative request, check permission and allowed state, invoke the supported reservation/change mechanism and report failures for the affected instance. Follow the RAP implementation contract; do not insert an arbitrary COMMIT WORK inside a behavior handler to make a document appear immediately.
For the fictional case, the action's algorithm rechecks quantity and unit, verifies current availability through an appropriate released interface and applies only the intended change. If a remote service participates, local rollback does not automatically undo that remote effect. Define that boundary and any reconciliation explicitly rather than assuming RAP supplies distributed atomicity.
PreviewAvailability(R100, requested 3 PC):
authorize read
read current availability
return requested quantity, available quantity and decision
leave request and reservation state unchanged
Reserve(R100, requested 3 PC):
authorize modifying operation and validate current request state
check current quantity/unit and supported concurrency conditions
perform the supported business reservation/change
report failed/reported instances accurately
return the declared resulting request instance when successful08 Permissions, feature control and state validation answer different questions
Authorization decides whether a caller may perform the operation. Feature control can communicate whether it is currently available for an instance. Business validation enforces preconditions at execution time. A disabled button is helpful presentation, but a direct caller can still attempt the endpoint and the backend must produce the correct outcome.
For R100, an authorized planner can still receive an insufficient-availability rejection after a valid preview. Conversely, sufficient stock does not grant an unauthorized user permission to reserve it. Test these dimensions separately. Current function authorization/feature capabilities also have release boundaries; verify them rather than assuming action configuration can be copied unchanged.
09 Troubleshoot declaration, invocation and result problems
Capture the exact layer that fails. An unknown operation is different from a business rejection, and a blank result can reflect an unfilled output rather than a failed calculation.
| Observation | Question | Next evidence |
|---|---|---|
| Operation absent in metadata | Projection/service exposure complete? | Base and projection BDEF plus service definition |
| Wrong HTTP invocation | Action/function kind or namespace mismatch? | Actual binding metadata |
| Function changes request state | Read contract violated? | Handler dependencies and persistence effects |
| Action succeeds but result initial | Was declared result filled? | Result mapping for the input instance |
| Preview sufficient; reserve fails | State changed between requests? | Current availability and concurrency evidence |
| Button disabled but direct action succeeds | Backend policy/state check missing? | Authorized negative endpoint test |
| Remote effect remains after local failure | Independent transaction boundary? | Remote reference and reconciliation design |
10 Verify both operation contracts
For the function's positive test, preview R100 with 8 available and 3 requested, then verify request status, stock and reservation records remain unchanged. Repeat the same read and confirm it creates no extra business effect. A negative test uses an unknown request or unauthorized caller and checks the documented failure/disclosure policy.
For the action, test a valid reservation and verify only its intended state transition. Test insufficient availability, invalid unit and an already processed request. The boundary test previews, changes availability through another controlled test operation, then reserves. The action must use current state rather than trusting the old preview. These are proposed tests; no customer service was invoked here.
Define the reservation fixture's postcondition before running it. In one illustrative design, reserving 3 PC from 8 available leaves 5 available and marks R100 Reserved, with exactly one reservation reference. A second Reserve attempt on that already-reserved request should follow the application's explicit repeat policy, such as rejecting the attempt without creating another reference. The action name alone does not provide duplicate protection.
Run that successful case separately from the preview-then-competing-consumption case. Reset request and inventory state between experiments so a reservation from the first test does not explain the second test's shortage. Capture the input instance, quantity/unit, resulting status/reference and persisted availability. For PreviewAvailability, capture those same business-state fields before and after: equality is the essential no-effect assertion. This is stronger evidence than an HTTP success response or an initial action-result structure.
11 Messages and client state need the correct contract
Use RAP's supported failed/reported mechanisms and distinguish transient operation messages from persisted business-state messages. The reviewed function documentation says a read/function implementation cannot create new state messages. Existing entity-state messages can be returned under particular result/protocol behavior; do not generalize one Fiori or OData version's presentation to every service. [3]
After Reserve, the client needs the actual action result or an appropriate refresh of dependent data. A preview result should be labeled as an observation at a time, especially when availability can change. Avoid a generic “success” toast that hides which instance was changed or whether a later transaction completion failed.
12 Frequently asked questions
Can a function reserve stock temporarily? That is a modifying effect and conflicts with the read-only contract described here. Model a supported action and its release/expiry behavior explicitly.
Does returning $self mean RAP fills it automatically? The declared result still needs correct implementation mapping under the action/function contract.
Does an EML test prove OData exposure? No. Inspect projection, result exposure, binding metadata and the actual client request.
Why does an action fail after a successful preview? The business state can change between requests, or the action can have stronger authorization/preconditions. Preserve that difference rather than weakening the action.
What should a design review retain? Operation effects, input/result types, instance identity, exposure chain, transaction owner and the no-change versus intended-change tests.
Related services and next steps
Primary sources
Found this useful?
Share this guide with your network, or leave a like.
Your like is saved in this browser.