ABAP CDS on HANA-1 Basic CDS View Creation Open HANA Studio. Goto ABAP perspective. Open the project, Navigate to the package. Right click on the package & select New->Other ABAP Repository Object. Object.
Expand Code Data Services & select DDL Source and finally f inally select NEXT button.
Provide CDS view name & description. Select FINISH button.
The view editor opens up. Here we have to provide the details.
Provide SQL VIEW NAME, provide a meaningful end user text label, provide view type as a s BASIC. On the define view statement, provide the select form as “SFLIGHT”, mention the field names marking key fields. Activate and execute the view.
The view editor opens up. Here we have to provide the details.
Provide SQL VIEW NAME, provide a meaningful end user text label, provide view type as a s BASIC. On the define view statement, provide the select form as “SFLIGHT”, mention the field names marking key fields. Activate and execute the view.
@AbapCatalog.sqlViewName: ‘ZSFLIGHTVIEW’ @AbapCatalog.compiler.compareFilter: @AbapCatalog.compiler.com pareFilter: true @AccessControl.authorizationCheck: @AccessControl.authoriz ationCheck: #NOT_REQUIRED #NOT_REQUIRED @EndUserText.label: ‘Flight Information’ @VDM.viewType: #BASIC define view Zflight_View 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 } Here is the CDS view output.
Once the DATA Definition is activated, activated, ddl sql view is created.
ABAP CDS on HANA-2 CDS view with Parameter In last post Basic 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. Object.
Expand Code Data Services & select DDL Source and finally f inally 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.
ABAP CDS on HANA-3 Calling CDS view in program( SQL Query)
We have the CDS view CDS view with Parameter . Now let’s use this CDS view in the report/program select query.
Program Code:
To check if DB supports VIEWS_WITH_PARAMETERS usually class CL_ABAP_DBFEATURES is used but now we can directly use ##db_feature_mode[views_with_parameters] as a part of SQL query. PARAMETERS: p_carr type sflight-carrid. START-OF-SELECTION. “if ( CL_ABAP_DBFEATURES=>use_features( ” requested_features = VALUE #( ( “CL_ABAP_DBFEATURES =>VIEWS_WITH_PARAMETERS ) ) ) = abap_true ). select * FROM Zflight_Param_View( flight_code = @p_carr ) into TABLE @DATA(lt_flight) ##db_feature_mode[views_with_parameters]. cl_demo_output=>display_data( EXPORTING value = lt_flight name = ‘Flight CDS View with Input Parameters’ ). “endif.
Output.
ABAP CDS on HANA-4
Explicit Name List use in CDS We create a simple CDS View like below.
@AbapCatalog.sqlViewName: ‘ZSFLIGHT_EXP’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Flight Information’ @VDM.viewType: #BASIC define view Zflight_Exp_View as select from sflight{ key sflight.carrid , key sflight.connid , key sflight.fldate , sflight.price , sflight.currency , sflight.planetype , sflight.seatsmax , sflight.seatsocc }
Run the View/Data Preview- The column heading appears same as the column names.
We can explicitly define the Column Name list as below(list name numbers should be equal to the selection column numbers)
@AbapCatalog.sqlViewName: ‘ZSFLIGHT_EXP’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Flight Information’ @VDM.viewType: #BASIC define view Zflight_Exp_View // Expicit Name List (Code, AirName, FDate, Fare,Curr, Cat, Max_seat, Ava_seat) as select from sflight{ key sflight.carrid, key sflight.connid, key sflight.fldate, sflight.price, sflight.currency, sflight.planetype, sflight.seatsmax, sflight.seatsocc }
The output list column names same as what is mentioned in the explicit name list.
Even we have another way of explicitly defining column names by using ‘as expcolumnname, in the selection list.
@AbapCatalog.sqlViewName: ‘ZSFLIGHT_EXP’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Flight Information’ @VDM.viewType: #BASIC define view Zflight_Exp_View // Expicit Name List // (Code, AirName, FDate, Fare,Curr, Cat, Max_seat, Ava_seat) as select from sflight{ key sflight.carrid as Code, key sflight.connid as AirName, key sflight.fldate as FDate, sflight.price as Fare, sflight.currency as Curr, sflight.planetype as Cat, sflight.seatsmax as MaxSeat, sflight.seatsocc as AvaSeat }
The output list column names appear same as what is mentioned in the selection list.
ABAP CDS on HANA-5 JOINs in CDS View In ABAP CDS, Join between two data sources is allowed. Allowed joins are:-
Inner Join/Join Left Outer Join Right Outer Join The post shows a simple Inner Join between data sources form SCARR & SPFLI table. In HANA studio, open ABAP perspective. From Project explorer, right click on th e package and choose New->Other ABAP Repository Object
Choose DDL Source & select Next
Provide a name & description & select finish
Provide aSQL View Name & code lines. Save & Activate.
@AbapCatalog.sqlViewName: ‘ZFLIGHT_JOIN’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Flight with Inner Join CDS View’ define view Zflight_Join_Vw as select from spfli join scarr on spfli.carrid = scarr.carrid { key spfli.carrid, key scarr.carrname, key spfli.connid, spfli.countryfr, spfli.cityfrom, spfli.airpfrom, spfli.countryto, spfli.cityto, spfli.airpto } Execute it or by right click choose Data Preview.
Output:
ABAP CDS on HANA-6 Case Expression in CDS View Create a CDS view and use below case expression.
@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: ‘Use of Case Expression in CDS view’ define view Zflight_Case_Exp as select from spfli { key spfli.carrid, key spfli.connid, spfli.countryfr, spfli.countryto, case when distance >= 10000 then ‘Long Way Journey’ when distance >= 5000 and distance < 10000 then ‘Medium Way Journey’ else ‘Short Way journey’ end as journey_type } Output- Data Preview
SPFLI Table Entries
ABAP CDS on HANA-7
Aggregate expression in CDS View An aggregate expression calculates a single value from an operand operand by calling an aggregate function from multiple rows of a results set. They need Group By clause to aggregate values from multiple rows and the nonaggregated fields are specified in the GROUP BY clause. Aggregate Functions:
Created a CDS view with below select with SUM function.
@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: ‘Flight View with Aggregation Operation’ define view Zflight_View as select from sflight { key sflight.carrid, key sflight.connid, sum( price ) as Total_Amount, sflight.currency } group by carrid, connid, currency
Data Preview:
CDS view with SUM & COUNT functions
@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: ‘Flight View with Aggregation Operation’ define view Zflight_View as select from sflight { key sflight.carrid, key sflight.connid, sum( price ) as Total_Amount, sflight.currency, count( *) as Lines } group by carrid, connid, currency
Data Preview
SFLIGHT Table contents
ABAP CDS on HANA-8 Arithmetic expression in CDS View
Allowed Arithmetic operators in CDS view.
CDS View-
@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: ‘Flight View with Aggregation Operation’ define view Zflight_View as select from sflight as s { key s.carrid, key s.connid, key s.fldate, s.price, s.currency, s.seatsmax – s.seatsocc as Avai_Seats_in_Economy_Class, s.seatsmax_b – s.seatsocc_b as Avai_Seats_in_Business_Class, s.seatsmax_f – s.seatsocc_f as Avai_Seats_in_First_Class }
Data Preview
ABAP CDS on HANA-9 Conversion Functions for Currencies and Units in CDS view Function CURRENCY_CONVERSION performs a currency conversion for the value passed to formal parameter amount.The currency conversion is performed on the basis of the rules stored in the database tables TCURR. Function UNIT_CONVERSION performs a unit conversion for the value passed to formal parameter quantity.The unit conversion is performed on the basis of the rules stored in transaction CUNI and in the database tables T006. Function DECIMAL_SHIFT sets the decimal separator of the value that is passed to formal parameter amount according to a currency. Below post shows to perform a currency conversion. We have SFLIGHT entries with respect to carrid ‘AA’ where price is available in USD but our CDS view should show a price in a different currency.
The CDS view with currency_conversion function, pass the amount to be converted, source currency, target currency and the exchange rate date.
@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: ‘Flight View with Aggregation Operation’ define view Zflight_View with parameters p_curr: abap.cuky(5), p_dat:abap.dats as select from sflight as s { key s.carrid, key s.connid, key s.fldate, currency_conversion( amount => s.price, source_currency => s.currency, target_currency => :p_curr, exchange_rate_date => :p_dat ) as local_amount, :p_curr as local_currency } where carrid = ‘AA’ Data Preview: provide the target currency and the date.
Here is the amount in the target currency.
Syntax for Unit_Conversion Function. unit_conversion( quantity => ”, source_unit => ”, target_unit => ” , error_handling => ” )
Syntax for Decimal Shift Function. decimal_shift( amount => ”, currency => ”, error_handling => ‘ ‘ ) ABAP CDS on HANA-10 SQL functions in ABAP CDS List of SQL Functions
Numeric Functions ABS(arg) CEIL(arg) DIV(arg1, arg2) DIVISION(arg1, arg2, dec) FLOOR(arg) MOD(arg1, arg2) ROUND(arg, pos) String Functions CONCAT(arg1, arg2) CONCAT(arg1, arg2, space_cnt)
LPAD(arg, len, src) REPLACE(arg1, arg2, arg3) SUBSTRING(arg, pos, len) CDS View
@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: ‘Demo View SQL Functions’ define view Zflight_View as select from spfli as s { key s.carrid, key s.connid, concat_with_space(s.cityfrom, s.cityto, 4 ) as City_From_To } Data Preview
ABAP CDS on HANA-11 Association in ABAP CDS An association in CDS view joins different data sources. Defining and using associations is a high-value wrapping of the syntax for joins. A CDS View with association between SPFLI & SCARR table.
@AbapCatalog.sqlViewName: ‘ZFLIGHT_AVW’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: ‘Flight CDS View with association’ define view Zflight_Asso_Vw as select from spfli association [1..1] to scarr as _scarr on $projection.carrid = _scarr.carrid { spfli.carrid, spfli.connid, spfli.countryfr, spfli.cityfrom, spfli.airpfrom, spfli.countryto, spfli.cityto, spfli.airpto, /* Associations */ _scarr }
Data Preview- No particular field of _SCARR added to the select . So in data preview only fields of spfli table are shown.
To add particular field of association _scarr, it can be added by the alias name and dot followed by field name
Data Preview.
ABAP CDS on HANA-12 Exposing CDS view as oData Service
Create a CDS view and we have the view type as ‘BASIC’ view
To publish this as oData, add the annotation as: @OData.publish: true
@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Flight View CDS’ @VDM.viewType: #BASIC @OData.publish: true define view Zflight_View as select from sflight { key sflight.carrid, key sflight.connid, key sflight.fldate, sflight.price, sflight.currency, sflight.planetype, sflight.seatsmax, sflight.seatsocc }
Activate the view. Then a symbol would appear at the line: @OData.publish: true, whihc tells that a service ‘ZFLIGHT_VIEW_CDS’ created and we have to add this service on Tx- /IWFND/MAINT_SERVICE
Go to the Tx- /IWFND/MAINT_SERVICE, click on Add Service button
Provide the alias name, and the service name and hit enter key.
The created service will appear in the list. Select the service and click on Add Selected Service.
Select local object and continue.
The information appears.
In the hana studio, activate the the view and a new symbol appears at the line’@OData.publish: true’ . Put the cursor on the mark
Click on the link: OData-Service
Here is the service. Now change the url and put ‘$metadata’
So here the service metadata information appears. sap/opu/odata/sap/ZFLIGHT_VIEW_CDS/$metadata
To execute the view and get the details, change the url sap/opu/odata/sap/ZFLIGHT_VIEW_CDS/Zflight_View It returns all the entries.
ABAP CDS on HANA-13 ABAP CDS View Types & Annotation Types
Different CDS views types are allowed to create and those are :-
1. Basic – Views that form the core data basis without data redundancies. 2. Composite – Views that provide data derived and/or composed from the BASIC views. 3. Consumption – Views that serve for specific application purposes and may be defined based upon public interface (for example, BASIC and COMPOSITE) views. 4. Extension – A HANA view can be used as abap CDS view called Extension view. A CDS interface view cam be made as Public or private. Private interface (for example, BASIC & COMPOSITE) views represent technical helper views which may only be used by their defining responsibilities.
1. 2.
3. 4.
CDS Annotations: A CDS annotation adds metadata to the view that expands the syntax options of SQL. Core annotations – It can be specified in the source code of any ABAP CDS object & are evaluated by run time environment. UI annotations -It allows to focus OData UI vocabulary on usage patterns of data in UIs representing certain semantic views of data. The UI annotations used are evaluated by the SADL framework, which means that SADL translates CDS annotations into the corresponding OData annotations. Search annotations – It allows to define search fields as filters . The annotations used are also evaluated by the SADL framework. Analytics annotations – It provides data elements with aggregation behavior in analytical scenarios. An example of – a Public BASIC CDS Interface View @VDM.viewType: #BASIC define view Flight ... { key Carrid, ... }
An example of – a Private COMPOSITE CDS Interface View
@VDM.private: true @VDM.viewType: #COMPOSITE define view FlightDetails ... { key Carrid, ... }
ABAP CDS on HANA-14 Consumption CDS View The post describes about how to create a consumption view. A consumption view basically build upon a basic or composite view.In this process will create:-
1. A basic view on a DB table 2. A Consumption view on the basic view Creation of Basic View
@AbapCatalog.sqlViewName: ‘ZFLIGHTVW1’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Basic Airline View’ @VDM.viewType: #BASIC @Analytics.dataCategory: #DIMENSION define view Zflight_View1 as select from scarr { key scarr.carrid as AirlineID, scarr.carrname as AirlineName, @Semantics.currencyCode: true scarr.currcode as AirlineCurrency } Data Preview
Creation of Consumption view on basic view- which is oData publish enabled
@AbapCatalog.sqlViewName: ‘ZFLIGHTVW2’ @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Consumption Flight View’ @VDM.viewType: #CONSUMPTION @OData.publish: true define view Zflight_View2 as select from Zflight_View1 { key Zflight_View1.AirlineID, Zflight_View1.AirlineName, Zflight_View1.AirlineCurrency }
Data Preview
ABAP CDS on HANA-15 Creating COMPOSITE & CONSUMPTION View for analytic engine
This post describes creating several BASIC views & then creating a COMPOSITE view by using the BASIC views & finally creating a CONSUMPTION view from the COMPOSITE view which is enabled for analytic query. 1. Creating 3 BASIC VIEWs 2. Creating 1 COMPOSITE VIEW 3. Creating 1 CONSUMPTION VIEW which is enabled for analytics
Basic View 1 on SCARR table- Its a DIMENSION type as it hits th e DB table directly
@AbapCatalog.sqlViewName: ‘ZVWSCARR’ @ClientDependent: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Airlline’ @VDM.viewType: #BASIC @Analytics.dataCategory: #DIMENSION @Analytics.dataExtraction.enabled: true @ObjectModel.representativeKey: ‘Airline’ define view ZDemo_Scarr as select from scarr { key scarr.carrid as Airline, @Semantics.text: true scarr.carrname as AirName, @Semantics.currencyCode: true scarr.currcode as AirCurrency, scarr.url as AirlineUrl }
Data Preview
Basic View 2 on SPFLI table- Its a DIMENSION type as it hits the DB table directly with association to the basic view
ZDemo_Scarr. @AbapCatalog.sqlViewName: ‘ZVWSPFLI’ @ClientDependent: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Airline Connection’ @Analytics.dataCategory: #DIMENSION
@Analytics.dataExtraction.enabled: true @VDM.viewType: #BASIC @ObjectModel.representativeKey: ‘AirConnection’ define view ZDemo_Spfli as select from spfli association [0..1] to ZDemo_Scarr as _Scarr on $projection.Airline = _Scarr.Airline { @ObjectModel.foreignKey.association: ‘_Scarr’ key spfli.carrid as Airline, key spfli.connid as AirConnection, spfli.countryfr as DepartureCountry, spfli.countryto as ArrivalCountry, @Semantics.quantity.unitOfMeasure: ‘AirDistanceUnit’ @DefaultAggregation:#SUM spfli.distance as AirDistance, @Semantics.unitOfMeasure: true spfli.distid as AirDistanceUnit, _Scarr } Data Preview
Basic View 3 on SFLIGHT table- with association to view ZDemo_Scarr and view ZDemo_Spfli. Several semantics are used for different fields on aggregation and currency & unit.
@AbapCatalog.sqlViewName: ‘ZVWSFLIGHT’ @ClientDependent: true @AccessControl.authorizationCheck:#NOT_REQUIRED @EndUserText.label: ‘Airline Schedule’ @Analytics.dataCategory: #CUBE @Analytics.dataExtraction.enabled: true @VDM.viewType: #BASIC define view ZDemo_Sflight as select from sflight association [0..1] to ZDemo_Scarr as _Scarr on $projection.Airline = _Scarr.Airline association [0..1] to ZDemo_Spfli as _Spfli on $projection.Airline = _Spfli.Airline and $projection.AirConnection = _Spfli.AirConnection {
@ObjectModel.foreignKey.association: ‘_Scarr’ key sflight.carrid as Airline, @ObjectModel.foreignKey.association: ‘_Spfli’ key sflight.connid as AirConnection, key sflight.fldate as FlightDate, @Semantics.amount.currencyCode: ‘FlightCurrency’ @DefaultAggregation: #MIN sflight.price as FlightPrice, @Semantics.currencyCode: true sflight.currency as FlightCurrency, @DefaultAggregation: #SUM sflight.seatsmax as MaximumAvaSeats, @DefaultAggregation: #SUM sflight.seatsocc as NumberOfAvaSeats, /* Associations */ _Scarr, _Spfli }
Data Preview
All fields of scarr, splfi, sflight are available in the view ZDemo_Sflight due to the association with views ZDemo_Scarr & ZDemo_Spfli Now next step is to build a composite view on the basic view ZDemo_Sflight and select as many fields from the view ZDemo_Sflight so that this composite view can expose many fields to the consumption views for analytic analysis.
@AbapCatalog.sqlViewName: ‘ZVWCSFLIGHT’ @ClientDependent: true @AccessControl.authorizationCheck:#NOT_REQUIRED @EndUserText.label: ‘Airline Schedule by Country’ @Analytics.dataCategory: #CUBE @VDM.viewType: #COMPOSITE define view ZDemo_Csflight as select from ZDemo_Sflight { @ObjectModel.foreignKey.association: ‘_Scarr’ key ZDemo_Sflight.Airline, @ObjectModel.foreignKey.association: ‘_Spfli’ key ZDemo_Sflight.AirConnection, key ZDemo_Sflight.FlightDate, @Semantics.amount.currencyCode: ‘FlightCurrency’ @DefaultAggregation:#MIN ZDemo_Sflight.FlightPrice, @Semantics.currencyCode: true
ZDemo_Sflight.FlightCurrency, @DefaultAggregation: #SUM ZDemo_Sflight.MaximumAvaSeats, @DefaultAggregation: #SUM ZDemo_Sflight.NumberOfAvaSeats, /* Associations */ ZDemo_Sflight._Scarr, ZDemo_Sflight._Spfli, ZDemo_Sflight._Scarr.AirName, ZDemo_Sflight._Scarr.AirlineUrl, ZDemo_Sflight._Spfli.DepartureCountry, ZDemo_Sflight._Spfli.ArrivalCountry }
Data Preview
Next step is to create a CONSUMPTION View from the COMPOSITE view- ZDemo_Csflight and enabling it for analytics. In the analytics view fields are marked as rows or columns, other fields can be left . Here the filter semantics provided for the field ‘Departure Country’ and with mandatory option means when we this view is analyzed with analytic engine, we have to pass the departure country value for selection.
@AbapCatalog.sqlViewName: ‘ZVWSFLIGHTQUERY’ @ClientDependent: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: ‘Flight Analytic Query’ @Analytics.query: true @VDM.viewType: #CONSUMPTION @OData.publish: true define view ZDemo_Sflight_Query as select from ZDemo_Csflight { @AnalyticsDetails.query.axis: #ROWS ZDemo_Csflight.Airline, @AnalyticsDetails.query.axis: #ROWS ZDemo_Csflight.AirConnection, @AnalyticsDetails.query.axis: #ROWS ZDemo_Csflight.FlightDate, @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: true } @AnalyticsDetails.query.axis: #ROWS @EndUserText.label: ‘Departure Country’ ZDemo_Csflight.DepartureCountry, @AnalyticsDetails.query.axis: #ROWS @EndUserText.label: ‘Arrival Country’ ZDemo_Csflight.ArrivalCountry , @AnalyticsDetails.query.axis: #COLUMNS ZDemo_Csflight.FlightPrice, ZDemo_Csflight.FlightCurrency, ZDemo_Csflight.MaximumAvaSeats, ZDemo_Csflight.NumberOfAvaSeats }
Data Preview
Next thing is to test the Consumption View in the analytic tool. In a BW system you can find the Tx- RSRT
Here we have to provide for consumption sql view name which is enabled for analytic query and provide 2C before it and hit enter key.
Now the actual query is on the composite view used in the consumption view. Execute.
As we have made Departure Country as a mandatory filter option in the consumption view, it asks for a value. Provide a value & Execute.
The list of values appear with 131 records. Let’s further filter the selection for Airline(CARRID) & Connection Number(CONNID). Select the filter button for each.
Select LH and click on transfer.
Now the selection result list reduced to 67 records. Choose filer for Connection Number. Select 400 and select Transfer.
Now with the filters we have few records now select Graphical Display.
A graphical view is displayed.
ABAP CDS on HANA-16 Navigating to association in Data Preview The post describes how to display the content of the association in the data preview of the CDS view.
Create a CDS view on the table SCARR & add all columns in the selection marking the key field.
Data preview & all records appear perfectly.
Now create a new CDS view on the table SPFLI table with association on the previous cds view Ztest_Scarr with cardinality 0..1. In the selection list no fields of the association is added explicitly but the entries alias _Scarr of the view Ztest_Scarr is added.
Data preview. So all the seelcted fields of SPFLI appear in the preview. Now to see the association, select a line and from the header arrow you can navigate to the association.
It displays the result from the association view.
Another way to navigate to the associated view is to right click on the record and from the options Follow Association can enable to view the association data in the preview.
Choose the association.
Here is the data preview
Now lets create a new CDS view on the table SFLIGHT with selected fields and marking the key fields.
Data Preview.
Now let ’s use the view Ztest_Sflight in the already created view Ztest_Spfli as an association with cardinality as [0..*]. No fields selected from the association Ztest_Sflight but the association alias name itself added in the selection so that it can be used in some other view to added fields from the association using path expression.
Do a data preview. Select one line and right click, chose Follow Association.
Here we have two association one with cardinality [0..1] for Ztest_Scarr and second with cardinality [0..*] for Ztest_Sflight. Choose the _Sflight association.