Technology Blog Posts by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
srikanthvadla
Explorer
769

Background

Upon upgrading our SAP system from S/4 HANA 2021 to the 2023 version, we experienced difficulties with our RAP-based Fiori apps. Specifically, we found that Feature Controls and Side Effects were not functioning correctly. Despite adhering to the new syntax, issues with those Fiori applications continued. Ultimately, we collaborated with the SAP support team and learned that certain modifications were necessary to enable those features in the S/4 2023 version.

Given the absence of an SCN post or comprehensive documentation detailing the steps to activate Feature Controls and Side Effects in the new version, I've put together this post using insights gained from our experience. While this post might not encompass all scenarios or specifics related to Feature Controls and Side Effects in RAP, it does specifically address the solutions/concept to enable Dynamic Feature Controls for UI elements and Side Effects associated with fields and actions in the new version.

In the S/4 HANA 2023 version, changes have been made to the RAP framework to boost the performance of Fiori elements applications. Consequently, we need to make some modifications to enable the Dynamic Feature Control and Side Effects.

Enable Dynamic Feature Controls

Example Use Case: When Fiori application has a Business Partner drop down with Customer and Supplier, if the Customer is selected then the Customer Number field should be changed to a mandatory field automatically in the UI.

To achieve above requirement in S/4 2023 version, following steps needs to be implemented.

  1. With dynamic feature control, you can add access restrictions based on conditions or specify access restrictions for fields. The field needs to be annotated as shown below in the behavior definition and is implemented in the behavior pool (step 2).                                                                                                                            field ( features : instance ) kunnr;                                                                                            
  2. In the method get_instance_features of the Behavior Pool, we need to implement respective logic for setting field behavior. Below syntax sets the customer number field to mandatory field.                                                     <lfs_result>-%field-kunnr = if_abap_behv=>fc-f-mandatory.                                                      
  3. Read the Metadata file of the service from Gateway or from the Browser Developers Tool to find the name of the respective field control (in this case kunnr_fc) in the respective Entity Type section as shown below.                                                                                            <Property Name="kunnr_fc" Type="Edm.Byte" sap:label="Dyn. Field Control"                                                                               sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>                                                                        
  4. Add the relevant field controls in the target properties (in this case kunnr_fc) for the field in the source properties, in the local Annotations.xml file in Gateway UI application as shown below. In this case, the sourcefieldname will be the field name for the business partner dropdown. Please note that the Qualifier must be unique for every Annotation tag.          srikanthvadla_4-1747369714830.pngSimilar steps can be followed to enable Dynamic Feature Controls for Operations and Actions.

Enable Side Effects for Determinations

Example Use Case: When a Customer Number in the Fiori Application is changed, the Customer Name and Customer Country values of the respective Customer should be updated automatically in the UI.

  1. Add Use Side Effects statement in the Behavior Projection.                                                                                                      use side effects;                                                                                                                    
  2. In the Behavior Definition, we need to declare the source and target entities for the side effects as shown below.                                                                                                                                                                            side effects {  field kunnr affects field name1, field land1;  }                                                               
  3. Declare the Determination for the Side Effect entity as shown below. You can also specify action for which the below determination should be triggered (example, create only or update only)                                            determination updateCustomerAddress on modify { <action> ; field kunnr;  }                                      
  4. Implement the method generated for the above determination in the behavior implementation class, to determine customer name and customer country values and implement EML modify entity on BO instance to update the fields.

Related Information:

  1. In the S/4 2023 version, for the RAP applications, mentioning the strict mode (use strict;) in Behavior Definition Projection is required. When a BO is defined as strict, set of best-practice rules are technically enforced with additional syntax checks on specific design and implementation requirements to make sure that a BO is lifecycle-stable, upgrade-safe, and best-practice compliant.                                                                       
  2. In S/4 2023 version, there is no support for DDIC based CDS views, they need to be migrated to CDS view entities. Use migrate wizard in Eclipse to migrate your DDIC based CDS views to CDS entities.                                                                                                           
  3. Use UI5 inspector (chrome extension) to inspect the App UI5 controls for additional information in the runtime (example: Aggregations, Bindings,Properties etc.).                                                                             
  4. In Browser Developer Tools, Use Sources -> ApplicationController-dbg.js, to inspect runtime values for side effects.                                                                                                                                                              
  5. In S/4 2023 or higher versions, It is recommended to maintain all the possible side effects or annotations in the backend itself instead of moving them to the frontend (local annotations.xml), for the reusability, maintenance, and better support for future upgrades.

References:

  1. How to use side effects in RAP https://community.sap.com/t5/technology-blogs-by-sap/how-to-use-side-effects-in-rap-restful-applicat...
  2. RAP Side Effects Document https://help.sap.com/docs/abap-cloud/abap-rap/side-effects
  3. Instance Feature Controls Document https://help.sap.com/docs/abap-cloud/abap-rap/instance-feature-control
  4. Strict Mode https://help.sap.com/docs/abap-cloud/abap-rap/strict-mode
  5. DDIC based CDS views to CDS entities migration https://help.sap.com/docs/abap-cloud/abap-cds-tools-user-guide/migrating-cds-ddic-based-views-to-cds...
1 Comment