Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
13,192

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;

}

 

 

 
14 Comments