In your draft app, validation messages pile up or never disappear. How do RAP messages work: %msg, %element, %state_area, and state versus transition messages?
Say your answer out loud first.
Practise another way
A message goes into REPORTED with the instance's %tky and a %msg object. The %msg object is built from a message class that implements IF_ABAP_BEHV_MESSAGE.
The %element flags make Fiori show it at the right field. Validation messages are state messages: they describe the instance's current state and stay with the draft until cleared.
That is what %state_area is for. At the start of the validation I append an empty entry with the state area to clear old messages, then add new ones with the same area.
Anatomy of a message
APPEND VALUE #( %tky = travel-%tky
%state_area = 'VALIDATE_DATES' ) TO reported-travel. " clears old ones
IF travel-EndDate < travel-BeginDate.
APPEND VALUE #( %tky = travel-%tky ) TO failed-travel.
APPEND VALUE #( %tky = travel-%tky
%state_area = 'VALIDATE_DATES'
%msg = NEW zcx_travel_messages(
textid = zcx_travel_messages=>end_before_begin
severity = if_abap_behv_message=>severity-error )
%element-EndDate = if_abap_behv=>mk-on ) TO reported-travel.
ENDIF.
%tkyties the message to the instance (draft or active).%msgis an object that implementsIF_ABAP_BEHV_MESSAGE(usually an exception class with your message class texts) with a severity.%element-<field>highlights the field;%op-%action-<name>ties a message to an operation instead.failedsays that it failed;reportedsays why. A validation that fails without a message leaves the user guessing.
State messages vs transition messages
- State messages come from validations. They describe a problem with the instance's data and remain valid as long as the data is wrong. So with draft, they are kept with the draft and shown again when the user returns.
- Transition messages belong to one request, for example a success message after an action. They are shown once and not kept.
Why messages pile up or never go away
- The validation adds a message every time it runs but never clears the old one: add the empty
%state_areaentry first. The state area is any string you choose; use one per validation. - The validation does not run again after the user fixes the field. Either its trigger conditions (
field BeginDate, EndDate) do not include the field the user changed, or no determine action and side effect re-run it. - A message is reported without
%tkyor with the wrong key group, so the UI cannot attach it to the right row.
Release note for 2026: ABAP release 8.16 (ABAP Platform 2025) and cloud release 2502 added contract checks for handler responses.
Three cases now end in the runtime error BEHAVIOR_BAD_HANDLER_RESPONSE: disallowed entries in failed, wrong fail causes, and non-initial %state_area in contexts where it is not allowed. Use %state_area in validations, not in actions or determinations.
Shows a complete REPORTED entry, explains state vs transition messages and the clear-then-add %state_area pattern, and knows the new contract check.
Fills only FAILED, or uses MESSAGE statements, and cannot explain why old errors stay on screen.
Appending messages in a validation without first clearing the state area, so every run adds another copy and fixed errors never disappear.
- What is the difference between FAILED and REPORTED?
- Why does a fixed error still show until the user touches another field?
- What happens if an action fills %state_area?
3 official pages. Confidence: medium. Checked 3 Dec 2026.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.