Custom CDS view with Mandatory Parameters as an OData Service in S4HANA Cloud


In S4HANA Cloud, you want to expose your custom CDS View as an OData Service but because there are mandatory parameters linked to it, it’s throwing up an error while forming your web service query. If this sounds familiar, this small little blog is going to help you find the way.

There are some powerful CDS Views that has mandatory Parameters associated to it and few to name in the S4HANA Cloud Space are:

I_ARJrnlEntrItmAgingGrid, I_OverdueAccountsReceivables, I_ARJrnlEntrItmAgingGrid etc.

Often times when calling such OData Entity Sets with Mandatory Paramters results in an EntitySets error.


So let’s start by assuming you’ve already created a custom CDS view using one of the referenced data source mentioned above. In my example, I will consume I_ARJrnlEntrItmAgingGrid for demonstration purpose and have created Custom Scenario to form the Webservice.

Here is my web service url to form the OData Query:

The first step is to identify the metadata and here is how you form your query:$metadata?saml2=disabled

Analyzing the log further, you’ll look for the EntityType Name under the Semantics “Parameters”

Furthermore, look for <NavigationProperty Name=”Results” under the same parameters Entity Type as depicted in the screenshot below.

Whatever that is listed under NavigationProperty Name will be part of the final Query. In this case it’s the “Results”


Analyze Logs

With this information you’ll be able to form your final query in the below format.’2022-04-18T00:00:00′,P_NetDueInterval1InDays=30,P_NetDueInterval2InDays=60,P_NetDueInterval3InDays=90,P_DisplayCurrency=’USD’,P_ExchangeRateType=’M’)/Results?$top=10

It has to be noted that the ‘P_KeyDate’ parameter has to be Unix timestamp in seconds.


Please note that, currently with 2202 release, we have limitation where SAP has not enabled the support for navigation entities in resource path yet. This would mean that webservices with mandatory parameters will have its limitation while exposing it into middleware or while consuming in SAP Cloud SDK.However,  I hope this gives you some direction on how you can test an OData service in a browser or in an API testing tool using Mandatory Parameters.

Thank you!

Amith Nair