CDS View
Mostly in S4 HANA the clients requirement will be in CDS views or in AMDP for reporting purpose.
- In HANA, every operation executed in database level. whereas in ECC systems we fetch the data from database to application layer before performing any operation.
- PUSH DOWN Technique: CDS view works by pushing code down to database for executing required operation. This is called code push down technique.
2.CDS views are consumed through.
- AFO Operation
- Extractors
- Fiori Tiles
AFO Operation
- AFO is a plugin to MS-OFFICE, with the help of CDS View we can fetch data from SAP system to MS OFFICE.
- MS Excel use CDS view it for various analytic purpose like pie chart preparation, graph preparation, sorting etc.
Note;
CDS view helps to view the data in third party system(ms-office).
Extractor:
CDS view helps to fetch data from SAP system to BODS Systems and BW systems for further processing.
Fiori Tiles:
CDS view with the help of ODATA Annotations it delivers the data from SAP system to FIORI tiles, Which will be further used by UI5/Fiori consultant for front end development.
2.Important terms in CDS.
- DDL - Data Definition Language (every thing in CDS view coding is ddl)
- DCL - Data Control Language(Defining authorization for CDS view are called DCL)
- CDS view has expression, association, annotation but normal views doesn't has these facilities.
- Expression: All the statement written in the CDS views are called expression.
- Association: On demand joins can be achieved using association.
- Annotation: Annotated codes are executed only at the run time. It will not be executed in hana studio or SAP gui, it will executed only at the time of accessing CDS view by fiori tiles or AFO operation or extractors.
3.Sample CDS view.
- SQL View name: Whenever we create CDS view, there will be SQL view created in background.
- Buffer specific annotation: To decide whether to have single or multiple buffer.
- CDS view entity: CDS view name.
- Name list: Fields to be display in output.
- CDS view and SQL view name should not be same.
- All the operation in the above pic will be executed directly in the database.
- CDS view itself just a query, So we cannot debug.
- For simple calculation like just to display, normal reports itself enough. For a complex calculation like sorting, summary preparation, aggregation and group-by operation, etc CDS view shows good performance improvement than normal reports.
- Output of one CDS view can be consumed by another CDS view. we can use two or more cds views to achieve final task.
- We can see CDS view in SE11 using SQL view name but we cannot edit in SE11.
- Every CDS view will be in 1 to 1 relationship with SQL view.
4.HANA studio/ Eclipse configuration.
- Install HANA studio or Eclipse in your system
- Goto Help -> Install new software
- Copy the like from "SAP development tools" website and paste it in HANA studio.
- Select All -> Follow wizard -> click finish.
- Change perspective to ABAP.
- Add SAP system.
- New -> ABAP Project -> select SAP system from the list.
5.To create CDS View.
- Press CTRL+N -> Select ABAP -> Select CDS -> Data Defnition.
- Enter Project, Package, Name, Desc
- Follow wizard.
- Enter Finish.
6.Simple CDS view.
Step 1
//Default annotation
@AbapCatalog.sqlViewName: 'ZSALESORDERV' - SQL View name
@AbapCatalog.compiler.compareFilter: true@AbapCatalog.preserveKey: true - To set key based on data source
@AccessControl.authorizationCheck: #CHECK - Authorization option
@EndUserText.label: 'base view for sales order' - Description
Step 2
//Select Conditiondefine view zsalesorder_base
as select from vbak
{
Step 3
//Display fields
vbeln as SalesOrder,erdat as OrderDate,
netwr as ActualPrice,
waerk as Currency,
}
6.Sample CDS view for sales order.
- Using Joins
- Using Aggregate function( SUM and Group By )
Step 1
@AbapCatalog.sqlViewName: 'ZSALESORDERV'
@AbapCatalog.compiler.compareFilter: true@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'base view for sales order'
Step 2
//Join Conditiondefine view zsalesorder_base
as select from vbak as SalesHeader
left outer join vbap as SalesItem on SalesHeader.vbeln = SalesItem.vbeln
{
Step 3
SalesItem.vbeln as SalesOrder,SalesItem.posnr as Item,
SalesItem.erdat as OrderDate,
SalesItem.matnr as Material,
Step 4
//Sum operation using keyword "sum"
sum(SalesItem.netwr) as ActualPrice,SalesItem.waerk as Currency,
}
//Need to add all the fields in Group By statement
group by
SalesItem.vbeln,
SalesItem.posnr,
SalesItem.erdat,
SalesItem.matnr,
SalesItem.waerk
7.CDS view for sales order
- Using fiori annotation for SUM operation.
- Using fiori annotation for establishing FK btw currency field and actual price field.
- Concatenate operation using concat keyword.
Code:
- @AbapCatalog.sqlViewName: 'ZSALESORDERV'
- @AbapCatalog.compiler.compareFilter: true
- @AbapCatalog.preserveKey: true
- @AccessControl.authorizationCheck: #CHECK
- @EndUserText.label: 'base view for sales order'
- //Join operaration
- define view zsalesorder_base
- as select from vbak as SalesHeader
- left outer join vbap as SalesItem on SalesHeader.vbeln = SalesItem.vbeln
- {
- //Fields to be displayed in OP
- SalesItem.vbeln as SalesOrder,
- SalesItem.posnr as Item,
- SalesItem.erdat as OrderDate,
- SalesItem.matnr as Material,
- //Sum operation using annotation
- @DefaultAggregation: #SUM
- //creating FK rel btw actualprice and currency field
- @Semantics.amount.currencyCode: 'Currency'
- SalesItem.netwr as ActualPrice,
- //currency field is key field for actual price
- @Semantics.amount.currencyCode:true
- SalesItem.waerk as Currency,
- //concatenate price and currecny unit field
- concat(cast(SalesItem.netwr as abap.char( 20 )), SalesItem.waerk ) as Price
- }

No comments:
Post a Comment