Hello SCN-community,
I tried my first steps in the world of CDS. As you may recognized in my last blog, I have to provide a kind of HANA-readiness. The Core Data Services (CDS) are available on both platforms – HANA and non-HANA.
In order to solve a problem in BRFplus, carsten.ziegler gave me the advice to take a look at CDS. I have to build a few aggregates upon the new General Ledger for some kind of statistics. The problem addresses to sum a few amount columns whose currency information points to another table. This is currently
not supported by the BRFplus database lookup expression. Technically in the case of the ledger it’s getting more complicated due to its table design.
But what if you only operate with one single currency? In fact if you have the same problem with another table, CDS is definitely something you may look
at.To give you an overview I built a small example table:
All amount fields refer to T000-MWAER (the clients default currency). For now, we want to sum each amount column of the table in BRFplus. This gives us the following errors:
In order to solve it we think about a view in which we explicit forget the currency details. This is done by creating a CDS view. But in CDS we are able to do more. We can create a view hiding the currency information or we can map all amount columns to a constant defined currency. I prefer the last variant because we take the currency information into BRFplus and do not need to append it later to the data. But sometimes you may not need the currency so I provide examples for both implementations.
By using the CAST function we transform the values of type amount to simple decimal numbers.
In order to give the currency information back to BRFplus we have to normalize all amount columns. This is done by defining a new currency key column. This column is annotated with @Semantics.currencyCode. To provide a constant value as currency information, I use the scalar value 'EUR' and cast it to the appropriate type. Then we have to link all currency fields of the underlying table to the new currency key column. To do this we annotate each amount column with @Semantics.amount.currencyCode and provide the currency key column as the property.
With one of those CDS views we can finalize the example in BRFplus.
If we try to simulate the database lookup expression we get something like this:
The example was written on a SAP NW7.40SP6 on HANA where I did not find many built in SQL-Functions.
That’s something I will check when SP8 is officially out.
CDS with it's Advanced SQL will be one important functionality in todays application development. It even solves problems of already released projects like BRFplus. Due to the fact CDS is available for non-HANA and HANA (here with a wider feature set) it becomes the backbone to build HANA-ready solutions I think.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |