cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CAP with OData V4 adds $count param to URI that is not supported

merveguel
Participant

Hello all,

I am developing a CAP supported Fiori Elements application with OData V4. Currently I am struggling with getting the onpremise OData Service data into a valuehelp in frontend. The issue is whenever the batch call is triggered it adds a "$count" parameter into the call URI which is not supported by the backend (error can be seen in /IWNFD/ERROR_LOG).

Since Fiori Elements template is used, this call takes place automatically over a CAP Service that wraps the backend OData Service call. It has a very basic service js as can be seen below. Even converting the frontend model into OData V2 didn't help since "inlinecount" param was also not supported in backend.

const cds = require("@sap/cds");
module.exports = async function () { 
const inspectionLotService = await cds.connect.to("INSPECTION_LOT_SRV");
this.on("READ", "Plant_VHSet", async function (request) 
{ 
return await inspectionLotService.tx(request).run(request.query); 
});
}; 

Batch URI in OData V4 Call:

GET Plant_VHSet $select=City1,Name1,Name2,Nation,PostCode1,Werks&$count=true&$orderby=Werks&$skip=0&$top=58<br>

Batch URI in OData V2 Call:

GET Plant_VHSet?$inlinecount=allpages&$orderby=Werks&$select=City1,Name1,Name2,Nation,PostCode1,Werks&$skip=0&$top=58 

Both URI calls ends with error in backend. A workaround would be deleting the count parameter from the query before sending it to backend. But I would like to find a more official solution, removing the count off of from the query via a configuration etc.

I appreciate for any comment and help,

Thanks in advance,

Best,

Merve

gregorw
Active Contributor
0 Kudos

What exact error do you get in the backend?

merveguel
Participant
0 Kudos

Hi Gregor,

Thank you for your reply. Following is the error message I get in Error log in the backend "Exception /IWCOR/CX_DS_URI_SYNTAX_ERROR occurred" and this is the call that causes this error "/sap/opu/odata/sap/ZQM_INSPECTION_LOT_SRV/Plant_VHSet?$select=City1,Name1,Name2,Nation,PostCode1,Werks&$orderby=Werks%20asc&$count=true&$top=58"

Kindly inform if more information would be needed.

Best,

Merve

gregorw
Active Contributor
0 Kudos

Can you please run

cds --version

and provide the output so we know what exact CAP Version you're using?

merveguel
Participant
0 Kudos

Hi Gregor,

Please find the cds version check result as follows:

@sap/approuter: 11.6.1

@sap/cds: 6.8.4

@sap/cds-common-content: 1.1.0

@sap/cds-compiler: 3.9.4

@sap/cds-dk: 6.8.0

@sap/cds-foss: 4.0.1

@sap/cds-mtx: -- missing --

@sap/cds-mtxs: 1.8.4

@sap/cds-odata-v2-adapter-proxy: 1.9.21

@sap/eslint-plugin-cds: 2.6.3

@sap/xsenv: 3.4.0

@sap/xssec: 3.2.17

Node.js: v16.19.0

gregorw
Active Contributor
0 Kudos

How is your service INSPECTION_LOT_SRV defined in package.json?

merveguel
Participant
0 Kudos

Hi Gregor,

Please find the definition of the service as follows:

      "INSPECTION_LOT_SRV": {
        "kind": "odata",
        "model": "srv/external/INSPECTION_LOT_SRV",
        "credentials": {
          "destination": "EU-IL"
        }
      },
0076436
Discoverer
0 Kudos

@gregorw , I have followed the same steps as you mentioned , however Iam facing same issue while i try read data from S/4 via Odata , I could see values are returning however the values are not appearing in UI.

Any Suggestions.

gregorw
Active Contributor
0 Kudos

Hello 0076436 ,

have you already followed https://cap.cloud.sap/docs/guides/using-services?

0076436
Discoverer
0 Kudos

@gregorw , I have followed the same steps as you mentioned , however Iam facing same issue while i try read data from S/4 via Odata , I could see values are returning however the values are not appearing in UI.

Any Suggestions.

gregorw
Active Contributor
0 Kudos

Can you share a sample project where this issue can be repeated?

0076436
Discoverer
0 Kudos

gregorw yes ,

gregorw
Active Contributor
0 Kudos

Then share the link.

0076436
Discoverer
0 Kudos

I am wondering how I can reproduce same issue via a sample project .Please do let me know if you need any other details in my ongoing project to digout further .

gregorw
Active Contributor
0 Kudos

You share a freshly created CAP project that consumes a public OData Service from S/4HANA Cloud provided by https://api.sap.com/products/SAPS4HANACloud/overview on GitHub.

View Entire Topic
merveguel
Participant
0 Kudos

Thank you for your replies gregorw marcel.waechter

This issue is now solved with setting kind property to "odata-v2" and returning "inlinecount" value from backend OData service implementation.

Special thanks to gregorw for his contributions and kind help during my research on this issue.

Thanks once again,

Best,

Merve Gül