我有问题,我想通过HTTP请求更新表。但我总是在表中的Edm.DateTime属性上收到错误消息。
错误:无效的URI-Segment '00:00',ValdTo = datetime'2019-04-03T00:00:00')'“}
甚至该值已经转换为Edm.DateTime。
valdfrom_edit = encodeURI(sap.ui.model.odata.ODataUtils.formatValue(new Date(values.ValdFrom), "Edm.DateTime"));
var update = "/ZSCORDERINGSet(Mandt='010',Vkorg='" + vkorg_Edit + "',ZzscSpSas='" + suppl_edit + "',ValdFrom=" + valdfrom_edit + ",ValdTo=" + valdto_edit + ")";
试试吧
const myODataModel = this.getOwnerComponent().getModel(/*modelName*/);
const update = () => myODataModel.update("/" + myODataModel.createKey("ZSCORDERINGSet", {
//<key>s for ZSCORDERING as described in $metadata
Mandt: "010",
Vkorg: vkorg_Edit,
ZzscSpSas: suppl_edit,
ValdFrom: new Date(values.ValdFrom), // no need to use ODataUtils.
ValdTo: valdto_edit
}), {
// properties of the entry that should be updated
}, {
// additional parameters such as success-, error-handler, groupId, ...
});
myODataModel.metadataLoaded().then(update);
API reference: v2.ODataModel#update
关于API createKey
,请参阅How to Create Entity Path Dynamically in UI5?它将根据OData规范为您创建实体路径,并始终以正确的顺序。
除此之外,请记住MockServer
doesn't support Edm.DateTime
in keys。
Edm.DateTime
键:不支持