Skip to Content

SimpleForm in XML with OData

Hey there,

I don't know what I'm doing wrong.

I have a simpleform and try ti bind it to a oData service.

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:form="sap.ui.layout.form"
		controllerName="wm_mde.WE_ERFASSEN" xmlns:html="http://www.w3.org/1999/xhtml">
	<Page title="Wareneingang erfassen">
		<content>
		<form:SimpleForm
			layout="ResponsiveGridLayout"
			editable="true"
			id="bestForm" >
			<Label displayOnly="true" wrapping="true" text="Bestellung" for="edtEBELN" required="true"/>
			<Input id="edtEBELN" change="onEbelnChange" valueLiveUpdate="true"></Input>
			<Label displayOnly="true" wrapping="true" text="Lieferschein" for="edtLIEFS" required="true"/>
			<Input id="edtLIEFS" change="onLiefsChange" value="{bestellung>Bktxt}" valueLiveUpdate="true"></Input>
			<Label displayOnly="true" wrapping="true" text="Belegdatum" for="edtBELDAT" required="true"/>
			<Input id="edtBELDAT" change="onBeldatChange" value="{Lfdat}" valueLiveUpdate="true"></Input>
			<Label displayOnly="true" wrapping="true" text="Lagerort" for="edtLGORT"/>
			<Input 
				id="edtLgort"
				editable="false" 
				value="{Lgort}"
				valueLiveUpdate="true" />
			<Label displayOnly="true" wrapping="true" text="Bestelldatum" for="edtBESTDAT"/>
			<Input id="edtBESTDAT" 
				editable="false" 
				value="{Bestdat}" 
				valueLiveUpdate="true"
				/>
				<Label displayOnly="true" wrapping="true" text="Text" for="txt"/>
				<!--<Text id="txt" text="{
  path: '/d/Bestdat',
  type: 'sap.ui.model.type.Date',
  formatOptions: {
  	style: 'long',
  	pattern: 'yyyy/MM/dd'
  }
  
  }" valueLiveUpdate="true"/>-->
				<Text text="{ 
				path: '/d/Bestdat',
				type: 'sap.ui.model.type.Date',
				formatOptions: { pattern: 'yyyy/MM/dd'} }" />
			<Label displayOnly="true" wrapping="true" text="Anforderer" for="edtANFORD"/>
			<Input id="edtANFORD" editable="false" value="{Lgnum}" valueLiveUpdate="true"></Input>
			</form:SimpleForm>
		</content>
		<footer>
			<Toolbar>
				<Button text="Abbruch" type="Reject" press="onCancel"/>
				<ToolbarSpacer/>
				<Button text="Weiter" type="Accept" id="btnOK" press="onOk"/>				
			</Toolbar>
		</footer>
	</Page>
</core:View>

And this is my controller

sap.ui.controller("wm_mde.WE_ERFASSEN", {


/**
* Called when a controller is instantiated and its View controls (if available) are already created.
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
* @memberOf wm_mde.WE_ERFASSEN
*/
	onInit: function() {
		var oModel = new sap.ui.model.odata.v4.ODataModel({
	    	serviceUrl: "http://obelix3.1net.dom:8002/sap/opu/odata/sap/ZWM_MDE_SRV_03/",
	    	synchronizationMode : "None"
	    });
		this.getView().byId("bestForm").setModel(oModel);
	},


/**
* Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered
* (NOT before the first rendering! onInit() is used for that one!).
* @memberOf wm_mde.WE_ERFASSEN
*/
//	onBeforeRendering: function() {
//		
//	},


/**
* Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
* This hook is the same one that SAPUI5 controls get after being rendered.
* @memberOf wm_mde.WE_ERFASSEN
*/
//	onAfterRendering: function() {
//
//	},


/**
* Called when the Controller is destroyed. Use this one to free resources and finalize activities.
* @memberOf wm_mde.WE_ERFASSEN
*/
//	onExit: function() {
//
//	}


	onEbelnChange: function(oEvent){
		ebeln=this.getView().byId("edtEBELN").getValue();
		 this.getView().byId("bestForm").bindElement({
				path: "/BESTSet(Ebeln='"+ebeln+"',Lgnum='110')",
		 });
		
		
		this.getView().byId("edtLIEFS").focus();
	},
	
	onLiefsChange: function(oEvent){
		this.getView().byId("edtBELDAT").focus();
	},
	
	onBeldatChange: function(oEvent){
		this.getView().byId("btnOK").focus();
	},
	onCancel: function(){
		app.back();
	},
	
	onOk: function(evt){
	
		
	}
	
});

I always get these two errors!

unbenannt.png (24.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 06, 2017 at 11:52 AM

    Seems to be an error in v4.ODataModel!

    If I use sap.ui.model.odata.ODataModel instead of v4, everything is fine!

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 06, 2017 at 02:53 AM

    Hi Sven Schuberth,

    It seems you are using the $batch URI which I think is not required for your simple form. Also, for your path, just try to execute the same URL in your netweaver gateway and check if you get a response.

    Regards,

    Arjun Biswas

    Add comment
    10|10000 characters needed characters exceeded