In a managed RAP BO, an on-save determination must notify finance only when the status of an existing request really changed in this transaction, not for new requests. How do you find out what changed?
Say your answer out loud first.
Practise another way
Since release 2511 I can read the instance in local mode with the WITH CHANGES addition. The result carries %chg, the accumulated operation in this transaction, so I can skip creates and act only on updates, and %control tells me which fields changed, here Status.
It works only in managed BOs, inside the behavior implementation, and not for read-by-association. On older releases I compare against the active table or use the update table in save_modified.
First, narrow the trigger. determination notifyFinance on save { field Status; } already runs only when Status was touched.
But it fires for creates too, and "touched" can mean set back to the old value within the same transaction. The determination needs to know the accumulated change.
WITH CHANGES (release 917, 2511). SAP added an EML addition that returns accumulated change information for instances in the current RAP transaction:
METHOD notifyFinance.
DATA changes TYPE TABLE FOR READ CHANGES zr_request.
READ ENTITY IN LOCAL MODE zr_request
WITH CHANGES
FIELDS ( Status ) WITH CORRESPONDING #( keys )
RESULT changes
FAILED DATA(read_failed).
LOOP AT changes INTO DATA(chg)
WHERE %chg = if_abap_behv=>cop-update
AND %control-Status = if_abap_behv=>mk-on.
" register the notification for the late save phase,
" for example raise a business event in save_modified
ENDLOOP.
ENDMETHOD.
- The result type is
TABLE FOR READ CHANGES. %chgholds the accumulated operation; the cheat sheet namesif_abap_behv=>cop-create,cop-updateandcop-recreateas the cases in which%controlis filled.%controlmarks which fields changed; for other%chgvalues it stays initial.
Restrictions (SAP's cheat sheet)
- Managed BOs only.
- Only inside implementation classes, and only together with
IN LOCAL MODE. - Not for read-by-association or functions. In the dynamic form you set the operand's
fullcomponent toif_abap_behv=>typekind-result_chg.
Where the notification itself goes. Not in the determination: sending is a side effect outside the BO. Collect the keys.
Then raise a RAP business event or register a bgPF process in the late save phase (save_modified with additional save). That way, finance is only notified if the commit succeeds.
Before 2511, or in unmanaged BOs
- In
managed with additional save,save_modifiedreceivesupdatewith%controlper field, which answers "what changed" at save time. - Otherwise compare the buffer value with the active database row (
SELECTon the persistent table) in the determination; heavier and easy to get wrong with draft.
Interview angle. The trigger condition answers "was the field touched"; WITH CHANGES answers "what is the net change in this transaction". Senior answers keep both apart and move side effects to the save phase.
Combines a field trigger with READ ... WITH CHANGES, reads %chg and %control correctly, states the managed-only and local-mode limits, and moves the notification to the late save phase.
Selects the database row in every determination run or sends the notification directly from the determination.
Sending the notification inside the determination. If a later validation fails, finance has already been told about a change that was never saved.
- Why should the notification be raised in the late save phase and not in the determination?
- What does save_modified receive with additional save, and how is it different from WITH CHANGES?
- How would you test this determination with the EML test doubles?
3 official pages. Confidence: high. Checked 3 Dec 2026.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.