Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
In this blog you will learn how to consume the HANA Calculation Views inside a S/4HANA CDS views.

Consider a scenario where business already have report based Enterprise HANA calculation view and now they want to consume same view in S/4 HANA CDS view with additional functionalities and  business logic. Below are the steps which we need to follow to achieve above use case.

Steps to be followed:

  1. Create Calculation view in E-HANA.

  2. Test view output in HANA using native SQL.

  3. Create CDS table function.

  4. Create AMDP function for calling HANA native query on calculation view.

  5. Expose result to outer CDS with business logic.


So, let’s start building:

Step 1:  Create a Calculation View

  1. Open Eclipse/ HANA Studio

  2. Select system and expand content folder and choose package where calculation view needs to be created.

  3. Right Click and Create New Calculation View.

  4. Add required tables/ views and select columns as per logic. In the View Properties make Default Client = Cross Client and Apply privileges as blank if not required.

  5. Now save and activate the view.


Step 2: Test view output in HANA using native SQL.


Open a SQL console by selecting a system and clicking on open a SQL console for selected system and write a query to fetch data from the view and hit a execute button to see the view’s data.


Step 3: Creating CDS Table Function

  1. Open ABAP perspective from Eclipse/ HANA Studio

  2. Select system and choose package where CDS data definition of type table function needs to be created.

  3. Create a table function by right clicking on the Package and select New other ABAP Repository object-> Data Definition and provide name and description then select next

  4. Choose the template “Define Table Function with Parameters” and say finish.

  5. Add required fields from HANA calculation view with data type as below and give AMDP class and function name which will create in next step and activate it.


Step 4: Create AMDP function for calling HANA native query on calculation view 

  1. Select package where AMDP Class needs to be created.

  2. Create AMDP Class by right clicking on the Package and select New ABAP Class and provide name and description then click finish.

  3. Write AMDP Class as below by specifying “interfaces if_amdp_marker_hdb” statement with addition of defining function in public section. In the return statement of function definition use the SQL query that we used in step 2 for displaying calculation view’s data and then activate AMDP ABAP Class.


Step 5: Expose table function results to outer CDS with business logic

  1. Select package where CDS data definition needs to be created.

  2. Create CDS View by right clicking on the Package and select New à other ABAP Repository object-> Data Definition and provide name and description then select next

  3. Choose the template “Define view with join” and say finish.

  4. Add required business logic to fetch data from table function and other views/ tables and activate it.

  5. Run the CDS View and see the results.


This concludes the above blog post. Hope the blog helped you. Please feel free to give feedback and comments.

Happy Learning!!!
10 Comments
Labels in this area