determination Calculate_Total_price on modify { field BookingFee; }
determination calculate_Total_Price on modify { create; field flightprice; }
internal action ReCalcTotalPrice;
action Apply_Discount parameter zrk_sde_a_apply_disc result [1] $self;
*************** calculate_Total_Price at Travel Entity
METHOD Calculate_Total_price.
"update involved instances
MODIFY ENTITIES OF zrk_sde_i_travel IN LOCAL MODE
ENTITY Travel
EXECUTE recalctotalprice
FROM CORRESPONDING #( keys ).
ENDMETHOD.
*************** calculate_Total_Price at Booking Entity
METHOD calculate_Total_Price.
READ ENTITIES OF zrk_sde_i_travel IN LOCAL MODE
ENTITY Booking
BY \_Travel
FIELDS ( TravelUUID )
WITH CORRESPONDING #( keys )
RESULT DATA(lt_travels).
"update involved instances
MODIFY ENTITIES OF zrk_sde_i_travel IN LOCAL MODE
ENTITY Travel
EXECUTE recalctotalprice
FROM VALUE #( FOR <fs_key> IN lt_travels ( %tky = <fs_key>-%tky ) ).
ENDMETHOD.
*************** Internal action - Implementation
METHOD ReCalcTotalPrice.
READ ENTITIES OF zrk_sde_i_travel IN LOCAL MODE
ENTITY Travel
FIELDS ( BookingFee )
WITH CORRESPONDING #( keys )
RESULT DATA(lt_travels).
LOOP AT lt_travels ASSIGNING FIELD-SYMBOL(<Fs_travel>).
<Fs_travel>-TotalPrice = <Fs_travel>-BookingFee.
READ ENTITIES OF zrk_sde_i_travel IN LOCAL MODE
ENTITY Travel
BY \_Booking
FIELDS ( FlightPrice )
WITH VALUE #( ( %tky = <fs_travel>-%tky ) )
RESULT DATA(lt_bookings).
LOOP AT lt_bookings ASSIGNING FIELD-SYMBOL(<fs_booking>).
<Fs_travel>-TotalPrice = <Fs_travel>-TotalPrice + <fs_booking>-FlightPrice.
ENDLOOP.
ENDLOOP.
"update involved instances
MODIFY ENTITIES OF zrk_sde_i_travel IN LOCAL MODE
ENTITY Travel
UPDATE FIELDS ( TotalPrice )
WITH VALUE #( FOR travel IN lt_travels (
%tky = travel-%tky
TotalPrice = travel-TotalPrice ) ).
ENDMETHOD.
METHOD Apply_Discount.
LOOP AT keys ASSIGNING FIELD-SYMBOL(<fs_key>).
DATA(lv_disc_percent) = <fs_key>-%param-Discount_percent.
ENDLOOP.
READ ENTITIES OF zrk_sde_i_travel IN LOCAL MODE
ENTITY Booking
FIELDS ( FlightPrice )
WITH CORRESPONDING #( keys )
RESULT DATA(lt_bookings).
LOOP AT lt_bookings ASSIGNING FIELD-SYMBOL(<fs_booking>).
<fs_booking>-FlightPrice = <fs_booking>-FlightPrice * ( 100 - lv_disc_percent ) / 100.
ENDLOOP.
"update involved instances
MODIFY ENTITIES OF zrk_sde_i_travel IN LOCAL MODE
ENTITY Booking
UPDATE FIELDS ( FlightPrice )
WITH VALUE #( FOR <fs_book> IN lt_bookings (
%tky = <fs_book>-%tky
FlightPrice = <fs_book>-FlightPrice ) ).
READ ENTITIES OF zrk_sde_i_travel IN LOCAL MODE
ENTITY Booking
FIELDS ( FlightPrice )
WITH CORRESPONDING #( keys )
RESULT DATA(lt_bookings_upd).
RESUlT = VALUE #( FOR <fs_res> IN lt_bookings_upd ( %tky = <fs_res>-%tky %param = <fs_res> ) ) .
ENDMETHOD.
define behavior for ZRK_SDE_I_TRAVEL alias Travel
...
side effects
{
field BookingFee affects field TotalPrice;
}
define behavior for zrk_sde_i_booking alias Booking
...
side effects
{
field FlightPrice affects field _Travel.TotalPrice;
action Apply_Discount affects field _Travel.TotalPrice ;
}
projection;
strict ( 2 );
use draft;
use side effects; <<<<<<=======
define behavior for ZRK_SDE_C_TRAVEL alias Travel
use etag
{
}
<Annotations Target="SAP__self.TravelType">
<Annotation Term="SAP__common.Label" String="Projection View for ZRK_SDE_I_TRAVEL"/>
<Annotation Term="SAP__common.SideEffects" Qualifier="SAP__Field_BookingFee">
<Record Type="SAP__common.SideEffectsType">
<PropertyValue Property="SourceProperties">
<Collection>
<PropertyPath>BookingFee</PropertyPath>
</Collection>
</PropertyValue>
<PropertyValue Property="TargetProperties">
<Collection>
<String>TotalPrice</String>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
<Annotations Target="SAP__self.BookingsType">
<Annotation Term="SAP__common.Label" String="ZRK_SDE_C_BOOKING"/>
<Annotation Term="SAP__common.SideEffects" Qualifier="SAP__Field_FlightPrice">
<Record Type="SAP__common.SideEffectsType">
<PropertyValue Property="SourceProperties">
<Collection>
<PropertyPath>FlightPrice</PropertyPath>
</Collection>
</PropertyValue>
<PropertyValue Property="TargetProperties">
<Collection>
<String>_Travel/TotalPrice</String>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
<Annotations Target="SAP__self.Apply_Discount(SAP__self.BookingsType)">
<Annotation Term="SAP__core.OperationAvailable" Path="_it/__OperationControl/Apply_Discount"/>
<Annotation Term="SAP__common.SideEffects" Qualifier="SAP__Action_Apply_Discount">
<Record Type="SAP__common.SideEffectsType">
<PropertyValue Property="TargetProperties">
<Collection>
<String>_it/_Travel/TotalPrice</String>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
7 | |
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |