cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Application Programming Model - casting type in queries

former_member182048
Active Contributor
0 Kudos

In a .CDS query I can derive a property in a view like so

case
   PROPERTY_NAME when 'SPECIAL VALUE' then 'Information'
   else 'None'
end            as RowHighlight,

In the DB it gets mapped to the following type which is not an allowable type

View Column                  SQL Date Type
ROWHIGHLIGHT                 VARCHAR(11)
Error: Element "Service.RowHighlight" does not have a type: Elements of ODATA entities must have a type

In a query how would i cast RowHighlight to an allowable SQL Type say NVARCHAR(11) ?

Accepted Solutions (1)

Accepted Solutions (1)

adrian_vaughan
Explorer

Hi John,

You should be able to explicitly type your "case" element using a colon and the required type i.e. add ": String" after RowHighLight

case
   PROPERTY_NAME when 'SPECIAL VALUE' then 'Information'
   else 'None'
end            as RowHighlight : String,

Check out the Type Definiton section on the following page:

https://help.sap.com/viewer/b3d0daf2a98e49ada00bf31b7ca7a42e/2.0.03/en-US/b4080c0883c24d2dae38a60d7f...

Answers (0)