0

我正在关注https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/comment-page-上的 OData 教程1/当我尝试使用DefaultBusinessPartnerService.

相关的代码是:

        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));

我的ErpQueryEndpoint配置如下:

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

其中hostport和已替换为正确的值UsernamePassword

当我查询时,http://localhost:8080/s4integration-application/businesspartners我收到以下错误:

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": []
    }
  }
}

SAP 系统上似乎没有配置端点(它是 S/4 Hana 系统)。我不确定是否必须URL在主机和端口之外添加其他内容,或者是否必须在 SAP 系统上完成一些其他配置。

4

1 回答 1

1

可以在此处找到从 SAP S/4HANA 后端激活 OData API 的说明:help.sap.com/viewer/cdc25c83b63e482586b31b8acd49cf2f/1610%20003/... 忽略 Fiori 应用程序的概念。

于 2018-05-22T12:30:52.377 回答