我们有一个自定义OData服务(函数导入),用于更新S / 4HANA本地系统中的价格(1909)。然后,我使用Java VDM Generator为该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系统中更新了价格之后,返回的实体(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服务给出了正确的响应。
OData响应
{“ __元数据”:{“ id”:“ http://host:port/sap/opu/odata/sap/ / TransferPriceCondition(SalesOrganisation =' ',Plant =' ',MaterialNumber =' ')“,” uri“:” http://host:port/sap/opu/odata/sap/ / TransferPriceCondition(SalesOrganisation =' ',工厂=' ',MaterialNumber =' ')“,” type“:” .TransferPriceCondition“},” SalesOrganisation“:” 1709“,” Plant“:” “,” MaterialNumber“:” ***“,” ConditionAmount“:” 123.000“,” ConditionUnit“:” EUR“,” ValidFrom“:” / Date(1546346659000) /“,” ValidTo“:” /日期(1577796259000)/“}
要从SDK中的响应获取实体时,请参见下面的源代码responseJsonObject不包含edmFunctionImportName(changePrice)。因此它将返回null。
Cloud SDK中的FunctionImportResponseParser.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年
谢谢, 杰瑞
答案 0 :(得分:2)
感谢有据可查的问题!请使用 SAP Cloud SDK 3.6.0及更高版本。我们修复了OData函数导入结果的解析。
最好的问候, 亚历山大