cancel
Showing results for 
Search instead for 
Did you mean: 

How to call action of ExternalService(S/4 HANA On-premise) in CAPM service.

BhavyasriM
Explorer
0 Kudos

Hello Experts,

We are trying to develop a wrapper kind of CAPM service for Sales Order Creation in CAPM. As we are basically trying to simplify the SO creation process, our service will be used in a much simpler version of 'Manage Sales Order Version 2' app. We are planning to develop it as a freestyle app as the requirements of our client are unique.

We are trying to call the same service used in the standard app, which is the below link

We are able to implement a Get service to retrieve SO details in our CAPM service but we are unable to figure out how to call the 'CreateWithSalesOrderType' action declared.

Please suggest if the approach of calling the service is recommended or any other approach we should be taking up.

Below is the original create call in the app 'Manage Sales Order Version 2'

Thanks,

Bhavyasri M

gregorw
Active Contributor

Instead of using on OData Service that is provided for a SAP Standard app you should use the released API_SALES_ORDER_SRV API which will be stable also cross releases. And before you start consuming such a service with CAP I suggest to try it with REST Client (Pre-Installed in BAS).

BhavyasriM
Explorer
0 Kudos

Hi gregor.wolf

Thanks for directing me to the correct usage. I have modified the service and both Get and Post calls are now using API_SALES_ORDER_SRV.

But one requirement we were struggling with is with the F4 value helps. In the standard Manage Sales Orders Version 2 app, the value help values are tailored. I mean for ex. for Sales Order Type, during create, we get only one value in the dropdown (Standard Order OR) based on the configs. But when I use the SalesOrderType entityset from the API, I'm getting the whole list of SO Types. I checked the c_managesalesorders service and it is working via Actions.

Could you please suggest what would be the best way to achieve this, other than building the logic on our own to determine, what is relevant for the user, based on customization.

Thanks you so much for your valuble suggestions..

Best Regards,

Bhavyasri M

gregorw
Active Contributor
0 Kudos

F4 helps is a weak point in the S/4HANA (Cloud) API area. But you say that you found a Value help in API_SALES_ORDER_SRV ? Can you provide a link I can't find it.

View Entire Topic
katan_patel
Participant
0 Kudos

Hi,

Have you looked at the documentation for calling actions and functions. In the section titled "Programmatic usage via generic APIs would look like this for Node.js:" are examples for both bound and unbound functions for OData V4.

Thanks,

Katan

BhavyasriM
Explorer
0 Kudos

Hi katan_patel,

Thanks for pointing me to the proper documentation. I have now modified my code to call the backend action via send method.

But still the call is unable to invoke the backend action of my S/4 HANA service.

Below is the service call

/sap/opu/odata4/sap/c_salesordermanage_srv/srvd/sap/c_salesordermanage_sd/0001/$batch?sap-client=400

SalesOrderManage/com.sap.gateway.srvd.c_salesordermanage_sd.v0001.CreateWithSalesOrderType/

This is the uri of the action getting triggered. In original service, the action is configured via the backend annotations.I've now tried below ways to invoke the action but none of them are working.

const sosrv = await cds.connect.to('c_salesordermanage_srv');

//not working const SalesOrderResponse = await sosrv.run('SalesOrderManage/com.sap.gateway.srvd.c_salesordermanage_sd.v0001.CreateWithSalesOrderType', [OrderData]); //{"sampleresp": "Test"};

////not working const SalesOrderResponse = await sosrv.CreateWithSalesOrderType('SalesOrderManage', OrderData);

//not working const SalesOrderResponse = await sosrv.send('SalesOrderManage/com.sap.gateway.srvd.c_salesordermanage_sd.v0001.CreateWithSalesOrderType', req.data.Order );

Also not sure if I need to declare the action in .cds file as we do for entities..

Please suggest if you can think of something I've wrongly configured or accessing it wrong.

Thanks,

Bhavyasri M