cancel
Showing results for 
Search instead for 
Did you mean: 

Write date to Odata Model 0CALDAY as string?

0 Kudos

I add new data to my oData Model by creating a new Entry like this:

_.forEach(insert, data => {
var entry = (modelprefix + "('" + data.COL01 + "')");
oModel.create(modelprefix, data, mParameters);
});

That code is working finde for strings and numbers, but when it comes to a date, it doesn't work.

My target structure contains a 0CALDAY column, in which the values from the "insert" JSON Model should get parsed. I don't get an error or anything, just nothing happens..

I suspect that this is because 0CALDAY expects an object to be inserted, but it gets only a String. But what can I do?

That's one object of my Insert-JSON-Model: COL04 is the date to be inserted. It already has the correct format for my SAP! (dd.mm.yy)

Accepted Solutions (0)

Answers (2)

Answers (2)

SergioG_TX
Active Contributor
0 Kudos

can you see what is getting posted correctly? i do not know why you would get an error while parsing xml stream since your service has json... are you specifying xml anywhere? are you able to see the payload on postman ? or the network tab in your browser?

SergioG_TX
Active Contributor
0 Kudos
if your service expects a date object..  you will need to create a date based on the string value such as 

new Date('YY.MM.DD')

hops this works
0 Kudos

Thanks 9958e4b6df99431a84a41b015b639ac8 . I came to that solution as well and now convert my dates to date objects before updating my data. But that causes an "Error while parsing XML stream".

I now have a date with the correct format that gets pushed to the oData model, but somehow it doesn't accept that either..

Do you know why?