See some examples about annotating side effects.
Using
TriggerActionto calculate theGrossPriceandNetPriceIncludingTaxthrough the function importCalculatePriceIncludingRegionalTax, when the source propertyUnitPriceorProductQuantityis modified. The side effect is triggered only whenUnitPriceandProductQuantityare successfully validated.XML Annotation
<Annotations Target="STTA_SALES_ORDER_WD_20_SRV.C_STTA_SalesOrder_WD_20Type"> <Annotation Term="com.sap.vocabularies.Common.v1.SideEffects" Qualifier="CalculatePrice"> <Record> <PropertyValue Property="SourceProperties"> <Collection> <PropertyPath>UnitPrice</PropertyPath> <PropertyPath>ProductQuantity</PropertyPath> </Collection> </PropertyValue> <PropertyValue Property="TargetProperties"> <Collection> <String>GrossPrice</String> <String>NetPriceIncludingTax</String> </Collection> </PropertyValue> <PropertyValue Property="TriggerAction" String="STTA_SALES_ORDER_WD_20_SRV.STTA_SALES_ORDER_WD_20_SRV_Entities/CalculatePriceIncludingRegionalTax"/> </Record> </Annotation> </Annotations>
The Guidance section in our live example shows the various uses of side effects along with examples in XML and ABAP CDS annotation. For more information and live examples, see the SAP Fiori development portal at Global Patterns - Side Effects.
Side effects are configured according to the modeling such as create, update, delete in RAP BDEF (behavior definition). You can see the ABAP CDS annotation examples in the RAP documentation. For more information, see Side Effects.
The following sample code shows you an example with actions, multiple targets, and messages:
ABAP CDS Annotation
side effects { field IntegerValue affects field ProgressIntegerValue, field RadialIntegerValue; field Timestamp affects field IANATimestamp; field Supplier affects entity toSupplier; action changeCriticality affects field CriticalityCode; action resetTimesChildCreated affects field TimesChildCreated, permissions ( action resetTimesChildCreated ); action overwriteTimezone affects $self; determine action validateDate executed on field ValidTo affects messages; $self affects permissions ( update _Child ); determine action updateTimes executed on entity _Child affects field TotalPieces; }
For information about SAP Fiori elements for OData V2, see Side Effect Annotations: Examples.