Skip to Content

Help required for CSV Binding to Odata Service

Dec 07, 2017 at 02:08 PM


avatar image
How to bind to oData service. I am able to upload ".CSV" file and displayed in sap.m.Table but unable to bind to oData service. Can you please help anybody how to archive this?

//my view.xml

<FileUploader xmlns="sap.ui.unified" id="idfileUploader" name="myFileUpload" uploadUrl="" buttonText="{i18n>upload}" fileType="csv"
						buttonOnly="true" icon="sap-icon://upload" change="handleExcelUpload" uploadComplete="handleUploadComplete" typeMissmatch="onFailedFUP"
						fileSizeExceed="onFailedFUP" uploadAborted="onFailedFUP" filenameLengthExceed="onFailedFUP" maximumFileSize="0" multiple="true"
						sameFilenameAllowed="false" sendXHR="true"/>

//my controller.js

handleExcelUpload: function(e) {
			var oPlmSelect = this.getView().byId("plmSelect");
			var oSelectedVal = oPlmSelect.getSelectedItem().getText();
			var oTable = this.getTable();

			var file = e.getParameter("files") && e.getParameter("files")[0];
			if (file && window.FileReader) {
				var reader = new FileReader();
				reader.onload = function(evn) {

					var strCSV =; //string in CSV
					var aCSV = strCSV.split('\n'),
						row = {};

					for (var i = 0; i < aCSV.length; i++) {
						row = aCSV[i].split(';');
						aCSV[i] = {
							"ZZSSENDER": row[0],
							"ZZSHIPTO": row[1],
							"ZZLNUM": row[2],
							"ZZCNR": row[3]
						}; // cell 1, 2, 3, 4

					var oModel = new sap.ui.model.json.JSONModel(aCSV);


					oTable.bindAggregation("items", {
						path: "/PMSSet",
						filters: [{
							path: "{ZZPLANMARKETID}",
							operator: "EQ",
							value1: oSelectedVal
						factory: function(sId, oContext) {
							// console.log(sId);
							var oSender = new sap.m.Text({
								text: oContext.getProperty("ZZSSENDER")
							var oShipTo = new sap.m.Text({
								text: oContext.getProperty("ZZSHIPTO")
							var oWhn = new sap.m.Text({
								text: oContext.getProperty("ZZLNUM")
							var oKunn = new sap.m.Text({
								text: oContext.getProperty("ZZCNR")
							return new sap.m.ColumnListItem({
								cells: [
									oSender, oShipTo, oWhn, oKunn



// My OData Service 

<EntityType Name="PMSDispatch" sap:content-version="1">
<PropertyRef Name="ZZPLANMARKETID"/>
<PropertyRef Name="ZZSSENDER"/>
<PropertyRef Name="ZZSHIPTO"/>
<Property Name="ZZPLANMARKETID" Type="Edm.String" Nullable="false" MaxLength="4" sap:unicode="false" sap:label="PM"/>
<Property Name="ZZSSENDER" Type="Edm.String" Nullable="false" MaxLength="18" sap:unicode="false" sap:label="Sender store area"/>
<Property Name="ZZSHIPTO" Type="Edm.String" Nullable="false" MaxLength="18" sap:unicode="false" sap:label="Ship to store area"/>
<Property Name="ZZLNUM" Type="Edm.String" MaxLength="3" sap:unicode="false" sap:label="CD warehouse"/>
<Property Name="ZZCNR" Type="Edm.String" MaxLength="10" sap:unicode="false" sap:label="CD receiving site"/>

/// entityset

<EntityContainer Name="ZLO_NAME_SRV_Entities" m:IsDefaultEntityContainer="true" sap:supported-formats="atom json xlsx">
	<EntitySet Name="PMSSet" EntityType="ZLO_NAME_SRV.PMSDispatch" sap:searchable="true" sap:requires-filter="true" sap:content-version="1"/>

My out put in screen shot.


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

0 Answers