Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
AndreaUS
Product and Topic Expert
Product and Topic Expert

Since ABAP release 7.88, SAP BTP ABAP Environment 2205, CDS view entities are feature complete. In this blog series, you find a complete list of new features, improvements, and differences of CDS view entities compared to CDS DDIC-based views.


Introduction and Overview

Part l: New features

Part ll: Improvements

Part lll: Differences

Part ll: Improvements

Learn about the improved design and architecture of CDS view entities.

  1. No CDS-managed DDIC view created in ABAP Dictionary.
  2. CDS view entities are generated as SQL views on the SAP HANA database.
  3. Stricter syntax and semantic checks.
  4. Automatic and implicit client handling.
  5. Improved activation performance.
  6. Currency and quantity handling in expressions.
  7. Improved expression matrix.

1. No CDS-managed DDIC view created in ABAP Dictionary

For each CDS DDIC-based view, a CDS-managed DDIC view is created in ABAP Dictionary upon activation. The name of this CDS-managed DDIC view is defined using the annotation @AbapCatalog.sqlViewName: 'name'.

A CDS view entity does not have such a DDIC view attached and this entails the following advantages:

  • Improved performance during activation.
  • One object less which can become inconsistent.
  • Simplified syntax. Only one name, not several names.

2. CDS view entities with input parameters are generated as SQL views on the SAP HANA database

CDS DDIC-based views with input parameters are created as table functions on the SAP HANA database. The reason is that table functions were the only artefacts that were able to deal with input parameters at the time when CDS views were first introduced.
However, table functions have a different scope than views, because inside a table function, you can write arbitrary SQL script, whereas in CDS views you can only define a SELECT statement.
By now, the SAP HANA database has extended SQL views so that they directly support input parameters. And CDS view entities make use of this. A CDS view entity, whether it has parameters or not, is always generated as SQL view on the database. ­­

3. Stricter syntax and semantic checks

In CDS view entities, stricter syntax and semantic checks have been implemented in many places where this is considered beneficial. Here are a few examples:

  • Annotations must have a CDS annotation definition in a DDLA file. Otherwise, a syntax error occurs.

Example: In a CDS DDIC-based view, you may write @bla.bla: true as header annotation. Even if no annotation of name @bla.bla exists, no syntax check error occurs.

In a CDS view entity, by contrast, this is not possible. If you write an annotation which is not registered as DDLA file, a syntax check error occurs.

    • In comparisons, stricter type compatibility checks apply.

Example: cast(111 as int1) = 256

This comparison is allowed in DDIC-based view, but not in a CDS view entity. 256 is not within the value range of data type INT1 and therefore, a syntax check error occurs in a CDS view entity.

    • Prefixing: if a CDS view entity selects data from more than one data source by means of an explicit join, each single element in the SELECT list must have a source prefix. Otherwise, a syntax check error occurs. Each element must be uniquely identifiable to avoid later inconsistencies, for example in an extension scenario.

4. Automatic and implicit client handling

In CDS DDIC-based views, client handling can be configured via header annotations:

  • ClientHanling.type
  • ClientHandling.algorithm

In CDS view entities, these annotations are not supported. Client handling is handled completely internally in CDS view entities. If a view entity is client-dependent, the session variable $session.client is used to locally filter the client for this view. This reduces the complexity of client-handling and developers do not have to take care of it.
For further details, see ABAP Keyword Documentation on SAP Help Portal: ABAP CDS - Client Handling in CDS View Entities.

5. Faster activation performance

CDS view entities have a much faster activation performance than CDS DDIC-based views. The main reason is that they don’t have any DDIC view attached. Instead of two objects, there’s only one object to be activated.
The following table shows examples for CREATE and CHANGE scenarios:

  • For a view stack of 10 or 20 views which are built on each other, activation time in a CREATE scenario is reduced to half.
  • For a view stack of 10 or 20 views which are built on each other, activation time in a CHANGE scenario has been reduced by factor 0,7.
View Stack / ScenarioActivation time DDIC-based viewActivation Time CDS view entity
10 / CREATE VIEW Stack20,19 s10,61 s
20 / CREATE VIEW Stack40,56 s21,37 s
10 / CHANGE FIELD32,68 s22,11 s
20 / CHANGE FIELD68,88 s48,09 s

6. Currency and quantity handling in expressions

CDS DDIC-based views don’t have any special checks implemented for amounts and quantities in expressions. Amount fields and quantity fields can be combined in expressions without any restrictions, even if the result makes no sense.

CDS view entities do check for currency and quantity fields in expressions. The reference to a unit or currency key is taken into account in the handling of expressions, comparisons, functions, union views, intersect views, and case expressions.

Example

7€ + 13km would be possible in a CDS DDIC-based view, because there is no check for references. In a CDS view entity, a syntax check error occurs, because CDS view entities do check for references and this calculation does not make any sense.

The following matrix shows how amounts and quantities can be combined in arithmetic expressions in CDS view entities and the result type. Depending on the result, the respective reference annotation is required. ‘-‘ means that this combination is not valid and a syntax check error occurs.

operands / operators/*+, -
amount, amountcalculated quantitycalculated quantityamount
quantity, quantitycalculated quantitycalculated quantityquantity
calculated quantity, amountcalculated quantitycalculated quantityamount
amount, quantitycalculated quantitycalculated quantity-
calculated quantity, numbercalculated quantitycalculated quantity-
calculated quantity, quantitycalculated quantitycalculated quantityquantity
calculated quantity, calculated quantitycalculated quantitycalculated quantitycalculated quantity
amount, numberamountamount-
number, amountcalculated quantityamount-
quantity, numberquantityquantity-
number, quantitycalculated quantityquantity-

Two new functions support amount and quantity handling in expressions:

  • GET_NUMERIC_VALUE returns the numeric value of a currency or quantity field without its currency or unit.
  • CURR_TO_DECFLOAT_AMOUNT converts a currency field of data type CURR into a currency field of data type DECFLOAT34.

Hint: In CDS view entities, the annotations @Semantics.currencyCode and @Semantics.unitOfMeasure are not required and not supported.

For further details, see ABAP Keyword Documentation on SAP Help Portal: ABAP CDS - Amounts and Quantities.

7. Improved expression matrix

Operand positions of clauses, expressions, and built-in functions have been opened up, that means, they accept a broader range of elementary operands and expressions as input. Nesting of expressions within each other has been enhanced. The following CDS view entity provides some examples:

    • Built-in function SUBSTRING:
      • Session variable allowed as first operand.
      • Parameter allowed as second operand.
      • Arithmetic expression allowed as third operand.
    • Simple case expression: Cast expressions are allowed as first operand.
      • Arithmetic expressions are allowed as operand after WHEN.
    • Searched case expression:
      • Another case expression is allowed as operand after WHEN.
    • Join ON condition: a literal is allowed on the left side.
    • Arithmetic expressions and case expressions are allowed as operands.
    • WHERE clause: Parameters and typed literals allowed as operands.

 

@EndUserText.label: 'Extended expression matrix'
define view entity zas_v2_extended_expr_matrix
  with parameters
    @EndUserText.label: 'Parameter for dec test'
    p_abap_dec : abap.dec( 8, 2 )
  as select from demo_ddic_types  as a
    inner join   demo_expressions as b on 1 = 1
{
  key a.char1                                  as keyField,
      case cast( a.char1 as char3)
      when substring( cast( 'AA' as char2), 1, 2)  then 'text1'
      when substring( cast( 'BB' as char2), 1, 2)  then 'text2'
      else                                              'OtherText'
      end                                      as CaseExp,
      substring(  $session.user_timezone, $parameters.p_abap_int4,1*2)
                                               as func_session_timezone,
      case when a.int2 * 2 = case 500 when 7 then 1 end
      then 'x'
      else 'y'
      end                                      as Arith_on_lhs_of_case,
      case a.int2
      when 260 * 1 then 0
      else              a.int2
      end                                      as simple_case
}
where
      b.dec3 * 5             = case a.int4 when 500 then 0 else 1 end
  and $parameters.p_abap_dec = abap.d16n'123.45'

 

The view entity shown above provides some examples for the extended expression matrix, but there are many more combinations which are allowed in CDS view entities, but not in CDS DDIC-based views. For example, the HAVING clause and the ON condition of associations have also been opened up for more different types of operands.

Check the release news and the ABAP Keyword Documentation for further details.

Further information

8 Comments
vonglan
Active Participant
0 Kudos

I am just transferring a Z CDS view from 7.50 to a view entity in a 7.56 system.

Three questions, maybe you can point me to the documentation:

1.

Eclipse shows me a lot of warnings of the kind

CAST CHAR to identical type

for example for

  cast( 'SALE' as zv_zvoov_type ) as zDocumentType,

Is there a better way to write this? I want to keep the DDIC type zv_zvoov_type, because of the texts.

2.

I also noticed that the syntax for domain fixed values is not supported any more:

#zv_zvoov_type.'SALE' as zDocumentType

(I did not use it in 7.50 anyway, because there were problems with generic type.)
Is there a new concept for that?

3.

I also get the new warning "Search help assignment for field '&1' is not inherited from base object", e.g. for

  so_head.SalesDocument, 

How do I solve this?

AndreaUS
Product and Topic Expert
Product and Topic Expert
A complete list of CDS syntax warnings and how to solve them is not yet available but we are working on it.

  1. The syntax is fine. Casting to a data element just for the texts is a typical use case. No action required. The warning can be ignored. It is planned to offer a way to suppress this warning. We don't know yet when it will be shipped.

  2. CDS view entities offer typed literals. In addition, SAP will soon offer CDS simple types - self-defined data types which allow, among others, enumerations. This is the replacement for domain fix values.

  3. This is explained as part of the migration tool documentation. Input help assignments are lost during a migration. As a solution, you can cast to a data element to preserve the value help after the migration. For example:CAST ( field AS data_element_with_f4 PRESERVING TYPE ) AS field

albertosimeoni
Participant
0 Kudos

Hello,

there is a problem, CDS View are used as ODP for data warehouses sold by SAP.
The removal of the option #CLIENT_INDEPENDENT creates a problem in some use cases.

for example:

if a firm needs to specify different client to manage different companies in S4, But they want a unique data warehouse (BW4 or DWC).

-> with CDS entities they will found themself in a mess by ABAP developers simplifications,

They can not read data of all companies at once as the connection is RFC with client specified.

so they need to declare as many connection/ source system as the client they use. and run as many DTPs as needed to retrieve data.

please consider to re-enable an (optional) annotation to totally disable client check.

 

Regards

AndreaUS
Product and Topic Expert
Product and Topic Expert
Hi there,

thank you for your feedback. After consulting with the responsible PO, we recommend that you open a case and discuss your issues with the application responsible. The application should take care of this issue and find a solution.

The concept of client handling in CDS view entities has been tested and approved by consumers. It is suitable for most use cases and provides additional security for consuming applications.

Regards

Andrea
dennisrihm
Discoverer
0 Kudos
Hi Andrea,

thank you for your blog. We were upgrading our on-premise S4 system for the latest release and faced some issues regarding stricter syntax and semantic checks, especially your point no. 3: "Prefixing".

Is there a documentation or anything to see which warn messages will be error messages. In our case we extended a SAP View. During the upgrade this view couldn't be activated and SUM ran into problems.

For the next upgrade we want to prevent that from happening and get a smoother upgrade process.

Thank you.

Regards

Dennis
Hi Dennis,

It is currently not possible before the upgrade to analyze the results of upcoming stricter checks in an automated way. For this purpose we have prepared the following notes:

2998810 - ABAP CDS: Syntax errors for customer views or CDS view extends during or after upgrade

https://i7p.wdf.sap.corp/sap/support/notes/2998810

-> Here potential topics with solution are listed which may create inconsistencies during upgrade. One can check whether objects are already aligned to these topics prior to upgrade.

3123580 - Dictionary Check of DDL Sources prior Zero Downtime Option (ZDO) Upgrades and Updates

https://i7p.wdf.sap.corp/sap/support/notes/3123580

-> Here you can check the inconsistencies via check report (attached with the note) during the upgrade.

 

Regards, Harish
dennisrihm
Discoverer
0 Kudos
Hi Harish,

thank you for you answer, these informations are very useful.

During our upgrade the checks/ activation of the Data Definitions was in Phase "MAIN_SHDRUN/PARDIST_ORIG". We were not able to activate any DD Objects during this phase, so we hat to delete the extension. As far as I understood, to prevent this from happening we should execute the report of note 3123580, correct?

Thank you.

Regards

Dennis
0 Kudos

CDS view entities in their current form can't replace CDS views. The problem is that database views resulting from view entities will forcibly filter by “client” field / session variable. It is a very common approach to use AMDP to access data in a cross-mandant way (for example when doing migrations). When building SQL queries that only use tables — this works nicely. When using CDS views — it works too. But when using CDS view entities, suddenly the database view only returns rows which belong to current client.

This is annoying and it is aligned with SAP long-established policy of making the live of developers miserable: 1) let's create a primitive SQL language, so that they can't really do much; 2) let's create a whole new set of features, that will allow better access to the data, but still not too flexible; 3) on top of that let's create ANOTHER way of accessing data, which will have direct access to the database; 4) but hey, let's mess with them an limit that in a complete unintuitive way.

Working with SAP products is like playing hide-and-seek with the vendor. Seriously, I believe in SAP there is a special team which is only dedicated to make things unnecessarily more complicated.

Labels in this area