Symptom
When trying to call an OData Service which exposed by a CDS view with parameters, the following error occurs:
<code>LCX_MISSING_PARAMETER</code>
<message>The caller violated a precondition for a method call</message>
<propertyref/>
<severity>error</severity>
<target/>
</errordetail>
<errordetail>
<code>/IWBEP/CX_MGW_MED_EXCEPTION</code>
<message>An exception was raised</message>
or the following error might occur
<code>CX_SADL_CONTRACT_VIOLATION</code>
<message>The entity '*YY1_xxxxxxx' was not found</message>
<propertyref/>
<severity>error</severity>
<target/>
</errordetail>
<errordetail>
<code>/IWBEP/CX_MGW_MED_EXCEPTION</code>
<message>An exception was raised</message>
Environment
SAP S/4HANA Cloud
Reproducing the Issue
- Using your S/4HANA Cloud account, login to your Fiori Launchpad
Expose a custom CDS view based on the standard view provided by SAP that has few parameters.
Note: If the parameters are hidden, make them unhidden and republish your CDS view
- Create an OData communication arrangement scenario using the application Maintain Communication Arrangements
- Call your OData Service using for example POSTMAN as follow https://<URL>/sap/opu/odata/sap/YY1_<ODATA-SERVICE>
- User gets list of EntitySets
- Call any of the EntitySets error occurs
Cause
Calling an OData EntitySets with parameter like that, <URL>\YY1_<ODATA-SERVICE>\EntitySets is not correct. Refer to the resolution section
Resolution
To call the correct Entitysets with parameter, do the following:
- Get the metadata first, <URL>\YY1_<ODATA-SERVICE>\$metadata
- In the metadata locate your EntitySets and check its Entity type, it will be something like this:
<EntitySet Name="YY1_<NAME>" EntityType="YY1_<ODATASERVICE>.YY1_<NAME>Parameters" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:pageable="false" sap:content-version="1"/> - Then locate the the <EntityType Name="YY1_<NAME>Parameters" as shown below
<EntityType Name="YY1_<NAME>Parameters" sap:semantics="parameters" sap:content-version="1">
<Key>
<PropertyRef Name="P_1"/>
<PropertyRef Name="P_2"/>
</Key> - Under the Parameters EntityType find the following:
<NavigationProperty Name="<RESULTSNAME>" .../>
</EntityType> - Now the user can form the URL as follow https://<URL>/sap/opu/odata/sap/YY1_<ODATA-SERVICE>/YY1_<NAME>(P_1='<WHATEVER-VALUE>',P_2='<WHATEVER-VALUE>')/<RESULTNAME>
- <RESULTNAME>: Whatever the name is from step 4
- YY1_<NAME> is the EntitySet Name from step 2
- P_1, P_2: Name of parameters from step 3, If the parameters list has X numbers of parameters, they need to be listed
- Note: If the result is very large, we can add $top=1 for testing purposes like that:
https://<URL>/sap/opu/odata/sap/YY1_<ODATA-SERVICE>/YY1_<NAME>(P_1='<WHATEVER-VALUE>',P_2='<WHATEVER-VALUE>')/<RESULTNAME>?$top=1
Keywords
LCX_MISSING_PARAMETER CDS OData, OData with Parameter S/4HANA, CX_SADL_CONTRACT_VIOLATION, sy530, Entity, Parameter entity set, cannot be used for read, /IWFND/CM_MGW004, custom CDS view, API. , KBA , lcx_parameter_derivation_fail , lcx_missing_parameter , BC-SRV-APS-GKE , Generic CDS Key User Editor , Problem