我正在尝试使用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": "東京仕入先株式会社"
}
]
}
}
答案 0 :(得分:6)
如果您使用的是HttpServlet
,请确保在编写以下内容之前将HttpServletResponse
对象的字符编码设置为UTF-8
,并将内容类型设置为application/json
。响应。
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");