cancel
Showing results for 
Search instead for 
Did you mean: 

RAP - static read only field problem?

jh_sim
Explorer
0 Kudos

hi, im trying to develope custom RAP Application with odata V4.

i have root view and 2 composition view.

but when i syntax check on my serveice page, it shows error message like

i using waers field in root view and either composition views too.

what should i know to solve this?

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Can you please provide more details? E.g. code snippets of your cds views and behavior definition?
Which ABAP platform release are you using (SAP BTP ABAP Environment, SAP S/4HANA 2022, 2021, ...)?

jh_sim
Explorer
0 Kudos

hello ander Fischer

im using sap s/4hana 2022

and here is my code

<CDS VIEW>

@EndUserText.label: 'CDS view for HEADER'

@AccessControl.authorizationCheck: #NOT_REQUIRED

define root view entity Z_R_HEADER

as select from ZTHEADER as _HD

composition [1..*] of Z_R_IT as _it

composition [1..1] of Z_R_ST as _st

composition [0..1] of Z_R_MLC as _mlc

association [0..1] to I_Supplier as _supplier_info on (

$projection.Lifnr = _supplier_info.Supplier

or $projection.Zfbeni = _supplier_info.Supplier

or $projection.Llief = _supplier_info.Supplier

)

association [0..1] to ekko as _ko on $projection.Ebeln = _ko.ebeln

key header_no as HD_NO,

ebeln as Ebeln,

.....


waers as Waers,

cast( kursf as abap.dec(9,5) ) as Kursf,

lastchangedat,

locallastlangedat,

//Public annotation

_it,

_st,

_mlc,

_ko,

_supplier_info,

}


<PROJECTTION VIEW>

@EndUserText.label: 'projection view for HEADER(default)'

@AccessControl.authorizationCheck: #NOT_REQUIRED

@Metadata.allowExtensions: true

define root view entity z_c_header

provider contract transactional_query

as projection on z_r_header

key HD_NO,

Ebeln,

@Semantics.amount.currencyCode: 'waers'

zftam,

@Semantics.amount.currencyCode: 'waers'

zfpam,

@Semantics.amount.currencyCode: 'waers'

zfram,

Waers,

/* Associations */

_hd : redirected to composition child z_c_header,

_it : redirected to composition child z_c_item,

_st : redirected to composition child z_c_mlc,

_ko,

_supplier_info

}



<BEHAVIOR DEF>

unmanaged implementation in class zbp_r_request unique;

with draft;

define behavior for Z_R_HEADER //alias <alias_name>

draft table zdr_hd

lock master total etag lastchangedat

etag master locallastlangedat

authorization master ( instance )

{

create;

update;

delete;

association _mlc { create; with draft; }

association _it { create; with draft; }

association _st { create; with draft; }

}

define behavior for z_r_mlc //alias <alias_name>

draft table zdr_mlc

lock dependent by _hd

authorization dependent by _hd

//etag master <field_name>

{

update;

delete;

field ( readonly ) HD_NO;

association _hd { with draft; }

}

define behavior for Z_R_IT //alias <alias_name>

draft table zdr_it

lock dependent by _hd

authorization dependent by _hd

//etag master <field_name>

{

update;

delete;

field ( readonly ) HD_NO;

association _hd { with draft; }

}

define behavior for Z_R_ST //alias <alias_name>

draft table zdr_st

lock dependent by _hd

authorization dependent by _hd

//etag master <field_name>

{

update;

delete;

field ( readonly ) HD_NO;

association _hd { with draft; }

}


<PROJECTION BEHAVIOR>

projection;

use draft;

define behavior for z_c_hd //alias <alias_name>

{

use update;

use delete;

use association _mlc { create; with draft; }

use association _it { create; with draft; }

}

define behavior for z_c_mlc //alias <alias_name>

{

use update;

use delete;

use association _hd{ with draft; }

}

define behavior for z_c_it //alias <alias_name>

{

use update;

use delete;

use association _hd{ with draft; }

}

define behavior for z_c_st //alias <alias_name>

{

use update;

use delete;

use association _hd{ with draft; }

}

///////////////////////////////////////////////////////


_it, _st has also waers from _hd too .


thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

vykuntrao
Participant
0 Kudos

I also faced similar issue. Initially created behavior definition projection without field which was highlighted in the error message which includes wears or currency code. Now I created service definition and service binding respectively.

At this point you will not get this error.

Now again I updated behavior definition projection by adding the wears or currency code field to read only section. Am not seeing that error and when I execute the app the field becomes read only.

JessieCheah
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello. This error normally comes when you have annotated an amount field with semantic currency code, but the currency code is declared as read-only in BDEF. Can you check if this is your case?

The annotation to check is @Semantics.amount.currencyCode: 'CurrencyCodeField' and then in the BDEF

field (readonly) CurrencyCodeField;

Updated: I've just seen your comments with Andre, should have updated the post before I answered. So far I don't see any read only defined in your BDEF, so it's a bit strange

jh_sim
Explorer
0 Kudos

Hello JES SIE CHEAH!

im using semantic annotation of currency code for 'WAERS' as you said

->

@Semantics.amount.currencyCode: 'waers'

zfram,

Waers...

but i dont write any of 'readonly' waers in my bdef

thanks.