CDS Views Concepts New
CDS Views Concepts New
3-Give Name and Description and click NEXT and Then FINISH.
4- This is what you get.
EXTENSION CDS:
Suppose we have standard CDS which SAP Provided. And if we want to
add a new field, we can use existing CDS View and just add new field.
Click NEXT->NEXT and then you get option Extend View
Remove last line and hit control space and you will get all fields. Select
fields to add.
VIEW ON VIEW:
Suppose we want to use our view on another view and that on other view we want to pass a parameter
to existing view. Right click on Data Definition and create new view.
Give name and hit next.
Define View
Give SQL View Name and select from original view and give where clause. You can Create N number of
view on View. Here is hard coded Currency Code.
Give SQL name and Pass Parameter to Original View on View CDS View.
DDIC VIEWS vs CDS VIEWS:
USE OF SYMANTICS:
This Type of Association is called ADHOC ASSOCIATION and work like a JOIN.
It is recommended not to use Adhoc Association because of join being performed. Rather use
EXPOSED ASSOCIATION:
Now if you want to show product details on right side of Fiori App for selected Item on Left side
Right Click on ITEM and select follow Association
Now it shows ASSOCIATION. You double click and it shows you one single product because of
CARDINALITY 0..1
SUPER VIEW WHICH WILL USE ITEM AND HEADER VIEWS TO DISPLAY FIROI APP:
Put HEADER Association View in Select FROM and ITEM association View in TO Section with Cardinality
1..* as we wan to select all item for one header selection.
Upon right Clicking and selecting association, system will show items
We Create ODATA Service using WebIDE. For more information watch how to SET UP WEBIDE
https://www.youtube.com/watch?v=1KACIrCTo04
In Order to create Fiori App, You need to add annotation in your CDS View
STEPS TO ACTIVATE ODATA SERVISE:
3- Add Service Name. Service name is always CDS View name with _CDS at the end of name.
HIT ENTER
4- Select Service name and hit ADD SELECTED SERVICE
5- Add Package Name where CDS View and Service Activation is so that it can be Transported.
6- Hit OK button
7- Go Back one step and you can see your active service . HIT CALL BROWSER Button
8- You will see it has created ODATA Service out of the BOX. We have 3 Entity sets, 1, for BP, 2 nd for Item
and 3rd for Super Invoice
NOTE: THIS IS ONE OF THE WAY TO CREATE ODATA SERVICE
https://www.youtube.com/playlist?list=PLcxqFaocb9WInzqf42H2d3Rhmgze15pEQ
It Will Fetch all the Services. Choose created Service. Select the service and hit NEXT
CDS Security:
DCL: Data Control language
Lets Create a CDS View with Adhoc Association to better understand the security concept
Right now we are able to see all the data form all the countries. We will use DCL to limit this access
Keep the same name as of CDS View Name with DCL at the end
Provide CDS View name and Field Name
Save and go back to initial and provide this field in field list
1- goto PFCG tcodeand give name of role an click on Create Single Role
2- Give Description, SAVE and then click on Authorization Tab and then click on Change Auth Data
6- It will show authority fields. Edit and add ACTIVITY and Field name as US.
Go to www.api.sap.com and in Content Types in left hand menu, click on CDS Views
1- Private _P_ViewName: not advised to use because SAP can change them and will disrupt programs
Consumption Views are already exposed so can be used directly in ODATA Services. ODATA Enabled.
That means you do not have to build ODATA
EXAMPLE:
Will Create BASIC INTERFACE VIEW with Dimension
Click NEXT, then NEXT and then select define view and hit finish
Add Annotation and then put table name and association name and hit control space and enter all
fields.
Now we will Create a Composite View .i.e. Interface View for Invoices Category Type FACT
Lets Create another view to join BUPA INVOICE HEADER
NOW MOVE TO LEVEL 2.
NOTE: Composite View of TYPE CUBE is needed if we want to use for analytics.
For this level we need to have the COLUMN NAMES which we need to extract data from. And we will
get it from views created in level 1.
This Annotation is needed in all of the view in this example.
Now to create Analytics, use tcode below. Remember to put “2C” in front of view name.