1

I have the problem, that I want to update a table via HTTP-request. But I always get an error-message on the Edm.DateTime attributes in the table.

Error: Invalid URI-Segment '00:00',ValdTo=datetime'2019-04-03T00:00:00')'"}

Even the value is already converted to 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 + ")";
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Vasi
  • 25
  • 9

1 Answers1

0

Try with:

// ... After metadata loaded:
// Create the sPath:
const sPath = "/" + myV2ODataModel.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
});
// Call the ODataModel API with the created sPath:
myV2ODataModel.update(sPath/*, other arguments according to the API reference ... */);

API reference: v2.ODataModel#update

About the API createKey, see How to create OData V2 entity path dynamically in UI5? It will create the entity path for you according to the OData specification and always in the right order.


Note: sap.ui.core.util.MockServer doesn't support Edm.DateTime in keys.

[...] OData features that are not supported by the mock server:

Feature Status
Edm.DateTime keys Unsupported
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170