Skip to Content

SAPUI5 oData POST 500 error

Oct 19, 2017 at 04:07 PM


avatar image

I'm trying to do a oData create on checkbox pressed and getting the following errors. Not sure if this is front end or a back end ABAP issue as have got this same function working in another project. It is failing on the create part but strangely is still passing through the details for SiteId, ArticleNumber, VarianceDate & Confirmed.

// Set CheckBox status, X for true, blank for false
        onVarianceChecked: function (oEvent) {
            var oEntry = {};

            var bindingContext = oEvent.getSource().getBindingContext(this.MODEL_VIEW);
            var path = bindingContext.getPath();
            var object = bindingContext.getModel("SI").getProperty(path);

            // Pass in the Header fields
            oEntry.SiteId = this.SiteId;
            oEntry.ArticleNumber = object.ArticleNumber;
            oEntry.VarianceDate = moment(new Date(object.VarianceDate)).format('YYYY-MM-DDTHH:mm:ss');

            // Set X or blank
            if (oEvent.getParameter("selected") === true) {
                oEntry.Confirmed = "X";
            } else {
                oEntry.Confirmed = "";

            // Do the create
            var oModel = this.getView().getModel("SI");
            oModel.create("/VarianceHeaderSet", oEntry, {
                success: function () {
                    console.log("Variance confirmed");
          "Variance confirmed", {
                        duration: 1000
                error: function (oError) {
                    console.log("Error, variance could not be confirmed");
          "Error, variance could not be confirmed", {
                        duration: 1000
odata1.jpg (48.0 kB)
odata2.jpg (14.0 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Joseph BERTHE Oct 19, 2017 at 08:23 PM


In your OData data model (SEGW) set the property variantDate to nullable.

Regenerate and clear the metadata, it should work.


10 |10000 characters needed characters left characters exceeded
Scott Ingle Oct 19, 2017 at 10:38 PM

Thanks for your reply. I'll mention it to the ABAP developer tomorrow when get into work, I'm just the UI5 front end guy :) We did find a similar answer to this but my ABAP guy was saying that it couldn't be set to nullable as it was a primary key?? Not sure on the why but it's something I'll pick up with him, thanks.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

In fact if it is a primary key, then you should always set a value to your property, or at least (because it is a date) set the value to 99991231 or 19800101.