cancel
Showing results for 
Search instead for 
Did you mean: 

How to call public cloud SAP API from embedded steampunk?

0 Kudos
897

After days of reading documentation, blogs and tutorials... I'm still no step further in what I was expecting to be a pretty straight-forward scenario. I must be missing something obvious, but what?

On our S/4HANA Public Edition development system, I have created an application job to automatically create credit memos. Works like a charm, up until the moment that I actually need to create the credit memo. Of course we want to use the available public API to do so.

There is a default communication arrangement for this API (SAP_COM_0158), which has INBOUND services linked. Makes sense, since I want to call this service to create the credit memo in SAP. That sounds indeed like an inbound interface. It should not matter whether I call it from an actual external system (like BTP) or in this case from the embedded ABAP environment. As far as S/4 is concerned, it is inbound.

This tutorial seems to come closest to what I want to achieve:
Implement an Outbound Service Call in SAP BTP, ABAP environment for an OData Service via Service Con...

Several components are required to make this work. We have a communication scenario ZCS_CREDIT_MEMO, in which I point to outbound service ZOBS_CREDIT_MEMO_REST. Then there is the consumption model ZCM_CREDIT_MEMO, based on the EDMX file from the business hub. It provides me with example code.

To get the destination, static method CREATE_BY_COMM_ARRANGEMENT is being called. Following the tutorial, I enter the communication scenario and the outbound service. This results in an exception. Apparently not the values SAP is expecting. I've tried several combinations of objects, so far nothing works.

DATA(lo_destination) = cl_http_destination_provider=>create_by_comm_arrangement(
                                             comm_scenario  = 'ZCS_CREDIT_MEMO'
                                             service_id     = 'ZOBS_CREDIT_MEMO_REST' ).

In the debugger I can see the query to retrieve the communication arrangements uses table aps_ca_d_root as a basis. Unfortunately, this being public cloud, I cannot view the contents of that table to see what is actually there. That would be helpful in finding what I should provide the method.

In case I enter the communication arrangement as 'comm_scenario', the system does find the communication arrangement itself, but then filters on available outbound services. Which it does not have, since it's meant for inbound. Once again, no result, which results in the exception.

This has to be incredibly basic. What step am I missing here? Thanks in advance for the help!

View Entire Topic
0 Kudos

Small update from my side, in case anyone else stumbles onto the topic... it can be done.

Although the documentation of the credit memo request states that it can be extended with custom fields, those fields do not work everywhere. There still are areas in which you will not find them. Unfortunately for us, the EML TP object is one of those. Reached out to SAP, they've investigated and replied that it's currently not supported and we can use the customer influence program to raise the issue. Which we will do, but that does not help us at this time.

The way I was able to make the public API work from an on-stack piece of programming is to have two communication arrangements pointing to the same communication system (the S/4 HANA Cloud Public Edition system), using the same communication user. I guess that previously when trying to find the correct interface, a connection through the same system could not be found.

I was so close, just a connection away. At last now I know what it was. I reckon once we get used to the way of working, it'll all become easier. And perhaps even make sense 😉

nileshpuranik
Explorer
0 Kudos

Hello,

Many thanks for this question and the discussion over it. It was helpful.

Br

Nilesh