0

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.

Cassio Pereira
  • 439
  • 1
  • 5
  • 15

2 Answers2

0

Can you pls clarify what you wanna achieve exactly: Calling a BAPI or an OData service? From your code I can see that you want to call a BAPI for obtaining financial transactions. On the other hand, you mentioned also OData. So pls clarify on that.

Secondly, as you mentioned that you do not use the SAP Cloud Connector. Do you execute the given code locally?

Also pls share the destination configuration with us.

Emdee
  • 1,689
  • 5
  • 22
  • 35
  • I want to call a BAPI via VDM/BapiQuery with Cloud SDK in Java, as the code shows. I'm executing the code locally with `neo-java-web-sdk-3.54.23`. The destination is configured as follows: https://gist.github.com/cmmp/0d9c61d13eab3419ac300a4026d2037c – Cassio Pereira May 24 '18 at 12:24
  • As you're invoking BAPIs inside SAP S/4HANA residing on-premise, you have to use destinations of type RFC. The linked destination config specifies an HTTP destination instead. – Emdee May 24 '18 at 12:46
  • Is there any configuration I have to do besides changing the type from HTTP to RFC? – Cassio Pereira May 24 '18 at 12:55
  • 1
    Check out this documentation about RFC destinations: https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/e184daba118b46679c6968567bacc98e.html – Emdee May 24 '18 at 14:42
  • From what I'm reading in the documentation, to access an RFC destination it must be first set up via Cloud Connector. Is that correct? I'm confused because for the OData services (which use HTTP) Cloud Connector was not needed. – Cassio Pereira May 24 '18 at 18:40
  • 2
    The question if you must set it up in the Cloud Connector depends on your use case and on your intention. If you want to connect to SAP S/4HANA from your local machine for testing purposes, then you do not need the SAP Cloud Connector. This assumes of course that the SAP S/4HANA system is accessible network-wise. However, if you want to connect to SAP S/4HANA from a deployed cloud application and SAP S/4HANA is on-premise, you do need the SAP Cloud Connector to establish the VPN tunnel between the cloud and the on-premise network – Emdee May 25 '18 at 06:32
  • I think I may be having an issue with the format of the endpoint configuration. I'm setting it via a destinations environment variable, as follows: "[{name: "RFCQueryEndpoint", type: "RFC", jco.client.ashost: "ip-here", jco.client.client: "100", jco.client.lang: "EN", jco.client.passwd: "password-here", jco.client.sysnr: "01", jco.client.user: "user-here"}]" but I keep getting Destination RFCQueryEndpoint does not exist. Is the format different? – Cassio Pereira May 25 '18 at 17:21
  • I have also tried following this guide: https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/7fa92ffa007346f58491999361928303.html but I still get Destination does not exist. I'm not sure how to register it properly so the Cloud SDK can find it. – Cassio Pereira May 25 '18 at 22:15
  • I saw you posted a similar question about destinations. Is this question meanwhile answered? If so, would you post the answer here as well? – Emdee Jun 06 '18 at 11:59
0

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.

Cassio Pereira
  • 439
  • 1
  • 5
  • 15