2024 Jul 25 11:15 AM - edited 2024 Jul 25 11:17 AM
Hi Everyone,
I've one use case, where I have parameterised service in s4 and consuming that in SAP CAPM project to read data, but not able to successfully read data getting below error
Error: Invalid call to "Service.Entityset". You need to navigate to Set
[remote] - Error: Error during request to remote service: Request failed with status code 500
S4 Url format(in which getting data)
https://..../S4ServiceName/EntitySetName(param1='abc')/Set
Service.cds file
EntitySetName(param1 :api.EntitySetName:param1) as
projection on api.EntitySetName{
key Set.val1,
key Set.val2,
Set.val3,
....
};
Server.js
srv.on('READ', ['EntitySetName'], async req => {
const api = await cds.connect.to('S4_metadata');
try {
const params = req.query.SELECT.from.ref[0].args;
const projection = req.target.projection.from.ref[0].substr(req.target.projection.from.ref[0].lastIndexOf(".") + 1);
let modifiedFromClause = { ref: [{ id: projection, where: [] }, "Set"] };
for (let param in params) {
modifiedFromClause.ref[0].where.push({ ref: [param] }, "=", { val: params[param].val }, ",");
}
modifiedFromClause.ref[0].where.splice(-1);
req.query.SELECT.from = modifiedFromClause;
} catch (e) {
console.log(e.message);
throw new Error("PARAMETERIZED_REQUEST_PROCESSING_EXCEPTION");
}
return api.run(req.query);
});
Please provide the correct way to consume these kind of services.
Request clarification before answering.
| User | Count |
|---|---|
| 14 | |
| 8 | |
| 6 | |
| 6 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.