0

I'm following the OData tutorial at https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/comment-page-1/ and I'm getting an error when I try to retrieve business partners using DefaultBusinessPartnerService.

The relevant piece of code is:

        DefaultBusinessPartnerService businessPartnerService = new DefaultBusinessPartnerService();
        System.err.println("criated default business partner");

        List<BusinessPartner> partners = businessPartnerService
                .getAllBusinessPartner()
                .select(BusinessPartner.BUSINESS_PARTNER,
                        BusinessPartner.LAST_NAME,
                        BusinessPartner.FIRST_NAME)
                //.filter(BusinessPartner.BUSINESS_PARTNER_CATEGORY.eq(CATEGORY_VENDOR))
                .orderBy(BusinessPartner.LAST_NAME, Order.ASC)
                .execute(new ErpEndpoint(new ErpConfigContext()));

        response.setContentType("application/json");
        response.getWriter().write(new Gson().toJson(partners));

My ErpQueryEndpoint configuration is as follows:

#Mon May 14 15:27:09 BRT 2018
URL=https\://host\:port
Name=ErpQueryEndpoint
TrustAll=TRUE
Type=HTTP
Password=Password
Authentication=BasicAuthentication
User=Username

Where host, port, Username and Password have been replaced by the correct values.

When I query http://localhost:8080/s4integration-application/businesspartners I get the following error:

The endpoint responded with HTTP error code 403.
No service found for namespace , name API_BUSINESS_PARTNER, version 0001
Full error message: 
{
  "error": {
    "code": "/IWFND/MED/170",
    "message": {
      "lang": "en",
      "value": "No service found for namespace , name API_BUSINESS_PARTNER, version 0001"
    },
    "innererror": {
      "application": {
        "component_id": "",
        "service_namespace": "/SAP/",
        "service_id": "API_BUSINESS_PARTNER",
        "service_version": "0001"
      },
      "transactionid": "C83CB3D2A1420000E005AF97B0836AD5",
      "timestamp": "20180514182746.3576100",
      "Error_Resolution": {
        "SAP_Transaction": "Run transaction /IWFND/ERROR_LOG on SAP Gateway hub system (System Alias ) and search for entries with the timestamp above for more details",
        "SAP_Note": "See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"
      },
      "errordetails": []
    }
  }
}

It seems that the endpoint is not configured on the SAP system (it's an S/4 Hana system). I'm not sure if I have to add something else to the URL besides the host and port or if there is some other configuration that has to be done on the SAP system.

Cassio Pereira
  • 439
  • 1
  • 5
  • 15
  • Just for clarification before we consider an answer: Is your system an S/4HANA on-prem or cloud system that you are trying to connect. Which version of S/4HANA is this system? Thank you. – Philipp Herzig May 14 '18 at 18:54
  • On System status I see `HDB 1.00.112.04.1467296086` and `S4CORE` release 101. Not sure if you need more info. It's on-prem. – Cassio Pereira May 14 '18 at 19:05
  • S4CORE release 101 sp 0000 – Cassio Pereira May 14 '18 at 20:23
  • 1
    Looks as if the OData service API_BUSINESS_PARTNER is not exposed from your SAP S/4HANA system. In order to check that, open transaction /IWFND/MAINT_SERVICE and see if this API is included in the table under Service Catalog. – Emdee May 15 '18 at 06:47
  • I can't even see it listed. I have a bunch of `ZC_...` services, such as `ZC_CUSTOMER_OP_SRV`, but can't find any `API_BUSINESS_PARTNER`. Is there a way to enable the services needed by the cloud SDK? What's weird is that I can access https://host:port/sap/opu/odata/sap/C_PURCHASEORDER_FS_SRV/C_PurchaseOrderFs?$top=10 from my browser. It seems the services names expected by the Cloud SDK are not there. – Cassio Pereira May 15 '18 at 15:35
  • Instructions for activating OData APIs from the SAP S/4HANA backend can be found here: https://help.sap.com/viewer/cdc25c83b63e482586b31b8acd49cf2f/1610%20003/en-US/4c288b58841a3132e10000000a441470.html Just ignore the notion of the Fiori app. – Emdee May 17 '18 at 06:11

1 Answers1

1

Instructions for activating OData APIs from the SAP S/4HANA backend can be found here: help.sap.com/viewer/cdc25c83b63e482586b31b8acd49cf2f/1610%20003/… Just ignore the notion of the Fiori app.

Emdee
  • 1,689
  • 5
  • 22
  • 35