[[{“value”:”
How can you group your various actions in RAP under a single button, especially if the actions are quite similar? This article will look at the details of implementing this with ABAP.
In this article, we will implement the Factory Actions and apply grouping in the UI to better visualize the options for the user.
Introduction
Displaying every action as a separate button can make an application toolbar feel crowded. Grouping related actions in a dropdown offers a simpler way to present these options under one meaningful label. In this blog, we will bring Approve, Reject and Cancel together under a single Status dropdown in an ABAP RAP application. Using UI annotations, we will define an action group and assign the actions to it, creating a more organised interface while keeping each option accessible.
Factory Actions
Factory actions in ABAP RAP are used to create new business object instances through custom logic. They can be instance-bound or static: an instance-bound factory action can copy values from an existing record into a new one, while a static factory action can create a record with predefined default values. Typical examples include copying an existing record or creating a new record with prefilled data.
Distinction for this example: The Approve, Reject and Cancel definitions shown below are instance-bound non-factory actions, not factory actions. They are declared using action rather than factory action and specify result [1] $self. This blog groups these three existing actions under the Status dropdown; it does not demonstrate creating new records with factory actions.
Current Status
We had already defined the following actions in the behaviour, but hadn’t yet implemented them. The following definitions currently exist and are already displayed in the UI.
action ( features : instance ) Approve parameter ZA_APPROVE_PARAM
result [1] $self{ default function GetDefaultsFor_Appr; }
event TravelApproved parameter ZI_TRAVEL_EVT;
validation valid_emp_name on save { field EmployeeName; create; update; }
action ( features : instance ) Reject result [1] $self;
action ( features : instance ) cancel result [1] $self;
Grouping
In this section, we want to group the two factory actions. The user should then find the option to create a record under one item and no longer scattered across several buttons, where other actions might also be visible.
@UI.lineItem: [ { importance: #MEDIUM },{ position: 20, type: #FOR_ACTION, dataAction: ‘Approve’, label: ‘Approve’ },
{ position: 30, type: #FOR_ACTION, dataAction: ‘Reject’, label: ‘Reject’ }, { position: 40, type: #FOR_ACTION, dataAction: ‘cancel’, label: ‘Cancel’ } ]
To do this, we create a group of type FOR_ACTION_GROUP. We give it a description and an “actionGroupId“. In the UI, the group will then bundle all assigned elements as a dropdown menu. As a final step, we need to assign the “actionGroupId” to the buttons. This adds a new line and two attributes to the UI annotations.
@UI.lineItem: [ { importance: #MEDIUM }, { position: 10, type: #FOR_ACTION_GROUP, label: ‘Status’, actionGroupId: ‘GRP1’ }, { position: 20, type: #FOR_ACTION, dataAction: ‘Approve’, label: ‘Approve’, actionGroupId: ‘GRP1’ }, { position: 30, type: #FOR_ACTION, dataAction: ‘Reject’, label: ‘Reject’, actionGroupId: ‘GRP1’ }, { position: 40, type: #FOR_ACTION, dataAction: ‘cancel’, label: ‘Cancel’, actionGroupId: ‘GRP1’ } ]
Conclusion
This example brings Approve, Reject and Cancel together through a Status action-group entry and a shared actionGroupId. The annotation change is only part of the story: the project context, grouping rationale and testing observations explain whether the design served the intended workflow.
Grouping related actions in an ABAP RAP application is more than a way to tidy the toolbar: it is a decision about how to organise the available operations. This walkthrough shows how an action group and a shared group identifier bring existing options under one dropdown without changing their definitions. The key takeaway is to choose a meaningful group label, group options that belong together, and verify the result against the intended workflow. A cleaner layout is the starting point; a grouping that makes sense to users is the goal.
“}]]
Read More Technology Blog Posts by Members articles
#abap