cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a Text field to an ABAP CDS View via extension.

andrefernandes
Participant
0 Kudos

Hello experts,

There is a standard CDS view we would like to extend by adding a text field. We want to add a Material_Text field, which will contain the text of the existing field MaterialMaterial would then have the annotation sap:text='Material_Text' in the OData metadata. We already have a text view properly setup.

If we were creating the view from scratch, it would be simple. We would just need to use: 

 

{
   ...
   @ObjectModel.text.association: '_Text'
   matnr as Material,
   _Text
}

 

But since we are trying to extend an existing view via, the code below fails:

 

extend view C_ConsumerView with ZC_CONSUMER
  association [0..*] to I_MaterialText as _MaterialText on  $projection.Material3  = _MaterialText.Material

{
  @ObjectModel.text.association: '_MaterialText'
  Material,
  _MaterialText
}

 

as we get the "The name Material is not unique" error, as it tries to add a field that already exists. @ObjectModel.text.association or sap:text also not available via metadata extension

So what would be the correct way to approach this?

Best regards,
André

View Entire Topic
junwu
Active Contributor
0 Kudos

 

 

extend view C_ConsumerView with ZC_CONSUMER
  association [0..*] to I_MaterialText as _MaterialText on  $projection.Material3  = _MaterialText.Material

{
 
  _MaterialText
}

 

create another metadata extension view to extend the annotation.

andrefernandes
Participant
0 Kudos

Hello,

Thanks for the reply.

Unfortunately this doesn't work. Putting only the navigation on the definition causes the error "Selection list is empty"

junwu
Active Contributor
0 Kudos
how about add the text field there, _MaterialText.YOURTEXTFIELD
andrefernandes
Participant
0 Kudos

In the end, that's the approach we took.

According to SAP "Field redefinition in a CDS view extension isn't supported".

So we added the Text field via association and added v4 annotations to the key field on the consuming app to define their relation.