In various business scenarios, we would need to create a custom button in the action toolbar in the list report FIORI apps. There would be different business cases for use of these custom actions. In this article, I would explain the technical steps involved in BOPF, CDS annotations and annotation model in the generated Fiori apps to achieve automatic pop-up confirmation box without any App extension.
Prerequisites:
- Good knowledge of ABAP Programming Model
- Good and hand-on knowledge in ABAP OOPS.
- BOPF and basic understanding of SAPUI5 Annotation Model
Business Scenario:
- With custom actions “Set Active” and “Set Inactive”, there should be a pop-up confirmation if user really wants to change the status to active or inactive respectively.
Expected Output:
Implementation Steps:
Step 1. Create a new custom action in relevant business Object
Step 2. Implement execute method in action implementing class ZCL_I_A_INACTIVE_PROCEDURE as:
METHOD /bobf/if_frw_action~execute. " Typed with node's combined table type DATA(lt_context_data) = VALUE ztifscm_dunn_proc( ). " READING BO data ---------------------------------------------- " Retrieve the data of the requested node instance io_read->retrieve( EXPORTING iv_node = is_ctx-node_key it_key = it_key IMPORTING et_data = lt_context_data ). " WRITING BO data --------------------------------------------- LOOP AT lt_context_data ASSIGNING FIELD-SYMBOL(). " Set the status as Inactive if its Active IF -x_active IS NOT INITIAL. -x_active = ' '. " Inactive Dunning Procedure " Update the changed data of the node instance io_modify->update( EXPORTING iv_node = is_ctx-node_key iv_key = -key iv_root_key = -root_key is_data = REF #( -node_data ) it_changed_fields = VALUE #( ( zif_i_fscm_dunn_proc_c=>sc_node_attribute-zi_fscm_dunn_proc-x_active ) ) ). ENDIF. ENDLOOP. ENDMETHOD.
Step 3. Add this action in LineItem annotation in CDS view as :
@UI:{ lineItem: [{position: 20,importance: #HIGH }, { type: #FOR_ACTION, dataAction: 'BOPF:ACTIVE_PROCEDURE', label: 'Set Active', position: 1 }, { type: #FOR_ACTION, dataAction: 'BOPF:INACTIVE_PROCEDURE', label: 'Set Inactive', position: 2 }, { type: #FOR_ACTION, dataAction: 'BOPF:SENDER_ID', label: 'Sender ID', position: 3 } ]
Step 4. Now all back-end changes have been done and we can use this action in the FIORI app. To add an automatic pop-up confirmation, please go to web IDE , Open the annotation.xml file of the generated fiori app and add the following xml code:
It’s called Critical Action annotation. Let’s understand the above annotation.
The target property of this OData annotation points to the function import which is the OData representation of the BOPF action. The target is divided into three parts which contain the service name, the entity container separated with a dot and the function import name separated with a slash.
Normally, Entity container is always build as {OData Service}_Entities and Function Import name would be {EntitySet}{BOPF action} but we can also find these objects from “Annotation Modeler” option in Annotation file as:
We can select the Entity containers/Function Imports/Entity Sets etc from the target selection
Now, all the required changes have been done and once we test the Fiori app, system would generate a pop-up confirmation with a pre-filled text: “Do you really want to execute the action Set Inactive?”
Please follow our LinkedIn Page, LinkedIn Group, Facebook Page, Twitter and Instagram.
Save our number +1-646-727-9273 and send us a Whatsapp message ‘LEARN’ to be part of our Learning Community.
Also, Check ABAP Programming for SAP Fiori Tutorials
- ABAP Programming Model for SAP Fiori – 1 – Overview
- ABAP Programming Model for SAP Fiori – 2 – CDS – Introduction
- ABAP Programming Model for SAP Fiori – 4 – OData Service Creation
- ABAP Programming Model for SAP Fiori – 5 – OData Service Generation
- ABAP Programming Model for SAP Fiori – 3 – CDS Views Creation
- ABAP Programming Model for SAP Fiori – 6 – Generating Read-Only Application in Fiori using Fiori Elements
- ABAP Programming Model for SAP Fiori – 7 – BOPF – Introduction
- ABAP Programming Model for SAP Fiori – 8 – Developing Transactional Application – CRUD Operations using BOPF
- ABAP Programming Model for SAP Fiori – 9 – Use of Determinations in BOPF
- ABAP Programming Model for SAP Fiori – 10 – Use of Actions in BOPF
- ABAP Programming Model for SAP Fiori – 11 – Enabling Draft Functionality for Transactional Apps
- ABAP Programming Model for SAP Fiori – 12 – Scenario of Transactional App with Draft Enabled Functionality
- ABAP Programming Model for SAP Fiori – 13 – How to Preview and Download PDF in Fiori Apps
- ABAP Programming Model for SAP Fiori – 14 : Dynamic handling of CUD Operations & Fields in the Transaction App
- ABAP Programming Model for SAP Fiori – 15 : Automatic Popup Confirmation for Custom Actions using ABAP Programming Model in S/4HANA
- ABAP Programming Model for SAP Fiori – 16 : Automatic Dialogue with Parameters for Custom Actions using ABAP Programming Model in S/4HANA
- Single Popup Instead Multiple Popup for BAPI Return and Custom Messages
- How to Create SM30 Like Table Maintenance T-Code in SAP RAP – Part 1
- How to Create SM30 Like Table Maintenance T-Code in SAP RAP – Part 2 – Validations and Action via RAP
- Table Maintenance Generator from SAP RAP – Part 3 – FIORI UI App