Skip to Content
0

Any Idea for this error??

Jan 24 at 08:34 AM

29

avatar image

Controller.js

	_handleSubmitTrc: function(e) {
		 var f = this.updateModelByForm(this.viewMode);
		if (f) {
			this._handleCreateCall(true);
		}
		
	},
	_handleSaveTrc: function(e) {
		var f = this.updateModelByForm(this.viewMode);
		if (f) {
			this._handleCreateCall(false);
		}
	},
	updateModelByForm: function(v) {
		var i, a;
		// if (!this.validateForm()) {
		//     return false;
		// }
		if (this.viewMode !== this.viewModes.NewTravel) {
			var t = this.getView().getModel().getProperty("/" + this.sTravelPath).Id;
			this.CreateTravelRequestModel.setProperty("/Id", t);
		}
		var P = "Visit";
		this.CreateTravelRequestModel.setProperty("/Purpose", P);
		var A = this.byId("Trc_s_Activity");
		this.CreateTravelRequestModel.setProperty("/TripActivity", A.getSelectedKey());
		a = this.byId("Desk_Depart_R1");
		var d = a.getDateValue();
		var D = travel.request.create.util.Formatters.formatDateToISOString(d);
		this.CreateTravelRequestModel.setProperty("/Departure", D);
		a = this.byId("Trc_D_To");
		var b = a.getDateValue();
		var c = travel.request.create.util.Formatters.formatDateToISOString(b);
		this.CreateTravelRequestModel.setProperty("/Arrival", c);
		this.CreateTravelRequestModel.setProperty("/CountryCode", "I");
		 this.CreateTravelRequestModel.setProperty("/Location", "Kolkata");
		var h = 0;
		var O = [];
		if (this.getView().getModel("CostAssignmentsModel") !== undefined) {
			var j = this.getView().getModel("CostAssignmentsModel").getData();
			this.CreateTravelRequestModel.getData().CostAssignments = [];
			for (i = 0; i < j.length; i++) {
				var k = {};
				k.CostObjectId = j[i].selectedCostObject;
				k.CostObjectType = j[i].selectedCostObjectType;
				k.Percentage = j[i].percentage.toString();
				if (j[i].selectedSalesOrderItem) {
					k.CostObjectItemId = j[i].selectedSalesOrderItem;
				}
				this.CreateTravelRequestModel.getData().CostAssignments.push(k);
				h = h + parseInt(j[i].percentage, 10);
			}
		}

	var a = this;
		var U = this.getUserInfo();
		this.oDataModel.setRefreshAfterChange(false);
		if (t) {
			this.CreateTravelRequestModel.setProperty("/UserAction", "3");
		} else {
			this.CreateTravelRequestModel.setProperty("/UserAction", "2");
		}
		// var oModel = this.getView().getModel();
		// oModel.setUseBatch(false);
		// oModel.read("/Travels", {


		// 	success: function(oData, oResponse) {


		// 		var oModel1 = new sap.ui.model.json.JSONModel();
		// 		oModel1.setData({
		// 			Totcity: oData.results
		// 		});
		// 		this.getView().setModel(oModel1, "CityModel");


		// 	}.bind(this),
		// 	error: function(err) {


		// 	}.bind(this)


		// });
		this.oDataModel.create("/Travels", this.CreateTravelRequestModel.getData(), null, function(r) {
			var c = new sap.ui.model.json.JSONModel({
				bHasPendingChanges: false
			});
			var C = sap.ui.core.Component.getOwnerIdFor(a.oView),
				o = sap.ui.component(C);
			var b = a.viewMode;
			if (a.viewMode === a.viewModes.NewTravel) {
				o.oEventBus.publish("travel.request.create", "RefreshNew", {
					param: "/Travels('" + r.Id + "')"
				});
				a.viewMode = a.viewModes.EditTravel;
			} else {
				o.oEventBus.publish("travel.request.create", "RefreshUpdate");
			}
			a.oApplicationFacade.setApplicationModel("changesModel", c);
			jQuery.sap.delayedCall(100, a, function() {
				if (t) {
					a.oRouter.navTo("detail", {
						contextPath: "Travels('" + r.Id + "')"
					}, true);
				} else {
					if (b === a.viewModes.NewTravel) {
						this.fromSave = true;
						a.oRouter.navTo("edit", {
							contextPath: "Travels('" + r.Id + "')"
						}, true);
					} else {
						a.callValueHelps(a.viewMode, "Travels('" + r.Id + "')", false);
					}
					a.resetControlState();
				}
			});
			a._setBusyOff();
			if (t) {
				if (U.Approver) {
					a.showMessageToast(a.oResourceBundle.getText("SUBMITTED_MSG", [U.Approver]));
				} else {
					a.showMessageToast(a.oResourceBundle.getText("SUBMITTED_MSG_NO_APPROVER"));
				}
			} else {
				a.showMessageToast(a.oResourceBundle.getText("SUBMITTED_MSG_SAVE_ONLY"));
			}
		}, function(e) {
			a.oDataModel.setRefreshAfterChange(true);
			if (a.oDataModel.hasPendingChanges()) {
				a.oDataModel.refresh(true);
			}
			a._onRequestFailed(e);
		});
	},

error1.png (161.4 kB)
metadata.jpg (534.2 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Nabi Zamani Jan 24 at 08:53 AM
0

I'm not a magician, thus it's hard to help you from the details in your question! You should add details, i.e. code snippets showing how you post the data, the relevant $metadata for the entity you try to POST, the POST request payload from you network tab of your browser...

From the error message I can tell you the following:

- You are using an OData service on SAPGW
- The entity has a property "Value"
- You send an empty string as value, which seems to be invalid

Again, you did not offer enough details!!!!!!!!!!!!!!

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

I have uploaded metadata and controller code. Now can you help me??

0