cancel
Showing results for 
Search instead for 
Did you mean: 

How to create AMDP in S/4 Hana Public Cloud ADT & Get the result in CDS Format

SiddharthaDas
Explorer
220

Hi Everyone , 

As i am new to the S/4 Hana Development , Can anyone share me any document or suggest me how to create a AMDP Class with a Standard CDS Query and Get that Procedure Result in a New CDS Format . 

It will be very helpful for me . 

Thanks in advance 

View Entire Topic
AndreasMuno
Product and Topic Expert
Product and Topic Expert

Thank you for your question, @SiddharthaDas.

without any further context I could imagine a number or ways to take advantage of the abstraction and readily available services provided with core data services and their views without even the need to go down to the underlaying data model or entities.

Let’s dive into how you can consume standard CDS views in ABAP, especially with an emphasis on extensions in embedded Steampunk (SAP S/4HANA with Steampunk capabilities).

Consuming CDS Views in ABAP

When working with CDS views in ABAP, especially in the context of extending functionalities in embedded Steampunk, you will typically:

  1. Define and Extend CDS Views
  2. Read Data from CDS Views in ABAP Programs
  3. Use Views in Analytical Scenarios

1. Define and Extend CDS Views

You can consume existing standard CDS views or create your own. Let's start with an example where we have a standard CDS view and we want to extend it.

Standard CDS View

Assume you have a standard CDS view SAP_CDS_VIEW.

Extending the CDS View

If you need to extend this standard CDS view, you can use the EXTEND VIEW statement:

@AbapCatalog.sqlViewName: 'ZCDSVIEWEXT'@EndUserText.label: 'Extended CDS View'extend view SAP_CDS_VIEW with ZCDS_VIEW_EXTENSION {    new_field1,    new_field2}

 

2. Read Data from CDS Views in ABAP Programs

Once you have your CDS views (extended) as per need, you can read them in your ABAP code. In embedded Steampunk, the process is similar to classical ABAP but optimized for cloud.

Example ABAP Code to Read CDS View

Here’s how you can consume this CDS view in your ABAP program:

DATA: lt_data TYPE TABLE OF zcds_view_extension.
SELECT * FROM zcds_view_extension INTO TABLE lt_data.
LOOP AT lt_data INTO DATA(ls_data).  WRITE: / ls_data-field1, ls_data-field2, ls_data-field3.ENDLOOP.

3. Using Views in Analytical Scenarios

In analytical scenarios, you typically use CDS views for defining complex queries and projections. These views can be directly consumed in SAP Fiori apps or analytical tools.

Example: Using CDS View in Fiori

Suppose you have extended or created analytical CDS views tagged with annotations for analytical purposes:

 

@Analytics.query: true@AccessControl.authorizationCheck: #CHECK@EndUserText.label: 'Analytical CDS View'define view ZANALYTICAL_CDS_VIEW as select from SAP_CDS_VIEW {    key field1,    field2,    field3,    @AnalyticsDetails.query.display: [        { position : 1, label: 'Measure 1' }    ]    measure1,    @AnalyticsDetails.query.display: [        { position : 2, label: 'Measure 2' }    ]    measure2}

Using ABAP Development Tools (ADT) in Eclipse for Embedded Steampunk

When working in embedded Steampunk, you'd typically use ABAP Development Tools (ADT) in Eclipse. Here's a brief on how to proceed:

  1. Create CDS Views: Use ADT to define CDS views.
  2. Extend Existing Views: Use the EXTEND functionality in ADT.
  3. Use @annotations: Utilize annotations like @Analytics.query to mark views for analytical use.
  4. Integrate in Your ABAP: Consume these CDS views in your ABAP classes or reports as shown previously.

Summary

  • Define/Extend CDS Views: Create or extend existing CDS views for your data models.
  • Read from ABAP: Use standard ABAP SELECT statements to query data from these CDS views.
  • Utilize Analytical Views: Mark your CDS views with appropriate annotations for analytical scenarios.

By following this approach, you can seamlessly transition your old ABAP skills into the new age of ABAP with CDS views, ensuring clean, maintainable, and efficient extensions in embedded Steampunk.

Feel free to ask if you need any more details or further clarification! Otherwise, please mark this question as solved. Thank you.