cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP RAP functions - how to default values to a drop-down in an abstract entity cds

0 Likes
2,227

I have an action button in behaviour definition I have defined the below

This below example doesn't have any Ui5 coding

storePut is function import

action ( features: instance) storePut parameter D_StorePutAbsEn result [1] $self

D_StorePutAbsEn is an abstract entity cds which opens the dialog having all fields like

Key F1

F2

I want to default a value to a drop-down for field F1.

Is there any annotation in cds or annotation in xml by which a value can be default to a drop-down inside the dialog.??

Any example how to achieve it .?

Accepted Solutions (0)

Answers (1)

Answers (1)

Ramjee_korada
Active Contributor

Hi Abhishek,

See below documentation .

Prefilling Fields Using the DefaultValuesFunction

<FunctionImport Name="GetDefaultsForSetText" ReturnType="cds_zrc_dv_defaultvalues.ZRC_DV_A_SetText" m:HttpMethod="GET" sap:action-for="cds_zrc_dv_defaultvalues.RootType">
<Parameter Name="UUID" Type="Edm.Guid" Mode="In"/>
</FunctionImport>
 
<Annotations xmlns=http://docs.oasis-open.org/odata/ns/edm Target="cds_zrc_dv_defaultvalues.cds_zrc_dv_defaultvalues_Entities/SetText">
<Annotation Term="com.sap.vocabularies.Common.v1.SideEffects" Qualifier="Action">
<Record>
<PropertyValue Property="TargetProperties">
<Collection>
<PropertyPath>Text</PropertyPath>
</Collection>
</PropertyValue>
</Record>
</Annotation>
<Annotation Term="com.sap.vocabularies.Common.v1.DefaultValuesFunction" String="GetDefaultsForSetText"/>
</Annotations>

Best wishes,

Ramjee

0 Likes

Hi Ramjee,

I can then use this annotation in my XML .

I already having the function import name..

I had one doubt suppose I am just using this annotation <Annotation Term="com.sap.vocabularies.Common.v1.DefaultValuesFunction" String="GetDefaultsForSetText"/>

</Annotations>

This method implementation logic needs to be added in backend to default values.

Or in annotation.xml do we have to provide the fields and default values.

"GetDefaultsForSetText" here this being the function import name. The default method has to be created in rap .??

saurabh__khare38
Participant
0 Likes
Hi, were you able to achieve this?