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

Set Nullable Property on SAP RAP based OData V4

5,085

Hello Community,

I created an OData V4 Service to read data with RAP (CDS Views) based on a SAP Standard Table BNKA.

In the metadata any string are stated as Nullable="false".

For non key fields I would expect that fields can be null.

Can this be influenced via cds?


With Odata V2 the nullable property is optional and thus not mentioned when publishing the same service.

However i did not find the default value for the field if it is not declared.

What is the default value for nullable if not provided in OData V2?

Accepted Solutions (0)

Answers (6)

Answers (6)

evanireland
Product and Topic Expert
Product and Topic Expert

Perhaps you will need to create an incident for the RAP tools. I don't work in that area so I don't know of another option.

0 Kudos

Hello Tudor,

I found this attribute in the cds annotation syntax ABAP CDS - Framework-Specific Annotation Syntax - ABAP Keyword Documentation (sap.com)
But as per my understanding it is only available in S/4 Cloud.

As I have an OnPrem System available i get an error when trying it.

0 Kudos

Hello Tudor,

Thank you very much sharing this. I will try this out.

tudor_teoteoi
Explorer
0 Kudos

(This is a solution obtained via support message to SAP.)

You must declare a separate field that references the original one via a dedicated annotation:

@Semantics.nullValueIndicatorFor: 'OriginalField'
cast ('X' as boole_d) as NullValIndicator

As per my tests in S4H Cloud 2023, once you this:

1) OriginalField will no longer have "Nullable"="false" in the metadata of a generated V4 service;
2) The NullValIndicator will NOT appear in the service metadata.

Kinsbrunner
Active Contributor
0 Kudos

Hi Philipp,

Have you found an answer for this? I am also curious how to turn properties into Nullable so I can avoid sending them on the body payload.

Cheers.

Alejandro.

evanireland
Product and Topic Expert
Product and Topic Expert
0 Kudos

The default for the CSDL XML Nullable facet is true for both OData V2 and V4.

http://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/cs01/odata-csdl-xml-v4.01-cs01.html#_Toc505863...

As to whether that indicates a problem with the generation of either the V2 and V4 models you are working with, I can't comment as I don't know the origin of those XML files. If these are both machine-generated from the same input, then one of them is wrong since they aren't consistent.

0 Kudos

Thank you for the answer. Yes, it should be consistent.

I created the OData v2 and OData v4 based on the same Service Definition resulting in the above seen metadata.

What leads to the inconsistency?