为自定义odata服务生成的javavdm更新价格后返回结果为null
The returned result is null after price is updated with java vdm generated for custom odata service
我们有一个自定义 OData 服务(函数导入)来更新 S/4HANA 本地系统 (1909) 中的价格。我使用 Java VDM 生成器为此 OData 服务生成 VDM。
OData 服务更新价格
/sap/opu/odata/SAP//ChangePrice?SalesOrganisation=''&Plant=''&MaterialNumber=''&ConditionAmount=2100&ConditionUnit='EUR'&ValidFrom=datetime'2019-01-01T00:00:00'&ValidTo=datetime'2019-12-31T00:00 :00'
在我调用 changePrice 方法并在 S/4HANA 系统中更新价格后,returned 实体 (priceCondUpdated) 为空。
TransferPriceCondition priceCondUpdated = service.changePrice(condUnit,
price,
materialNo,
plant,
LocalDateTime.of(2019, 1, 1, 0, 0, 0),
LocalDateTime.of(2019, 12, 31, 0, 0, 0),
salesOrg).execute(DestinationUtil.getHttpDestination());
我调试了SAP Cloud SDK的源代码,发现OData Service给出了正确的响应。
OData 响应
{"__metadata":{"id":"http://host:port/sap/opu/odata/sap//TransferPriceCondition(SalesOrganisation='',Plant='',MaterialNumber='')","uri":"http://host:port/sap/opu/odata/sap//TransferPriceCondition(SalesOrganisation='',Plant='',MaterialNumber='')","type":".TransferPriceCondition"},"SalesOrganisation":"1709","Plant":"","MaterialNumber":"***", "ConditionAmount":"123.000","ConditionUnit":"EUR","ValidFrom":"/日期(1546346659000)/","ValidTo":"/日期(1577796259000)/ "}
当它要从SDK中的响应中获取实体时,请参阅下面的源代码 responseJsonObject 不包含 edmFunctionImportName(changePrice)。所以它将 return 为空。
Cloud SDKFunctionImportResponseParser.java 的源代码
@Nullable
<T> T getEntityFromResponse(
final InputStream responseContent,
final String edmFunctionImportName,
final Class<? extends T> entityJavaType )
throws IOException,
IllegalArgumentException
{
final JsonObject responseJsonObject = getJsonObjectFromResponse(responseContent);
if( responseJsonObject.has(edmFunctionImportName) ) {
final JsonElement jsonElement = responseJsonObject.get(edmFunctionImportName);
return getEntityFromJsonElement(jsonElement, entityJavaType);
}
return null;
}
你能帮忙看看这个问题吗?
SAP Cloud SDK 版本:3.3.1
S/4HANA 本地:1909
谢谢,
杰瑞
感谢您提供有据可查的问题!请使用 SAP Cloud SDK 3.6.0 及以上版本。我们修复了 OData 函数导入结果的解析。
此致,
亚历山大
我们有一个自定义 OData 服务(函数导入)来更新 S/4HANA 本地系统 (1909) 中的价格。我使用 Java VDM 生成器为此 OData 服务生成 VDM。
OData 服务更新价格
/sap/opu/odata/SAP//ChangePrice?SalesOrganisation=''&Plant=''&MaterialNumber=''&ConditionAmount=2100&ConditionUnit='EUR'&ValidFrom=datetime'2019-01-01T00:00:00'&ValidTo=datetime'2019-12-31T00:00 :00'
在我调用 changePrice 方法并在 S/4HANA 系统中更新价格后,returned 实体 (priceCondUpdated) 为空。
TransferPriceCondition priceCondUpdated = service.changePrice(condUnit,
price,
materialNo,
plant,
LocalDateTime.of(2019, 1, 1, 0, 0, 0),
LocalDateTime.of(2019, 12, 31, 0, 0, 0),
salesOrg).execute(DestinationUtil.getHttpDestination());
我调试了SAP Cloud SDK的源代码,发现OData Service给出了正确的响应。
OData 响应
{"__metadata":{"id":"http://host:port/sap/opu/odata/sap//TransferPriceCondition(SalesOrganisation='',Plant='',MaterialNumber='')","uri":"http://host:port/sap/opu/odata/sap//TransferPriceCondition(SalesOrganisation='',Plant='',MaterialNumber='')","type":".TransferPriceCondition"},"SalesOrganisation":"1709","Plant":"","MaterialNumber":"***", "ConditionAmount":"123.000","ConditionUnit":"EUR","ValidFrom":"/日期(1546346659000)/","ValidTo":"/日期(1577796259000)/ "}
当它要从SDK中的响应中获取实体时,请参阅下面的源代码 responseJsonObject 不包含 edmFunctionImportName(changePrice)。所以它将 return 为空。
Cloud SDKFunctionImportResponseParser.java 的源代码
@Nullable
<T> T getEntityFromResponse(
final InputStream responseContent,
final String edmFunctionImportName,
final Class<? extends T> entityJavaType )
throws IOException,
IllegalArgumentException
{
final JsonObject responseJsonObject = getJsonObjectFromResponse(responseContent);
if( responseJsonObject.has(edmFunctionImportName) ) {
final JsonElement jsonElement = responseJsonObject.get(edmFunctionImportName);
return getEntityFromJsonElement(jsonElement, entityJavaType);
}
return null;
}
你能帮忙看看这个问题吗?
SAP Cloud SDK 版本:3.3.1 S/4HANA 本地:1909
谢谢, 杰瑞
感谢您提供有据可查的问题!请使用 SAP Cloud SDK 3.6.0 及以上版本。我们修复了 OData 函数导入结果的解析。
此致, 亚历山大