Skip to Content

Could not generate BO from CDS View with Annotations

Hi experts,

i tried to generate a BO from CDS View with Annotations. The entities i tried to model are Monster and Monster Items. So in particular i have done the steps in this blog to accomplish the task:

  • Create two database tables to hold BO data
  • Create two CDS views
  • Add @ObjectModel Annotations to both CDS Views
  • Save and Activate both CDS Views

As i think how these @ObjectModel Annotations should work, the BOPF runtime should have generated the BO with a ROOT Node and an ITEM Node. But unfortunately nothing was generated.

I dont know why the BO is not generated at activation of the CDS views as all needed Annotations are set for this task. We are working on a SAP System with following patch levels:

Could these Annotations for creating BO from CDS View maybe are not recognized by our System due to patch level?

Here is the source code of the two CDS views:

CDS View Znl_Monster

@AbapCatalog.sqlViewName: 'ZDDL_NL_I_MNSTR'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'ZNL_MONSTER'

@Search.searchable: true
@Search.ranking: 'HIGH'

@ObjectModel.semanticKey: 'MonsterId'
@ObjectModel.representativeKey: 'MonsterId'
@ObjectModel.modelCategory: #BUSINESS_OBJECT
@ObjectModel.compositionRoot: true
@ObjectModel.transactionalProcessingEnabled: true
@ObjectModel.writeActivePersistence: 'ZNL_D_ROOT'
@ObjectModel.createEnabled: true
@ObjectModel.deleteEnabled: true
@ObjectModel.updateEnabled: true

define view Znl_Monster 
    as select from znl_d_root as Monster
    // Association to Item
    association [0..*] to Znl_Monsteritem as _MonsterItem on Monster.monsterid = _MonsterItem.MonsterId {
    
    // Monster
    @Search.defaultSearchElement: true
    @ObjectModel.readOnly: true
    key Monster.monsterid as MonsterId,

    // Name
    Monster.name as Name,

    // Make association public
    @ObjectModel.association.type:  [#TO_COMPOSITION_CHILD]
    _MonsterItem // Make association public
}

CDS View Znl_Monsteritem

@AbapCatalog.sqlViewName: 'ZDDL_NL_I_MNSTRI'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'ZNL_MONSTERITEM'

@Search.searchable: true
@ObjectModel.semanticKey:  [ 'MonsterId', 'MonsterItemId' ]
@ObjectModel.representativeKey: 'MonsterItemId'
@ObjectModel.writeActivePersistence: 'ZNL_D_ITEM'
@ObjectModel.createEnabled: true
@ObjectModel.deleteEnabled: true
@ObjectModel.updateEnabled: true

define view Znl_Monsteritem
    as select from znl_d_item as Item
    
    // Association to Header
    association [*] to Znl_Monster as _Monster on Item.monsterid = _Monster.MonsterId {
    
    // Monster
    @Search.defaultSearchElement: true
    @ObjectModel.readOnly: true
    key Item.monsterid                  as MonsterId,
    
    // Monster Item
    @Search.defaultSearchElement: true
    key Item.itemid                     as MonsterItemId,
    
    // Name
    Item.name                           as Name,
    
    // Measure fields
    Item.price                          as Price,
    Item.quantity                       as Quantity,
    Item.power                          as Power,
    
    // Make association public
    @ObjectModel.association.type:  [#TO_COMPOSITION_PARENT,#TO_COMPOSITION_ROOT]
    _Monster 

}
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Sep 10, 2017 at 11:37 PM

    Hi Nils Lutz,

    Did you find a sollution for your problem, I'm faciong the same.

    Do you know if the annotation @ObjectModel.transactionalProcessingEnabledalso does NOT work in the SAP NetWeaver 750 ?

    I saw in the Eclipse that the font color of this annotation is different from anothers, and the BOF is not created in the SAP NetWeaver.

    first-screen.png

    second-screen.png

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 24, 2017 at 01:07 PM

    Hi Nils / Marcio,

    Were you guys able to create child nodes in BOPF from CDS annotations? Any suggestions for child node creation? Or have you raised the ticket to SAP for further assistance?

    Since, I followed few posts and created exactly as advised with the required annotations. I was able to create only Root node in BOPF, but child nodes are not getting created. Could you please let me know what could be the issue of child node creation? since I don't have any authorization issue nor the error.

    Thanks,

    Santosh Kumar J

    Add comment
    10|10000 characters needed characters exceeded

  • May 03 at 03:14 PM

    Hi,

    I was facing a similar issues where the child node was not getting generated. So I started played around with variations and then realized that in my child view I had specified the following:

    semanticKey: [ 'SalesOrder', 'SalesOrderItem' ],

    On reading the documentation about this annotation it specified that "For a given entity, only a single semantic key is defined."

    So I changed it to as follows:

    semanticKey: [ 'SalesOrderItem' ],

    Then deleted my BOPF object and regenerated. This solved the issue.

    Give it a try as I am not sure why this behavior was exhibited.

    Cheers,

    Vikas

    Add comment
    10|10000 characters needed characters exceeded