Search code examples
s4sdk

Can't query BAPI via OData on S/4Hana using Cloud SDK


I'm trying to follow https://blogs.sap.com/2017/09/15/step-11-with-sap-s4hana-cloud-sdk-virtual-data-model-for-bapi/ for calling a BAPI via OData on an S/4 Hana system on-prem.

I've successfully called other OData services that I enabled via /IWFND/MAINT_SERVICE.

However, when trying to execute the sample call

final ErpConfigContext erpConfigContext = ...
return new DefaultFinancialTransactionService().getList().execute(erpConfigContext).getListOfSelectedTransactions();

I'm getting:

17:34:20.998 [http-nio-8080-exec-4] ERROR 
Query execution failed with status code 404. Response body: <html><head><meta http-equiv="content-type" content="text/html; charset=windows-1252"><title>Service cannot be reached</title>...
...
    at com.sap.cloud.sdk.s4hana.connectivity.ErpEndpoint.handleHttpError(ErpEndpoint.java:600)
    at com.sap.cloud.sdk.s4hana.connectivity.ErpEndpoint.handleHttpStatus(ErpEndpoint.java:560)
    at com.sap.cloud.sdk.s4hana.connectivity.ErpEndpoint.sendPayload(ErpEndpoint.java:925)
    at com.sap.cloud.sdk.s4hana.connectivity.ErpEndpoint.executeQuery(ErpEndpoint.java:372)
    at com.sap.cloud.sdk.s4hana.connectivity.ErpEndpoint.executeQuery(ErpEndpoint.java:253)
    at com.sap.cloud.sdk.s4hana.connectivity.rfc.SoapRemoteFunctionQueryExecutor.execute(SoapRemoteFunctionQueryExecutor.java:121)
    at com.sap.cloud.sdk.s4hana.connectivity.rfc.SoapRemoteFunctionQueryExecutor.execute(SoapRemoteFunctionQueryExecutor.java:30)
    at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiQuery.execute(BapiQuery.java:91)
    at com.sap.cloud.sdk.s4hana.datamodel.bapi.functions.DefaultFinancialTransactionGetListFunction.execute(DefaultFinancialTransactionGetListFunction.java:469)

It's basically saying the service could not be found. Is there a specific service I have to enable to be able to call that service? I actually want to use other BAPI's, so ideally I'd like to enable a single service that gives me access to multiple RFC's. Note I'm not using Cloud Connector. I'm trying to connect directly to the ERP Endpoint.


Solution

  • For reference,

    The problem was that I was using an HTTP destination for a service that performs BAPI queries using RFC. What was needed was the configuration of an RFC destination as well.

    The answer to my follow-up question explains how that RFC destination can be set up, such that this service as well as other BapiQuerys work.