Skip to Content
Technical Articles

#CDSFioriElementMissAdventures – CDS extension not getting activated!

Background

Off late we have been trying to get a deep understanding of ABAP CDS and Fiori Elements, this blog talks about one such adventure. So we created a base CDS view and then the intention was create an extension for it. So what following my instinct copied the base view and changed it as per extension format. We were expecting it to get activated smoothly but nothing is straight forward sometimes silly mistakes makes you understand the things at deeper level, read on!

An extension does not get activated

So when we tried to activate the CDS extension we were getting the error “The DDL source can only be used to define a view”. I double checked the syntax all looked fine as shown below.

Base View

@AbapCatalog.sqlViewName: 'ZBASEVVIEW'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'original for extension'
define view zbaseview as select from spfli as c
inner join scarr as a 
on c.carrid = a.carrid {
    key c.carrid,
    key c.connid,
    c.cityfrom,
    c.cityto,
    a.carrname
}

Extension View

@AbapCatalog.sqlViewAppendName: 'ZBASEVVIEWEXT'
@EndUserText.label: 'Copy and then extension'
extend view zbaseview with Zbaseviewext  {
    c.fltype,
    c.distid
}

Activation Error

I thought rather than copying which we always do let’s try to see does it work when we manually create an extension. Surprisingly it worked as can be seen below.

Manual Extension

@AbapCatalog.sqlViewAppendName: 'ZBASEVVIEWEXTM'
@EndUserText.label: 'Manual Extension'
extend view zbaseview with Zbaseviewextm  {
    c.fltype,
    c.distid
}

 

So something is different in the backend, although the code for both the extension CDS is the same only difference being one is copied and other is manually extended. Next step was to drill more into understanding how it is working in the backend.

Finding the root cause

As a first step i tried to activate the CDS manually in SE80 to check if we can get more detail into the issue but sadly the same log shows.

Definitely the next step was to switch on the debugger and understand what is causing this issue. On debugging further we found out the place from where the error was coming as shown below.The base source type passed for copied is V and where it is expecting an E for extension. On comparing it with manual extension we found the base source type was passed as E which is in line with the expectation

The different constant values for reference for different type of views are shown below.

What is the learning?

Basically when you copy it copies the source type of the view and does not take into account the annotations used in the CDS. Irrespective of the annotation used it simply copies the base source type. I would have expected it to automatically adjust it considering the content of the CDS view being activated.

So learning is be careful when you copy things, things will not work the way you expect them to me like in this case. It actually helps in understanding the things in a better way if we dig more rather than just using the alternative which we have found by just creating the extension manually.

 

7 Comments
You must be Logged on to comment or reply to a post.
    • Scary i will say😀  I am wondering we have so many things going on and these small small exceptions or notes are always referred when mishappening has already occured😀 I feel somehow special notes should somehow gets highlighted while using or deleting them say what?

      Nabheet

       

      • I agree. When should have tips and notes popup whenever a new type of object is being created by a user.

        It is so much easier to implement with our Eclipse IDE I think.

        WE can build an extension for eclipse IDE that will create tips popups for a new user or whenever tips are updated.

  • Nice analysis Nabheet Madan, l did not know that a dump will register in the backend at the time of activation(incases of errors).

    Usually in SAP GUI these issues will never come, as they are pretty informative and restrictive as well. Like we cannot copy a table to a view in GUI right..

    But in eclipse, it hard to differentiate (for people like us who come from GUI background) especially these annotation, data definitions, access control etc.., which doesn’t have any extensions( if they have then we can at least change the extension after copying 😀 ).

    We just have to differentiate them based on the folders here. I think there is a restriction in eclipse where if you copy the data definition by using cntrl + c and cntrl + v to a metadata extension folder, it will give an error.  But I think you’ve directly changed the format by copying it in the same ddl definition folder.

     

    Best Regards,

    Mahesh

    • Thanks Mahesh agree an extension like it is in native HANA application for file will make perfect sense.  Yes i just did a right click on the existing view and copy that is where got into this trouble🤣

       

  • Unfortunately devil’s always in the details.

    The annotation checks loads in later after the DDL metadata has been set. Annotations are based on scopes like View, Table Function, Extensions, Entities and Parameters. The DDL source type controls the scope that is to be loaded which is set by the template in use in ADT.

    Based on the source type the DDL main source implementation will recognize EXTEND VIEW as a valid syntax to decode. The way it would work is to identify the variables after EXTEND VIEW syntax and then carry on to check if thats a valid CDS view ro extend.

    Regards,

    Sitakant