Understanding a Basic CDS View:
- In Top part of a basic CDS, annotations are mentioned. Annotations make CDS view semantically rich. Every CDS annotation has a different meaning. If you need to take a look at available annotations, just type @ in the top part of CDS and press Control + Space.
- CDS starts with DEFINE/EXTEND syntax and gives CDS a Structured Object name.
- After name of CDS, SELECT query is initiated and JOINS are defined beforehand
- Inside curly braces, projection list(fields to be selected) is provided
- An individual field can be associated with special semantic meaning using annotations
- Inbuilt functions can be used inside CDS which effectively helps in Code Push Down.
- ‘Where’ conditions for CDS query can be mentioned just below projection list which filters the data and reduces selection effort
- A “Group By” clause can be added if aggregation(sum, count etc.) is used in query
- A selection can be UNIONed with another select using UNION ALL/DISTINCT clause. All projections of UNION should be the similar i.e. number of field selection, their type and sequence must be same!
Steps to Check, activate and check data:
- Once CDS Editing is complete, a syntax check(Ctrl + F2) can be done. In case of any error, Problem view in Eclipse can be used to see errors present in CDS view.
- Once errors are fixed, CDS can be activated(Ctrl + F3).
- CDS can be checked for data after activation. For checking data, right click on DDLS object in Project Explorer view > Open With > Data Preview
Data preview is a feature-rich editor where following actions can be done:
- Filters can be set of Fields
- Number of entries can be checked
- SQL console can be opened directly from here where query can be fired on CDS or any table/view of SAP to check data accuracy
- Columns can be selected which user needs see at a time
- Data can be exported to local desktop
- Data can be refreshed if number and sequence of CDS projection is not changed
- Maximum number of rows can be set which reduces load of database