Skip to Content
0

Update OData failed SAPUI5

Jan 20, 2017 at 11:52 AM

176

avatar image

Hello!

I have some problems with update function. In OData Service it is everything working, there are no problems. I have tested. So, the problem is in Frontend in Form.

I can make update first time, but at the second time the program says about this problem.

If I update my page I can update my OData again but only one time.

I don't understand why my program says about duplicate id of input field...

There are my code of update function

	onUpdate: function() {
		var inputFragment = sap.ui.xmlfragment(
			"Z_MOBILE.view.AddFragment",
			this.getView().getController()


		);


		var Zeile1 = this.byId("Row1").getValue();
		var ID1 = this.byId("ID").getValue();
		var Activity = this.byId("Activity").getValue();
		var Level = this.byId("Level").getValue();
		var Plot = this.byId("Plot").getValue();
		var Area = this.byId("Area").getValue();
		var Description = this.byId("Description").getValue();
		var ZzStartmonth = this.byId("ZzStartmonth").getValue();
		var ZzActivitymonth = this.byId("ZzActivitymonth").getValue();
		var ZzMinutetotal = this.byId("ZzMinutetotal").getValue();
		var ZzMinutebase = this.byId("ZzMinutebase").getValue();
		var Itground = this.byId("Itground").getValue();
		var iteration = this.byId("Iteration").getValue();
		var oModel = this.getView().getModel();


		var data = {
			ZzID: ID1,
			ZzActivity: Activity,
			ZzLevel: Level,
			ZzPlot: Plot,
			ZzArea: Area,
			ZzDescription: Description,
			ZzStartmonth: ZzStartmonth,
			ZzActivitymonth: ZzActivitymonth,
			ZzMinutetotal: ZzMinutetotal,
			ZzMinutebase: ZzMinutebase,
			ZzIteration: iteration,
			ZzGroundarea: Itground


		};


		var dialog = new sap.m.Dialog({
			title: 'Confirm',
			type: 'Message',
			content: new sap.m.Text({
				text: 'Wollen Sie die Daten ändern?'
			}),


			beginButton: new sap.m.Button({
				text: 'Submit',
				press: function() {


					oModel.update(
						"/AllevoSat88Set(Zeile=" + "'" + Zeile1 + "'" +
						",Version='0',Pjahr='2013',Coobject='0000009999',Setclass='0101',Kokrs='1000',Mandt='800')", data, {
							merge: true
						}


					);
					sap.m.MessageToast.show('Submit pressed!');
					dialog.close();
				}


			}),
			endButton: new sap.m.Button({
				text: 'Cancel',
				press: function() {
					dialog.close();
				}
			}),
			afterClose: function() {
				dialog.destroy();
			}
		});


		dialog.open();


	}
p1.png (122.5 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Krishna Kishor Kammaje
Jan 20, 2017 at 04:21 PM
0

Whenever an Update is triggered, you are instantiating the fragment. So when you hit 'Update' second time, the earlier instance (upon first update) still exists, so no new instantiation fails due to duplicate id.

Why are you instantiating a fragment upon 'Update'?

Share
10 |10000 characters needed characters left characters exceeded
Akhilesh Upadhyay Jan 20, 2017 at 06:49 PM
0

issue with fragment initialisation, remove it if not needed OR

declare var as global and assign fragment to it when its initial, as below:

this.inputFragment= ""; //global, may be in onInit function

if(this.inputFragment == ""){
  this. inputFragment = sap.ui.xmlfragment(
                      "Z_MOBILE.view.AddFragment",
                      this.getView().getController()
                      );
}

Regards,

Akhilesh

Share
10 |10000 characters needed characters left characters exceeded
Khristina Filonchik Jan 23, 2017 at 08:00 AM
0

Thank you for your help! Now it works!

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

since your question status is still not answered, please mark your querry as resolved.

0