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
SachinArtani
Participant
0 Kudos

In my case, I just created a reference field out of Material like this - 

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

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

and showed this field instead of existing material field by creating a CUSTOMER layered metadata extension on top of existing CORE layered metadata extension.
This way the transactions will not be impacted as data is eventually be saved to the original material field and if it's a display report, we are already set.

andrefernandes
Participant
0 Kudos

Hello!

Thanks for the reply. I had tried this option too, but when I queried the entity, I got a SHORTDUMP:
The parser produced the error: The field "MATERIALNAME" does not have a corresponding field in the work area.

But good to know this could be an option. I will investigate further what went wrong.