cancel
Showing results for 
Search instead for 
Did you mean: 

Call RAP Action from CAPM application based on NodeJs

nileshpuranik
Explorer
0 Kudos
591

Dear all,

I have a RAP application created in On-Premise S4 system. It contains a bound action called 'Simulation' without any parameters. The entity name is 'PostingHeader'.The RAP service is exposed as oData V4 service to the external applications.

In the NodeJS based CAPM, i am trying to call this action but not able to succeed.

1. The action is present in the metadata (.csn) file of the service in the CAPM application. However, it has parameter (name: _it ). Not sure why and how did it come there

image.png

2. I tried to call the same using various techniques but getting error everytime

  const externalService = await cds.connect.to('SIECUI_I_CIC');
const actionParams = {};
const actionData = {
CompanyCode: '3006',
FiscalYear: '2023',
AccountingDocument: '3000000000'
};
//ABAP Trace doesn't give anything
/* const response = await SIECUI_I_CIC.Simulation(actionData, 'xSIECxC_CIC_POSTHEADER');
console.log('response', response); */
//ABAP Trace gives something --
// const responde3 = await externalService.send({ event: action, entity: 'xSIECxC_CIC_POSTHEADER', data: actionData, params: { _it: req } });
await cds.tx(async (tx) => {
const actionResponse = await externalService.tx(tx).run(
externalService.Simulation(actionData)
);
console.log(actionResponse);
});
//ABAP Trace gives something -- Solution 3-1
/* const response = await SIECUI_I_CIC.Simulation({entity: 'xSIECxC_CIC_POSTHEADER'});
console.log('response', response); */
//ABAP Trace gives something -- Solution 4
/* SIECUI_I_CIC.send('READ', 'xSIECxC_CIC_POSTHEADER', async (request) => {
const result = await SIECUI_I_CIC.tx(request).run('Simulation');
console.log(result);
return result;
}); */
//ABAP Trace doesn't give anything -- No Solution
/* const response2 = SIECUI_I_CIC.send('Simulation', actionData);
console.log('response', response2); */
//ABAP Trace gives something -- Solution 5
/* const result = await SIECUI_I_CIC.tx({runHeader_ID: req}).run('Simulation');
console.log('result', result); */
//ABAP Trace doesn't give anything -- No Solution
/* await cds.tx(async (tx) => {
const response = await SIECUI_I_CIC.tx(tx).run(SIECUI_I_CIC.Simulation());
console.log(response);
}); */

Can some one help?

Br

Nilesh

gregorw
Active Contributor
0 Kudos

Please format the code better.

nileshpuranik
Explorer
0 Kudos

HI Gregor,

Have formatted the code. Would you have any pointers/advice here please ?

Regards,

Nilesh

gregorw
Active Contributor
0 Kudos

I hope you can further improve the code sample. It's hard to understand what is working or not. Also the image is not showing up.

Did you tried a trace in the ABAP System how the calls are received? And compare them with valid calls in the Gateway Client?

View Entire Topic
Dinu
Contributor

Refer to calling functions in CAP documentation.

You mention that the bound action 'Simulation' is without any parameters. But in the code, sometimes, there are parameters actionData in the call.

let postingHeader = { id: '....'} // assume id is the key for PostingHeader

await srv.send({ event: 'Simulation', entity: 'PostingHeader', data: actionData, params: postingHeader })