1

我正在尝试使用 VDM 从我们的 S/4HANA 云(公共云)获取业务合作伙伴数据。

        final List<BusinessPartner> businessPartners =
                new DefaultBusinessPartnerService()
                        .getAllBusinessPartner()
                        .select(BusinessPartner.BUSINESS_PARTNER,
                                BusinessPartner.BUSINESS_PARTNER_NAME)
                        .filter(BusinessPartner.BUSINESS_PARTNER_CATEGORY.eq("2"))
                        .orderBy(BusinessPartner.BUSINESS_PARTNER, Order.ASC)
                        .execute();

英文业务伙伴名称显示正确。但日本业务伙伴名称显示为?????。

{"BusinessPartner":"80000001","BusinessPartnerName":"Domestic US Customer 1"},
{"BusinessPartner":"80000002","BusinessPartnerName":"?????????????"},
{"BusinessPartner":"90000001","BusinessPartnerName":"Domestic US Supplier 1"},
{"BusinessPartner":"90000002","BusinessPartnerName":"????????"}

你能给我建议如何获取本地化字段的文本吗?

谢谢。

(补充说明)

我用 Postman 手动执行了 OData。在这种情况下,本地化字段以日语显示。

https://myXXXXXX.s4hana.ondemand.com/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner?$select=BusinessPartner,BusinessPartnerName&$orderby=BusinessPartner&$filter=BusinessPartnerCategory%20eq%20'2'&$format=json&saml2=disabled

输出

{
    "d": {
        "results": [
            {
                "__metadata": {
                    "id": "https://myXXXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('80000001')",
                    "uri": "https://myXXXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('80000001')",
                    "type": "API_BUSINESS_PARTNER.A_BusinessPartnerType"
                },
                "BusinessPartner": "80000001",
                "BusinessPartnerName": "Domestic US Customer 1"
            },
            {
                "__metadata": {
                    "id": "https://myXXXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('80000002')",
                    "uri": "https://myXXXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('80000002')",
                    "type": "API_BUSINESS_PARTNER.A_BusinessPartnerType"
                },
                "BusinessPartner": "80000002",
                "BusinessPartnerName": "東京得意先株式会社"
            },
            {
                "__metadata": {
                    "id": "https://myXXXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('90000001')",
                    "uri": "https://myXXXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('90000001')",
                    "type": "API_BUSINESS_PARTNER.A_BusinessPartnerType"
                },
                "BusinessPartner": "90000001",
                "BusinessPartnerName": "Domestic US Supplier 1"
            },
            {
                "__metadata": {
                    "id": "https://myXXXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('90000002')",
                    "uri": "https://myXXXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('90000002')",
                    "type": "API_BUSINESS_PARTNER.A_BusinessPartnerType"
                },
                "BusinessPartner": "90000002",
                "BusinessPartnerName": "東京仕入先株式会社"
            }
        ]
    }
}
4

1 回答 1

6

如果您使用的是HttpServlet,请确保在编写响应之前将HttpServletResponse对象的字符编码设置为UTF-8,并将内容类型设置为。application/json

response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
于 2018-10-09T14:56:05.207 回答