Skip to Content
Technical Articles
Author's profile photo Aman Garg

ABAP RESTful Application Programming Model – Enable Change Set processing in Multi select Fiori Applications

I hope you had a pleasant start to 2022 😊

I would again like to share my learning from a challenge which I recently encountered while implementing a RAP based SAP Fiori Elements application for our customer, and the respective solution, using which I could overcome the challenge.

Problem Statement:

We wanted to create a RAP based SAP Fiori Elements List Report application. Customer wanted to have multiple selections enabled in the List Report page for this Fiori Application. It was required to have certain custom actions in the application called ‘Group’.

So basically, the application user can select multiple entries from the list and click on Custom action to group all the selected entries together and assign a common grouping ID to it. However, there were also multiple validations required like we should not allow grouping of all the selected entries if one or more of the selected entries are already grouped.

 

Challenge:

To achieve the above requirement, we created a RAP based managed service and added custom action called Group to our app, exposed it to UI, enabled multi select in UI by modifying manifest.json (each step explained in detail in next section), and added action implementation in Behavior Pool class to assign Grouping ID to all the selected entries by generating a unique ID using number range object. However, after implementing these steps, when we tested the application, we got to know that only a single record per backend call was being sent from UI to backend. This means, if the user selected 3 entries and clicked on Group, the action implementation would be called 3 times, with a single ‘key’ value in each call, hence, at a given point of time, we didn’t know how many records were selected, and if some of the records selected were already grouped previously. Hence, the validation of the grouping couldn’t be achieved due to this challenge.

 

Solution:

To overcome the challenge, we had to explicitly turn on the Changeset using invocation grouping. This can be simply activated by adding parameter ‘invocationGrouping’ in the UI annotation where you are exposing your action and set its value to #CHANGE_SET as highlighted below.

As soon as invocation grouping is added, we were then able to receive all the selected entries in a single backend call, and apart from implementing Grouping, we were also able to implement all the validations, as we now know all the selected entries together.

 

Implementation Steps:

To demonstrate, I am using ABAP cloud trial to develop the service using a Travel entity and adding a custom action ”Group” to it and exposing it to UI using Business Application Studio.

1. Create a root Travel view entity:

2. Create Behavior Definition and add action called ‘group’.

3. Create Behavior Pool class and implement logic in action implementation method.

4. Create Projection View.

5. Create Behavior Definition Projection.

6. Create Service Definition:

7. Create Service Binding:

8. Expose the oData service to UI using BAS:

Create a new project from Template in Business Application Studio/WebIDE to generate a Fiori Elements app for the generated oData service. Below is the project I generated in BAS:

9. Edit manifest.json file to enable multi select

10. Test

Test the Fiori App in BAS to see multi-select enablement:

Select some records and hit ‘Group’ button:

Verify Grouping ID assigned:

Effect of Invocation Grouping:

The below steps explain effect of invocation grouping:

1. Expose ‘Group’ action without invocation Grouping

Add a break-point in action implementation

Select multiple records in UI and hit ‘Group’:

Debugger would stop at action implementation. Check ‘keys’. Only a single value in first backend call. Method is triggered twice since 2 records are selected

2. Expose Group action with invocation grouping

Again, add select multiple records in UI and hit ‘Group’

Check no of values in ‘keys’ in debugging. This time, since we have invocation grouping activated, we receive all the selected entries in a single backend call. That’s the effect invocation grouping brings.

This way, I was able to add all the validations as well.

 

Please feel free to share your thoughts and feedback 🙂

Cheers,
Aman Garg

Assigned Tags

      9 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Dhananjay Hegde
      Dhananjay Hegde

      Hi Aman,

      Excellent post.

      I usually work with EML which by default provides multiple record processing.  Didn't know exposing actions to UI needs this  additional settings.

      Thanks for the post.

      Regards,

      Dhananjay

      Author's profile photo Aman Garg
      Aman Garg
      Blog Post Author

      Hi Dhananjay,

      Thanks for the feedback.

      Regards,

      Aman Garg

      Author's profile photo Mahesh Palavalli
      Mahesh Palavalli

      Nice one Aman.

      Author's profile photo Aman Garg
      Aman Garg
      Blog Post Author

      Thanks Mahesh!

      Author's profile photo Thiago da Graça
      Thiago da Graça

      Excellent post.

      Thanks so much for sharing your knowledge with all of us.

       

      Author's profile photo Aman Garg
      Aman Garg
      Blog Post Author

      Thanks for the feedback Thiago!

       

      Author's profile photo Swarajsingh Rajput
      Swarajsingh Rajput

      Nice one Aman. I was struggling with multiple backend calls. Feeling good now after getting solution from you. Kudos.!

      One more scenario if you could come across, is there any way to control backend code based on framework EDIT/DISPLAY mode in managed scenario?

      Author's profile photo Aman Garg
      Aman Garg
      Blog Post Author

      Hello Swaraj,

      Thanks for your feedback, I am glad this helped you.

      Regarding your scenario, for Edit, you can disable the standard Edit operation, and define a custom action with the same/similar name, this way you now have control over the back-end code.

      Thanks,

      Aman

      Author's profile photo Swarajsingh Rajput
      Swarajsingh Rajput

      Hello Aman,

      I want to show specific action/certain fields only in EDIT mode of application. During DISPLAY mode, those fields/action should be hidden.

      Do we have any possibility in feature control to make it hide/visible .? Have you come across such situation.?

      I am aware of custom action. But need to understand visibility control of certain fields using feature control