Вы находитесь на странице: 1из 4

@AbapCatalog.

sqlViewName: 'ZCDSAUGMEAL'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'CDS BOPF Integration for transactional Fiori App'
@OData.publish: true
@Metadata.allowExtensions: true

@ObjectModel: {
modelCategory: #BUSINESS_OBJECT,
compositionRoot: true,
transactionalProcessingEnabled: true,
createEnabled: true,
updateEnabled: true,
deleteEnabled: true,
draftEnabled: true,
writeActivePersistence: 'ZFLIGHT_MEALS',
writeDraftPersistence: 'ZDFLIGHT_MEALS'
}

define view ZCDS_AUG_FLIGHT_MEAL as select from zflight_meals as flmeal


association [1] to scarr as _Airline
on $projection.carrid = _Airline.carrid
association [1] to spfli as _Flights
on $projection.carrid = _Flights.carrid and $projection.connid =
_Flights.connid
association [1] to smeal as _Meals
on $projection.meal = _Meals.mealnumber
{
key meal_id,
@ObjectModel.foreignKey.association: '_Airline'
carrid,
@ObjectModel.foreignKey.association: '_Flights'
connid,
@ObjectModel.foreignKey.association: '_Meals'
meal,
total_seats,
status,
/* Associations */
//scarr
_Airline,
_Flights,
_Meals
}

@Metadata.layer: #PARTNER
annotate view ZCDS_AUG_FLIGHT_MEAL
with
{
@UI.lineItem: [{position: 10 }]
@UI.identification: [{position: 10 }]
@UI.hidden: true
meal_id;
@UI.selectionField: [{position: 10 }]
@UI.lineItem: [{position: 10 }]
@UI.identification: [{position: 10 }]
carrid;
@UI.selectionField: [{position: 20 }]
@EndUserText.label: 'Flight Number'
@UI.lineItem: [{position: 20 }]
@UI.identification: [{position: 20 }]
connid;
@UI.selectionField: [{position: 30 }]
@UI.lineItem: [{position: 30 }]
@UI.identification: [{position: 30 }]
meal;
@UI.lineItem: [{position: 40 }]
@UI.identification: [{position: 40 }]
@UI.hidden: true
total_seats;
@UI.identification: [{position: 50, type: #FOR_ACTION, dataAction:
'BOPF:APPROVE', label: 'Approve/Reject' }]
@UI.lineItem: [{position: 50, type: #FOR_ACTION, dataAction: 'BOPF:APPROVE',
label: 'Approve/Reject' }]
status;

class ZCL_CDS_V_VALIDATE definition


public
inheriting from /BOBF/CL_LIB_V_SUPERCL_SIMPLE
final
create public .

public section.

methods /BOBF/IF_FRW_VALIDATION~EXECUTE
redefinition .
protected section.
private section.
ENDCLASS.

CLASS ZCL_CDS_V_VALIDATE IMPLEMENTATION.

method /BOBF/IF_FRW_VALIDATION~EXECUTE.

data: lt_data type ZTCDS_AUG_FLIGHT_MEAL.

io_read->retrieve(
exporting
iv_node = is_ctx-node_key " Node Name
it_key = it_key " Key Table
importing
et_data = lt_data
).

if eo_message is initial.
eo_message = /bobf/cl_frw_factory=>get_message( ).
endif.

loop at lt_data assigning field-symbol(<fs>).

select single 'X' into @data(lv_exist) from scarr where carrid = @<fs>-
carrid.
if lv_exist <> 'X'.

eo_message->add_message(
exporting
is_msg = value #( msgid = 'SY' msgno = '499' msgv1 = 'Invalid
Flight Company' msgv2 = <fs>-carrid ) " Message that is to be added to the
message object
iv_node = is_ctx-node_key " Node to be used in the origin
location
iv_key = <fs>-key " Instance key to be used in the origin
location
iv_attribute = ZIF_CDS_AUG_FLIGHT_MEAL_C=>sc_node_attribute-
zcds_aug_flight_meal-carrid " Attribute to be used in the origin location
iv_lifetime = /bobf/cm_frw=>co_lifetime_transition " Lifetime
of the message
).

append value #( key = <fs>-key ) to et_failed_key.

endif.
clear lv_exist.

select single 'X' into @lv_exist from spfli where carrid = @<fs>-carrid and
connid = @<fs>-connid.

if lv_exist <> 'X'.

eo_message->add_message(
exporting
is_msg = value #( msgid = 'SY' msgno = '499' msgv1 = 'Invalid
Flight Connection' msgv2 = <fs>-connid msgv3 = <fs>-carrid ) " Message that is
to be added to the message object
iv_node = is_ctx-node_key " Node to be used in the origin
location
iv_key = <fs>-key " Instance key to be used in the origin
location
iv_attribute = ZIF_CDS_AUG_FLIGHT_MEAL_C=>sc_node_attribute-
zcds_aug_flight_meal-connid " Attribute to be used in the origin location
iv_lifetime = /bobf/cm_frw=>co_lifetime_transition " Lifetime
of the message
).

append value #( key = <fs>-key ) to et_failed_key.

endif.
endloop.

endmethod.
ENDCLASS.

class ZCL_CDS_D_UPDATE_BO_DATA definition


public
inheriting from /BOBF/CL_LIB_D_SUPERCL_SIMPLE
final
create public .

public section.
methods /BOBF/IF_FRW_DETERMINATION~EXECUTE
redefinition .
protected section.
private section.
ENDCLASS.

CLASS ZCL_CDS_D_UPDATE_BO_DATA IMPLEMENTATION.


method /BOBF/IF_FRW_DETERMINATION~EXECUTE.

data : lt_input_from_user type ZTCDS_AUG_FLIGHT_MEAL.

io_read->retrieve(
exporting
iv_node = is_ctx-node_key " Node Name
it_key = it_key " Key Table
importing
* eo_message = " Message Object
et_data = lt_input_from_user " Data Return Structure
* et_failed_key = " Key Table
* et_node_cat = " Node Category Assignment
).

loop at lt_input_from_user reference into data(lo_inp).

data : lv_seatsmax type p,


lv_seatsmax_b type p,
lv_seatsmax_f type p.

select sum( seatsmax ) as max, sum( seatsmax_b ) as bus, sum( seatsmax_f )


as fc
into ( @lv_seatsmax, @lv_seatsmax_b, @lv_seatsmax_f )
from sflight where carrid = @lo_inp->carrid and connid = @lo_inp->connid.

lo_inp->total_seats = lv_seatsmax + lv_seatsmax_b + lv_seatsmax_f.

io_modify->update(
exporting
iv_node = is_ctx-node_key " Node
iv_key = lo_inp->key " Key
iv_root_key = lo_inp->root_key " NodeID
is_data = lo_inp " Data
it_changed_fields = value #( (
ZIF_CDS_AUG_FLIGHT_MEAL_C=>sc_node_attribute-zcds_aug_flight_meal-
total_seats ) ) " List of Names (e.g. Fieldnames)
).

endloop.

endmethod.
ENDCLASS.

Вам также может понравиться