Skip to Content
0
Sep 06, 2018 at 07:28 PM

Running Sum in CDS Views in SAP HANA

9770 Views Last edit Sep 13, 2018 at 04:56 PM 2 rev

Hi Experts,

I am trying to calculate the running sum in CDS view. below cds view is join of VBAK and VBRP table.

Data should like this in output in running sum field.

am trying to achieve it with windows function in SQL but the below statement Sum() is not working in CDS view.

I am getting an error while activating CDS view. Error is : System is expecting ',' after sum.

Could you please do let me know how can we do this in CDS view.

define view ZC_VBAK_VBRP_RUN as select 
from ZI_VBAK_ZVBRP 
 {
  
  SalesDocument, 
  SalesCreationDate, 
  BillingDocument, 
  Billing_Item, 
  BillingAmount, 
  BillingDate,
  currency,
sum(BillingAmount) OVER(partition by ("salesdocument") orderby ("Salesdocument")) as runningsum
   
}

Attachments

runningsum.jpg (39.4 kB)