ABAP CDS on HANA-2

cds

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.

1

Expand Code Data Services & select DDL Source and finally select NEXT button.

2

The below screen appears.

3

Provide CDS view name & description. Select FINISH button.

4

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 {

}


5


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.

6

In the selection condition, we can see the input condition.

7


Run the view as ABAP Application. The input screen appears.

8

Provide a value & hit enter key so that OK button is activated.

9

So here is the output. To change the input parameter value, select the Parameter link.

10

Try with a different input value.

1112


 

Advertisements

2 thoughts on “ABAP CDS on HANA-2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s