CDS view with Parameter
In last post Basic CDS View Creation we created a basic cds view. In this post will make use of parameter in CDS view.
Open HANA Studio. Goto ABAP perspective. Open the project, Navigate to the package. Right click on the package & select New->Other ABAP Repository Object.
Expand Code Data Services & select DDL Source and finally select NEXT button.
The below screen appears.
Provide CDS view name & description. Select FINISH button.
The CDS view code format appears.
@AbapCatalog.sqlViewName: ‘sql_view_name’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: ‘Flight CDS View with parameter’
define view Zflight_Param_View as select from data_source_name {
}
Provide the code, declare an input parameter as ‘flight_code’ with data element type ‘s_carr_id’ and make use of that in the where condition.
@AbapCatalog.sqlViewName: ‘ZSFLIGHTPARVIEW’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: ‘Flight CDS View with parameter’
@VDM.viewType: #BASIC
define view Zflight_Param_View
with parameters flight_code: s_carr_id
as select from sflight{
key sflight.carrid as AirlineCode,
key sflight.connid as ConnectionNumber,
key sflight.fldate as FlightDate,
sflight.price as Airfare,
sflight.currency as FareCurrency,
sflight.planetype as PlaneCategory,
sflight.seatsmax as MaxAvailableSeats,
sflight.seatsocc as OccupiedSeats
} where carrid = $parameters.flight_code
Activate the cds view. After activation, ddl sql view is created.
In the selection condition, we can see the input condition.
Run the view as ABAP Application. The input screen appears.
Provide a value & hit enter key so that OK button is activated.
So here is the output. To change the input parameter value, select the Parameter link.
Try with a different input value.
2 comments