
@AbapCatalog.sqlViewName: 'ZISPFLI01'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Flight Connections'
define view ZI_FlightConnections
as select from spfli
left outer join zspfli_act as CancellationInfo on spfli.carrid = CancellationInfo.carrid
and spfli.connid = CancellationInfo.connid
association [0..1] to U99_I_Airline as _Airline on $projection.Airline = _Airline.Airline
association [0..1] to U99_IAIRPORT as _AirportFrom on $projection.AirportFrom = _AirportFrom.Airport
association [0..1] to U99_IAIRPORT as _AirportTo on $projection.AirportTo = _AirportTo.Airport
association [0..1] to S_CityAirport as _CityFrom on $projection.CityFrom = _CityFrom.City
association [0..1] to S_CityAirport as _CityTo on $projection.CityTo = _CityTo.City
{
@ObjectModel.foreignKey.association: '_Airline'
@UI: { lineItem: [{ position: 10 }] , selectionField: [{ position: 10 }]}
key spfli.carrid as Airline,
@UI.lineItem: [{ position: 20 }]
key spfli.connid as FlightConnection,
@ObjectModel.foreignKey.association: '_CityTo'
@UI: { lineItem: [{ position: 40 }] , selectionField: [{ position: 15 }]}
spfli.cityfrom as CityFrom,
@ObjectModel.foreignKey.association: '_AirportFrom'
@UI: { lineItem: [{ position: 50 }] , selectionField: [{ position: 20 }]}
spfli.airpfrom as AirportFrom,
@ObjectModel.foreignKey.association: '_CityTo'
@UI: { lineItem: [{ position: 70 }] , selectionField: [{ position: 25 }]}
spfli.cityto as CityTo,
@ObjectModel.foreignKey.association: '_AirportTo'
@UI: { lineItem: [{ position: 80 }] , selectionField: [{ position: 30 }]}
spfli.airpto as AirportTo,
@UI.lineItem: [{ position: 90 }]
spfli.deptime as DepartureTime,
@UI.lineItem: [{ position: 100 }]
spfli.arrtime as ArrivalTime,
@UI.lineItem: [{ position: 120 }]
@EndUserText.label: 'Cancelled On'
CancellationInfo.cancelledon,
@UI.lineItem: [{ position: 130 }]
@EndUserText.label: 'Cancelled By'
CancellationInfo.cancelledby,
@UI.hidden:true
cast( 'X' as boole_d ) as IsActiveCancelFlight,
@UI.hidden:true
cast ( 'X' as boole_d ) as IsActiveKeepFlight,
_Airline,
_AirportFrom,
_AirportTo,
_CityFrom,
_CityTo
}
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_ZIFLTCON_MPC_EXT->ADD_ACTION
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_ACTION_NAME TYPE /IWBEP/MED_EXTERNAL_NAME
* +--------------------------------------------------------------------------------------</SIGNATURE>
method add_action.
data: lv_fc_fieldvalue type /iwbep/med_annotation_value,
lo_complex_type type ref to /iwbep/if_mgw_odata_cmplx_type,
lo_prop type ref to /iwbep/if_mgw_odata_property.
data(lo_action) = model->create_action( iv_action_name ).
"set return parameter
lo_action->set_return_entity_type( 'ZI_FlightConnectionsType' ) .
lo_action->set_return_entity_set( 'ZI_FlightConnections' ).
lo_action->set_http_method( 'PUT' ).
lo_action->set_return_multiplicity( /iwbep/if_mgw_med_odata_types=>gcs_cardinality-cardinality_1_1 ).
"specify input parameters
data(lo_parameter) = lo_action->create_input_parameter(
iv_parameter_name = 'Airline'
iv_abap_fieldname = 'AIRLINE' ).
lo_parameter->/iwbep/if_mgw_odata_property~set_type_edm_string( ).
lo_parameter->set_maxlength( iv_max_length = 3 ).
data(lo_parameter1) = lo_action->create_input_parameter(
iv_parameter_name = 'FlightConnection'
iv_abap_fieldname = 'FLIGHTCONNECTION' ).
lo_parameter1->/iwbep/if_mgw_odata_property~set_type_edm_string( ).
lo_parameter1->set_maxlength( iv_max_length = 4 ).
"Is Action Active?
concatenate 'IsActive' iv_action_name into data(lv_action_ac).
data(lo_annotation) = lo_action->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
lo_annotation->add( iv_key = 'action-for' iv_value = 'ZI_FlightConnectionsType' ).
lo_annotation = lo_action->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
lo_annotation->add( iv_key = 'applicable-path' iv_value = lv_action_ac ).
endmethod.
method define.
super->define( ) .
add_action( iv_action_name = 'CancelFlight' ) .
add_action( iv_action_name = 'KeepFlight' ) .
endmethod.
define view ZI_FlightConnections
as select from spfli
....
{
@ObjectModel.foreignKey.association: '_Airline'
@UI: { lineItem: [{ position: 10 } ,
{ type: #FOR_ACTION, invocationGrouping: #CHANGE_SET, position: 0, dataAction: 'MPC_EXT:CancelFlight', label: 'Cancel Flight' },
{ type: #FOR_ACTION, invocationGrouping: #CHANGE_SET, position: 1, dataAction: 'MPC_EXT:KeepFlight' , label: 'Keep Flight' }] ,
selectionField: [{ position: 10 }]}
key spfli.carrid as Airline,
....
}
method /iwbep/if_mgw_appl_srv_runtime~changeset_begin.
cv_defer_mode = abap_true .
endmethod.
method /iwbep/if_mgw_appl_srv_runtime~changeset_process.
data : lo_func_import_context type ref to /iwbep/if_mgw_req_func_import,
lt_parameters type /iwbep/t_mgw_name_value_pair,
ls_flight_con_status type zspfli_act,
ls_result type zcl_zifltcon_mpc_ext=>ts_zi_flightconnectionstype,
ls_changeset_response type /iwbep/if_mgw_appl_types=>ty_s_changeset_response.
"read requests where operation is execute action (EA)
loop at it_changeset_request assigning field-symbol(<lfs_changeset_request>)
where operation_type = /iwbep/if_mgw_appl_types=>gcs_operation_type-execute_action.
"find function name
lo_func_import_context ?= <lfs_changeset_request>-request_context .
data(lv_function_import_name) = lo_func_import_context->get_function_import_name( ) .
if lv_function_import_name = 'CancelFlight' or lv_function_import_name = 'KeepFlight' .
"read parameters
lt_parameters = lo_func_import_context->get_parameters( ).
ls_flight_con_status-carrid = lt_parameters[ name = 'AIRLINE' ]-value .
ls_flight_con_status-connid = lt_parameters[ name = 'FLIGHTCONNECTION' ]-value .
"set/reset values
case lv_function_import_name.
when 'CancelFlight'.
ls_flight_con_status-cancelledby = sy-uname .
ls_flight_con_status-cancelledon = sy-datum .
when 'KeepFlight'.
clear ls_flight_con_status-cancelledby .
clear ls_flight_con_status-cancelledon .
endcase .
modify zspfli_act from ls_flight_con_status .
"select new values
"do you know - even if you haven't yet committed the changes,
"system will return new data
"search 'transaction isolation levels' to read more on this
select single from zi_flightconnections fields *
where airline = @ls_flight_con_status-carrid
and flightconnection = @ls_flight_con_status-connid
into corresponding fields of @ls_result .
"prepare response with operation number and respective data,
"insert in CT_CHANGESET_RESPONSE
ls_changeset_response-operation_no = <lfs_changeset_request>-operation_no .
copy_data_to_ref(
exporting
is_data = ls_result
changing
cr_data = ls_changeset_response-entity_data ).
insert ls_changeset_response into table ct_changeset_response.
endif .
endloop .
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 | |
4 | |
4 | |
4 |