Symptom
You have developed a Custom CDS View of type External API based on the I_MatrixConsolidationReportC Standard CDS View, but when calling the API you're getting the error message: "Temporal query option 'at' expected but not supplied".
Environment
SAP S/4HANA Cloud
Cause
Your Custom CDS View has a parameter P_KeyDate which got copied from the primary data source I_MatrixConsolidationReportC. As this parameter got copied it has some ‘semantics’ that are currently not shown in the Custom CDS View. This ‘semantics’ results in an extension to the generated OData Service that requires the URL option ‘at’ to be filled when calling the service. Since you have not filled the option, the OData calls fails.
Resolution
I can see three options to solve the issue now:
1. You can fill the parameter when calling the service. E.g: myXXXXXX-api.s4hana.ondemand.com/sap/opu/odata/sap/YY1_XXX_CDS/YY1_XXX(P_KeyDate=datetime'2024-01-19T00:00:00')/Results?at=20240110
2. You can temporarily remove parameter P_KeyDate and immediately add it again with the same data. By doing so, you don’t copy the ‘semantics’ from the primary data source.
3. If you don’t really need a parameter on view level, you just need to fill the parameter of I_MatrixConsolidationReportC to select from that view. If you add a primary data source that has parameters, our default behaviour is that we copy those parameters to the Custom CDS View and define a 1:1 mapping from those parameters to the parameters of the primary data source. By doing so we make sure that initially a consistent view is defined. But if you nevertheless define a default value for the parameter and hide it, you can also remove it from the parameters tab and define the same mapping to the current date (Session Varaiable->System Date) on the primary data source parameter mapping popup (click on the parameters icon in the data source table). If you do the same for all parameters of the Custom CDS View you can get a much leaner view definition.
We are currently evaluation if a display of the copied semantics on parameter level is possible in future.
Keywords
Custom CDS View, External API, I_MatrixConsolidationReportC, Standard CDS View, API, Temporal query option 'at' expected but not supplied, parameter, URL, OData call, GET, POST , KBA , BC-SRV-APS-GKE , Generic CDS Key User Editor , Problem