cancel
Showing results for 
Search instead for 
Did you mean: 

RAP error "Use of annotation OBJECTMODEL.ASSOCIATION.TYPE is not allowed"

MioYasutake
Active Contributor
0 Kudos

Hi community,

I am creating a RAP BO with an association. What I want to achieve is to show text (CertificateName) for the Certificate ID. Our development environment is S/4HANA 2022 SPS00.

The base view:

The projection view:

However, the service binding throws the following error.

"Use of annotation OBJECTMODEL.ASSOCIATION.TYPE is not allowed for element CERTIFICATENAME".

As I am not using such annotation in my CDS views, I have no idea why the error is occurring.

2023/05/29 Updated the CDS views based on the suggestions below, but the error still persists.

1. The text view "ZZ1_CERTIFICATE" has @Semantics.text: true on Description field.

define view ZZ1_CERTIFICATE
  as select from ZZ1_C95AEE38E19C
  association [0..1] to ZZ1_TV_CERTIFICATE
    as _TextSys
    on _TextSys.Code = $projection.Code and
       _TextSys.Language = $session.system_language
  association [0..1] to ZZ1_TV_CERTIFICATE
    as _TextOrig
    on _TextOrig.Code = $projection.Code and
       _TextOrig.Language = 'E'
{
  @Search.DefaultSearchElement: true
  @ObjectModel.text.element:['Description']
  @EndUserText.label: 'Code'
  @EndUserText.quickInfo: 'Code'
  key CODE as Code,
  @ObjectModel.association.type: [#TO_COMPOSITION_CHILD]
  @Semantics.text: true
  @EndUserText.label: 'Description'
  @EndUserText.quickInfo: 'Description'
  coalesce( _TextSys.Description, _TextOrig.Description ) as Description
}
where IsDisabled = ' '
2. The base view exposes the association to the text view, but not the fields from the association.
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: '認定資格'
define view entity Z_I_Certificate_2 as select from zcertificate_2
association to parent Z_I_EMPLOYEE_G as _Employee
    on $projection.Employee = _Employee.UUID
  association [0..1] to ZZ1_CERTIFICATE as _CertificateText
  on $projection.CertificateId = _CertificateText.Code    
{
    key uuid as Uuid,
    employee as Employee,
    certificate_id as CertificateId,
    acquired_at as AcquiredAt,
    description as Description,
    is_certified as IsCertified,
    @Semantics.systemDateTime.localInstanceLastChangedAt: true
    local_last_changed_at as LocalLastChangedAt,
    _Employee, // Make association public
    _CertificateText
}
3. The projection view adds description (as CertificateName) from the association. The field CertificateId is annotated with @ObjectModel.text.element.
@EndUserText.label: '認定資格'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.allowExtensions: true
@ObjectModel.semanticKey: ['CertificateId']
define view entity Z_C_Certificate_2
  as projection on Z_I_Certificate_2
{
      @UI.hidden: true
  key Uuid,
      @UI.hidden: true
      Employee,

      @Consumption.valueHelpDefinition: [{
        entity: { name: 'ZZ1_CERTIFICATE', element: 'Code'}
       }]
      @ObjectModel.text.element: ['CertificateName']
      @EndUserText.label: '認定資格'
      CertificateId,
      @EndUserText.label: '資格名'
      _CertificateText.Description as CertificateName,
      @EndUserText.label: '取得日'
      AcquiredAt,
      @EndUserText.label: '説明'
      Description,
      @EndUserText.label: '認定済'
      IsCertified,
      LocalLastChangedAt,
      /* Associations */
      _Employee : redirected to parent Z_C_EMPLOYEE_G,
      _CertificateText
}

The activation error of the service binding occurs at the 3rd step, where I add a field from the association.

Regards,

Mio

shavneet1
Participant
0 Kudos

Hi ,

I am getting the exact same error , while trying to create the service binding. I am in S/4hana on premise 2021 release , and trying to consume the standard SAP CDS view . which has this annotaion in some fields which i am using in my Z cds view.

andre.fischer : Would you please help here.

REgards ,

Shavneet Singh

View Entire Topic
BhargavaReddy
Active Participant

Seems, the error is related to @ObjectModel.text.element

Remove the annotation in the projection entity and add it to the base view entity.

Also, add the below annotation for the text field.
@Semantics.text: true

MioYasutake
Active Contributor
0 Kudos

Hi 3d76ad13a3144842a119a30f61020327,

Thanks for your quick response. I have moved the annotation @ObjectModel.text.element to the base view entity, but the error still perists. Regardless of the annotation, adding the association to the base view is leading to the error.

The base view:

The projection view:

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

You forgot to annotate the field with @Semantics.text: true as recommended by 3d76ad13a3144842a119a30f61020327 and by me.