Discard pending RAP changes when the workflow cancels

An application may decide that a staged change must not be saved—for example, a required approval is missing. In an EML consumer scenario, ROLLBACK ENTITIES rolls back the current RAP transaction, including transactional-buffer changes.

Make the decision explicit

IF cancel_request = abap_true.
  ROLLBACK ENTITIES.
  DATA(result) = 'RAP transaction cancelled'.
ELSE.
  DATA(result) = 'Continue validation before committing'.
ENDIF.

Rollback is transaction-wide, not a way to undo one selected field. Use it only when the caller owns the transaction and intends to discard its pending work. In unmanaged BOs, behavior implementation must correctly handle its own buffer cleanup. Native RAP service flows manage commit and rollback through the runtime.

Don’t mix this with direct database updates; they are outside the RAP transactional buffer and may not be reversed by this statement.

Sources

Developer practice · ABAP

Practice: choose commit or rollback

When a validation flag says the request must be cancelled, use ROLLBACK ENTITIES and record a cancellation result.

Choose your ABAP environment

This choice changes the output pattern checked here: WRITE belongs in a classic executable report, while out->write( ) uses the supplied output reference in an ABAP Cloud class-run method. It does not switch the language version of the other code; check release and API availability in your target system.

Complete the task and include the output statement shown for your selected environment. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.

0 required structures detected · 0 checks