如何在 VDM 中获取本地化字段的文本?
How to get the text of localized fields in VDM?
我正在尝试使用 VDM 从我们的 S/4HANA 云(Public 云)获取业务合作伙伴数据。
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": "東京仕入先株式会社"
}
]
}
}
如果您使用的是 HttpServlet
,请务必先将 HttpServletResponse
对象的字符编码设置为 UTF-8
,并将内容类型设置为 application/json
撰写回复。
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
我正在尝试使用 VDM 从我们的 S/4HANA 云(Public 云)获取业务合作伙伴数据。
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": "東京仕入先株式会社"
}
]
}
}
如果您使用的是 HttpServlet
,请务必先将 HttpServletResponse
对象的字符编码设置为 UTF-8
,并将内容类型设置为 application/json
撰写回复。
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");