cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP CDS Views

aalexis
Participant
0 Kudos

Hello All,

I am trying to create a cube like structure for a simple sales order. I need my sums to be displayed by sales org. In order to accomplish I followed the following

1. Created a BASIC CDS View with VBELN, VKORG, NETWR association with SalesOrg Description (Annotation @VDM.viewType: #BASIC) - displays data.

2. Created a COMPOSITE View with the same columns (@VDM.viewType:#CUBE, @DefaultAggregation: #SUM for SalesAmount with Currency) and it activates and displays data..

When It displays data, even if I select columns Sales Org, Description and Amount, it is not summarizing by sales Org and it still shows individual rows of Sales Amount, though I am not displaying Sales Order.

How can I make the CDS to display summary data by Sales Org and if detail needed with Sales Order.

What changes are to be done to the view?

Should I create a #CONSUMPTION view and OData.publish and the summation will happen at the front end?

Appreciate your reply,

Thanks,

Arthur.

Accepted Solutions (1)

Accepted Solutions (1)

mdcastle
Active Participant
0 Kudos

You need to create another view on top of your Composite view

define view ZCDS_something
  as select from ZCDS_something_else

{
   key vkorg,
       @DefaultAggregation: #SUM
       sum(netwr) as total
}
group by vkorg

You could also publish the composite view as an odata service as you suggested and let the visualisation do the calculation for you.

aalexis
Participant
0 Kudos

Mark appreciate your reply.

It is not only Sales Org, there are multiple other characteristics (Distribution Channel, Division, Sales Group,Sales Partners, Customer, Customer Group, Material Type, Material Group, Week, Month, Quarter and Year, so far that is all been identified as requirement, may be more). In HANA models I can list all characteristics and aggregate on KYF and when consuming it will do the sum as the characteristics used. .

Is it similar to that? so I can list all the group by characteristics in the next view?

(BASIC --> COMPOSITE --> CONSUMPTION)

Can I create a consumption view and publish it, will the front end do the summation by various characteristics?

Thank you,

Arthur.

aalexis
Participant
0 Kudos

Also when I try building the view I get the following error. I believe it is at the start of the line (Position 1)key must be contiguous and start at the first position

aalexis
Participant
0 Kudos

Mark,

I made it to work by removing the Key from the underlying views and it shows the summarized value. But still 2 things I would need to get clarified to build proper models.

1. The Key and how it will affect

2. The CONSUMPTION and COMPOSITE VIEW Difference. Also will try additional key characteristics and key figures.

Thank you,

Arthur.

mdcastle
Active Participant
0 Kudos

HANA CDS appears to be more feature-rich than ABAP CDS. I don't think you can get summary data within Eclipse without creating a view where you 'Group By'. You could publish the view where you group your characteristics, as an OData service - this can be done on a view which is either annotated as a #COMPOSITE or #CONSUMPTION. I've found that some functionality in Fiori Elements is only available when the CUBE (@Analytics.dataCategory: #CUBE) is published as an OData service and NOT when the annotation @Analytics.query: true is set.

mdcastle
Active Participant
0 Kudos

The syntax looks ok to me - did you originally have the key field lower down? I've noticed that Eclipse sometimes doesn't clear errors and will only remove the error after activation.

mdcastle
Active Participant
0 Kudos

From memory you'll need a key if you're annotating a view with @analytics.query: true

Have a look here https://blogs.sap.com/2017/10/09/abap-core-data-services-part-2virtual-data-model-types/ for info about Views.

Answers (1)

Answers (1)

dmitry_kuznetsov1
Active Participant
0 Kudos

aalexis, the two you ask about sere a very different purpose:

Composite view functions as a Cube-like structure, it typically has one or more fact "tables" and lots of associations to master-data views. Pretty much like star-join node in HANA CalcViews or BW Cube (depends on your background)

Consumption view is pretty much a query, with no associations, but potentially lots of parameters, restricted & calculated measures, structure of rows/columns, fields exposed from associations (see above), etc.