Skip to Content
Technical Articles
Author's profile photo Andre Fischer

How to use side effects in RAP

How to use side effects in RAP

A long awaited feature became available with the latest upgrade to 2302 of the SAP BTP, ABAP Environment and SAP S/4HANA ABAP Environment systems.

It is now possible to configure side effects in the behavior definition of your RAP business object.

This feature (amongst lots of other cool features 😉 ) is also implemented in the SAP Fiori Elements Feature Showcase App:

The SAP Fiori Elements feature showcase with RAP and ABAP CDS annotations | SAP Blogs

Feature Showcase App Guide · SAP-samples/abap-platform-fiori-feature-showcase Wiki (github.com)

and we now also have a very comprehensive video available that explains this feature in more detail as well

RAP Side Effects in a Nutshell | SAP Blogs

 

RAP calculator app using side effects

 

For demo and educational purposes I have build a simple example of a RAP based calculator app.

Here you can add two operands and an operator ( +, , * or / ).

When changing one value, either one operand or the operator the data in the results field will be changed.

This app you can build yourself based on the table that is listed at the end of this post.

Once you have generated the RAP BO you only have to add the

side effects

{

}

statement to your behavior definition where you list which field is effected by another field of your RAP BO.

side effects
  {   
    field OperandA affects field CalcResult;
    field OperandB affects field CalcResult;
    field Operator affects field CalcResult;
  }

  determination CalculateCalcResult on modify {  field OperandA, OperandB, Operator; }

And in the behavior projection you have to enable the use of side effects by adding a

use side effects;

statement.

projection;
strict ( 2 );
use side effects;
use draft;

define behavior for ZC_CalculatorTP_01 alias Calculator
use etag

{
  use create;
  use update;
  use delete;

  use action Edit;
  use action Activate;
  use action Discard;
  use action Resume;
  use action Prepare;
}

SAP Online Help

More information can be found in the SAP Online Help

Side Effects | SAP Help Portal

Table

@EndUserText.label : 'Pocket Calculator'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zcalculator {

  key client            : abap.clnt not null;
  key calc_uuid         : sysuuid_x16 not null;
  operand_a             : abap.int4;
  operand_b             : abap.int4;
  operator              : abap.char(1);
  calc_result           : abap.fltp;
  created_at            : abp_creation_tstmpl;
  created_by            : abp_creation_user;
  last_changed_by       : abp_lastchange_user;
  last_changed_at       : abp_lastchange_tstmpl;
  local_last_changed_at : abp_locinst_lastchange_tstmpl;

}

 

 

 

Assigned Tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Prashant Sharma
      Prashant Sharma

      Thanks Andre for sharing this. It's a needed functionality in RAP.

      Author's profile photo Saikrishna Ravichandran
      Saikrishna Ravichandran

      Hi Andre

      One question how to define side effects on multiple fields ?

      For instance field 1 affects field 2 ; field 3 ;

       

      Regards

      Sai

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      The syntax is the following (taken from the SAP Fiori Elements feature showcase app).

      side effects {
      
      field IntegerValue affects field ProgressIntegerValue, field RadialIntegerValue;
      
      field NavigationID affects entity _Navigation;
      
      action resetTimesChildCreated affects field TimesChildCreated, permissions ( action resetTimesChildCreated );
      
      determine action validateDate executed on field ValidTo affects messages;
      
      determine action validateChild executed on entity _Child affects messages;
      
      }
      
      

       

      Author's profile photo Anilkumar Yarramasu
      Anilkumar Yarramasu

      Hi Andre,

      I tried to use the same in SAP 2020 on-premise, It is not working.

      How can I use this feature in my version?

      Best Regards,

      Anil.

       

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      Defining side effects in the behavior definition is not supported in on premise releases so far.

      It is planned to be supported with the next upcoming on premise release where features of the current cloud release 2302 will be shipped with.

      In on premise releases you unfortunately still have to create side effect annotations in the UI project using business application studio.

       

      Author's profile photo Sampath Ramanujam
      Sampath Ramanujam

      Quick question: Can we use side effects in the Embedded abap (3SL) stack of s/4hana cloud ? it will be great feature to experiment this against s/4hana public cloud with the support of embedded abap stack, i love it if it works.

      Author's profile photo Yogeendar Rao
      Yogeendar Rao

      Hi Andre,

       

      It seems currently Side Effects are available only for Draft enabled BO.

      Is there a way to use Side Effects in Non-Draft BO? I am using Managed Scenario without draft in S/4 Public Cloud and want to recalculate some fields on UI dynamically, but neither Determination on Modify nor Side effects are working. Any suggestions on this?

       

      Regards,

      Yogeendar