Technical Articles
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.
GitHub Repository
I have published the source code on GitHub in the following repository:
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;
}
Thanks Andre for sharing this. It's a needed functionality in RAP.
Hi Andre
One question how to define side effects on multiple fields ?
For instance field 1 affects field 2 ; field 3 ;
Regards
Sai
The syntax is the following (taken from the SAP Fiori Elements feature showcase app).
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.
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.
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.