<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: OData model binding on model.read /get entity in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/odata-model-binding-on-model-read-get-entity/qaa-p/12270363#M4596533</link>
    <description>&lt;P&gt;Hello Rohit,&lt;/P&gt;&lt;P&gt;Thanks for quick reply.&lt;/P&gt;&lt;P&gt;In above case, which element will be appropriate for binding? According to my understanding, element will be the UI control like panel or label or text etc.. right?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yayati &lt;/P&gt;</description>
    <pubDate>Fri, 28 Aug 2020 05:49:04 GMT</pubDate>
    <dc:creator>YayatiEkbote</dc:creator>
    <dc:date>2020-08-28T05:49:04Z</dc:date>
    <item>
      <title>OData model binding on model.read /get entity</title>
      <link>https://community.sap.com/t5/technology-q-a/odata-model-binding-on-model-read-get-entity/qaq-p/12270361</link>
      <description>&lt;P&gt;Hello experts,&lt;/P&gt;
  &lt;P&gt;I work as ABAP developer but I am new to SAP UI5. I have followed ui5.sap.com , walkthrough model binding concepts.&lt;/P&gt;
  &lt;P&gt;I am developing a very basic demo application for my practice. &lt;/P&gt;
  &lt;P&gt;I have an input field where I will enter company code. On button press, I am executing function onGetAddress.&lt;/P&gt;
  &lt;P&gt;In the function onGetAddress, I am giving call to the OData service. &lt;/P&gt;
  &lt;P&gt;My view is like this - &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;mvc:View controllerName="CA_Descriptor.CompanyAddress_Cpy.controller.Main" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m" xmlns:f="sap.ui.layout.form"&amp;gt;
&amp;lt;Page id="page" title="{i18n&amp;gt;title}" binding="{/CompanyAddressSet}"&amp;gt;
  &amp;lt;content&amp;gt;
	&amp;lt;f:SimpleForm id="CompInput" title="{i18n&amp;gt;comp_sel}" editable="true" layout="ResponsiveGridLayout" labelSpanS="12" labelSpanM="3" labelSpanL="3" labelSpanXL="3" emptySpanXL="4" emptySpanL="4" emptySpanM="4" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1" singleContainerFullSize="false"&amp;gt;
		&amp;lt;f:content&amp;gt;
			&amp;lt;Label id="l_bukrs" text="{i18n&amp;gt;l_bukrs}"/&amp;gt;
			&amp;lt;Input id="ip_bukrs" /&amp;gt;
			&amp;lt;Button id="b_getAddr" text="Get Address" press="getCompAddr"/&amp;gt;
		&amp;lt;/f:content&amp;gt;
	&amp;lt;/f:SimpleForm&amp;gt;
	&amp;lt;f:SimpleForm id="AddrDetail" title="{i18n&amp;gt;comp_addr}" editable="true" layout="ResponsiveGridLayout" labelSpanS="12" labelSpanM="3" labelSpanL="3" labelSpanXL="3" emptySpanXL="4" emptySpanL="4" emptySpanM="4" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1" singleContainerFullSize="false"&amp;gt;
		&amp;lt;f:content&amp;gt;
			&amp;lt;Label id="l_name" text="{i18n&amp;gt;l_name}"/&amp;gt;
			&amp;lt;Text id="t_Name" text="{CompAddr&amp;gt;/Name1}"/&amp;gt;
			&amp;lt;Label id="l_street" text="{i18n&amp;gt;l_stras}"/&amp;gt;
			&amp;lt;Text id="t_Street" text="{CompAddr&amp;gt;/Street}"/&amp;gt;
			&amp;lt;Label id="l_city" text="{i18n&amp;gt;l_city}"/&amp;gt;
			&amp;lt;Text id="t_City" text="{CompAddr&amp;gt;/City1}"/&amp;gt;
			&amp;lt;Label id="l_regio" text="{i18n&amp;gt;l_regio}"/&amp;gt;
			&amp;lt;Text id="t_Region" text="{CompAddr&amp;gt;/Region}"/&amp;gt;
			&amp;lt;Label id="l_ctry" text="{i18n&amp;gt;l_ctry}"/&amp;gt;
			&amp;lt;Text id="t_Country" text="{CompAddr&amp;gt;/Country}"/&amp;gt;
		&amp;lt;/f:content&amp;gt;
	&amp;lt;/f:SimpleForm&amp;gt;
 &amp;lt;/content&amp;gt;
&amp;lt;/Page&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;My Controller is like this &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/m/MessageToast"
], function (Controller,MessageToast) {
	"use strict";


	return Controller.extend("CA_Descriptor.CompanyAddress_Cpy.controller.Main", {
		onInit: function () {
			var oModel = this.getOwnerComponent().getModel("CompAddr");
			this.getView().setModel(oModel);
		},
		getCompAddr: function(){
			var gModel = this.getView().getModel();
			var vInput = this.getView().byId("ip_bukrs").getValue();
			var vQuery = "/CompanyAddressSet('" + vInput + "')";
			function fnSuccess(oData,oResponse){
				console.log("Data",oData);
				console.log("Response",oResponse);
			}
			
			function fnError(oError){
				console.log("Error", oError);
			}


			gModel.read(vQuery,{
				success: fnSuccess,
				error: fnError
				});
			
			MessageToast.show("Clicked");
		}
	});
});
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;When I press the button, I can see that the service is bringing the data correctly which I am logging in console. But I am unable to see the data reflected back in the view display.&lt;/P&gt;
  &lt;P&gt;I want to learn how to bind the data back to view on the button click.&lt;/P&gt;
  &lt;P&gt;I have declared model and datasource properly in manifest.json.&lt;/P&gt;
  &lt;P&gt;My manifest.json looks like this - &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;{
	"_version": "1.12.0",
	"sap.app": {
		"id": "CA_Descriptor.CompanyAddress_Cpy",
		"type": "application",
		"i18n": "i18n/i18n.properties",
		"applicationVersion": {
			"version": "1.0.0"
		},
		"title": "{{appTitle}}",
		"description": "{{appDescription}}",
		"sourceTemplate": {
			"id": "servicecatalog.connectivityComponentForManifest",
			"version": "0.0.0"
		},
		"dataSources": {
			"YE_DEMO_COMP_ADDR_SRV": {
				"uri": "/destination/SBX/sap/opu/odata/sap/YE_DEMO_COMP_ADDR_SRV/",
				"type": "OData",
				"settings": {
					"localUri": "localService/metadata.xml"
				}
			}
		}
	},
	"sap.ui": {
		"technology": "UI5",
		"icons": {
			"icon": "",
			"favIcon": "",
			"phone": "",
			"phone@2": "",
			"tablet": "",
			"tablet@2": ""
		},
		"deviceTypes": {
			"desktop": true,
			"tablet": true,
			"phone": true
		}
	},
	"sap.ui5": {
		"flexEnabled": false,
		"rootView": {
			"viewName": "CA_Descriptor.CompanyAddress_Cpy.view.Main",
			"type": "XML",
			"async": true,
			"id": "Main"
		},
		"dependencies": {
			"minUI5Version": "1.65.6",
			"libs": {
				"sap.ui.layout": {},
				"sap.ui.core": {},
				"sap.m": {}
			}
		},
		"contentDensities": {
			"compact": true,
			"cozy": true
		},
		"models": {
			"i18n": {
				"type": "sap.ui.model.resource.ResourceModel",
				"settings": {
					"bundleName": "CA_Descriptor.CompanyAddress_Cpy.i18n.i18n"
				}
			},
			"CompAddr": {
				"type": "sap.ui.model.odata.v2.ODataModel",
				"settings": {
					"defaultOperationMode": "Server",
					"defaultBindingMode": "OneWay",
					"defaultCountMode": "Request",
					"useBatch": true
				},
				"dataSource": "YE_DEMO_COMP_ADDR_SRV",
				"preload": true
			}
		},
		"resources": {
			"css": [{
				"uri": "css/style.css"
			}]
		},
		"routing": {
			"config": {
				"routerClass": "sap.m.routing.Router",
				"viewType": "XML",
				"async": true,
				"viewPath": "CA_Descriptor.CompanyAddress_Cpy.view",
				"controlAggregation": "pages",
				"controlId": "app",
				"clearControlAggregation": false
			},
			"routes": [{
				"name": "RouteMain",
				"pattern": "RouteMain",
				"target": ["TargetMain"]
			}],
			"targets": {
				"TargetMain": {
					"viewType": "XML",
					"transition": "slide",
					"clearControlAggregation": false,
					"viewId": "Main",
					"viewName": "Main"
				}
			}
		}
	}
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Aug 2020 07:20:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odata-model-binding-on-model-read-get-entity/qaq-p/12270361</guid>
      <dc:creator>YayatiEkbote</dc:creator>
      <dc:date>2020-08-27T07:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: OData model binding on model.read /get entity</title>
      <link>https://community.sap.com/t5/technology-q-a/odata-model-binding-on-model-read-get-entity/qaa-p/12270362#M4596532</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You need to make a few changes in your code.&lt;/P&gt;&lt;P&gt;First, you need to perform Element Binding on success function of  your read call on your form layout which is showing the details.&lt;/P&gt;&lt;P&gt;You can find a good example for this in the SDK: &lt;A href="https://sapui5.hana.ondemand.com/#/topic/6c7c5c266b534e7ea9a28f861dc515f5"&gt;Element Binding&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Additionally, I noticed that the binding in the Details form is with absolute paths (eg: {CompAddr&amp;gt;/Name1}). You would need to change it to Relative paths (eg: {CompAddr&amp;gt;Name1}).&lt;/P&gt;&lt;P&gt;Do let me know if you face any further issues.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Rohit&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 08:42:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odata-model-binding-on-model-read-get-entity/qaa-p/12270362#M4596532</guid>
      <dc:creator>rohit_singhal</dc:creator>
      <dc:date>2020-08-27T08:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: OData model binding on model.read /get entity</title>
      <link>https://community.sap.com/t5/technology-q-a/odata-model-binding-on-model-read-get-entity/qaa-p/12270363#M4596533</link>
      <description>&lt;P&gt;Hello Rohit,&lt;/P&gt;&lt;P&gt;Thanks for quick reply.&lt;/P&gt;&lt;P&gt;In above case, which element will be appropriate for binding? According to my understanding, element will be the UI control like panel or label or text etc.. right?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yayati &lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 05:49:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odata-model-binding-on-model-read-get-entity/qaa-p/12270363#M4596533</guid>
      <dc:creator>YayatiEkbote</dc:creator>
      <dc:date>2020-08-28T05:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: OData model binding on model.read /get entity</title>
      <link>https://community.sap.com/t5/technology-q-a/odata-model-binding-on-model-read-get-entity/qaa-p/12270364#M4596534</link>
      <description>&lt;P&gt;I did the element binding to the simple form control and it started working.&lt;/P&gt;&lt;P&gt;Thanks for quick reply.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 15:35:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odata-model-binding-on-model-read-get-entity/qaa-p/12270364#M4596534</guid>
      <dc:creator>YayatiEkbote</dc:creator>
      <dc:date>2020-08-28T15:35:42Z</dc:date>
    </item>
  </channel>
</rss>

