Where do you define a RAP action and where do you implement it? How do you give it an input parameter and show it as a button in the Fiori app?
Say your answer out loud first.
Practise another way
I define the action in the behavior definition and implement it in a FOR MODIFY handler method in the behavior pool. For input I add parameter with a CDS abstract entity, read the values from %param, and can add a default function to prefill the dialog.
Then I expose it with use action in the projection behavior definition. In the metadata extension, a UI.lineItem or UI.identification entry with type FOR_ACTION and dataAction creates the button.
1. Define it (base BDEF)
action ( features : instance, authorization : update )
deductDiscount parameter ZA_TravelDiscount result [1] $self
{ default function GetDefaultsForDeductDiscount; }
parameternames a CDS abstract entity (or a DDIC type for flat input); deep input uses an abstract BDEF withwith hierarchy.result [1] $selfreturns the changed instance so the UI refreshes the row.default functionprefills the parameter dialog; it needs an input parameter.features : instancelets you grey out the button per row;authorization : updatereuses the update check.
define abstract entity ZA_TravelDiscount
{
discount_percent : abap.int1;
}
2. Implement it (behavior pool)
METHODS deductDiscount FOR MODIFY
IMPORTING keys FOR ACTION Travel~deductDiscount RESULT result.
- Each key carries
%tkyand%param-discount_percent. Reject bad input withfailedand a message inreported. - Read the instances with
READ ENTITIES ... IN LOCAL MODE, change them withMODIFY ENTITIES ... IN LOCAL MODE, then read again and fillresult. - No
COMMIT: the action changes the buffer; the save sequence persists it. - The default function is a separate
FOR READ ... FOR FUNCTIONmethod that returns%paramvalues per key.
3. Expose it (projection BDEF)
use action deductDiscount; and use function GetDefaultsForDeductDiscount;. An action that is not in the projection does not exist for that service.
4. Show it (metadata extension on the projection view)
@UI.lineItem: [ { type: #FOR_ACTION, dataAction: 'deductDiscount',
label: 'Deduct Discount', invocationGrouping: #CHANGE_SET } ]
@UI.identification: [ { type: #FOR_ACTION, dataAction: 'deductDiscount',
label: 'Deduct Discount' } ]
TravelID;
lineItem gives a toolbar button on the list or table, identification a header button on the object page. Because the action has a parameter, Fiori elements opens a dialog built from the abstract entity's fields.
Also decide: instance vs static action, whether a factory action fits better (it creates instances), and whether the logic should be an internal action reused by other code.
SAP's own ABAP Platform 2025 Flight reference scenario implements exactly this discount action, including the default function, if you want a working model.
Covers all four places (BDEF, handler, projection, annotation), explains parameter via abstract entity and %param, and mentions result $self and feature control.
Only mentions the BDEF line and is surprised the button does not appear, or puts COMMIT WORK in the action.
Forgetting `use action` in the projection BDEF or the #FOR_ACTION annotation, then debugging the handler for a button that was never exposed.
- What is the difference between an action and a function?
- How do you grey out the button for some rows?
- What does invocationGrouping #CHANGE_SET change when several rows are selected?
2 candidate write-ups, 4 official pages and 1 prep guide. Confidence: high. Checked 1 Dec 2026.
- Prep guide Gives the question.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Candidate write-up Gives the question.
- Candidate write-up Gives the question.