How to upload CSV file data in SAPUI5 and SAP Fiori Applications


Hello everyone, in this blog we will show you how to upload CSV file data in SAPUI5 and SAP Fiori Applications. Lets get started.



You should have basic understanding on building SAPUI5 applications. To get all beginner tutorials please check here.

UI Controls used

  • File Uploader from sap.ui.unified library
  • Table and Button from sap.m library

Step-by-Step Procedure

1. Create a SAPUI5 application in Eclipse IDE with one view and a controller. You project structure will look like below.

SAPUI5 Project Structure 2. Go to index.html and copy the below code.

		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

		<script src="resources/sap-ui-core.js"
		<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->

			var app = new sap.m.App({initialPage:"idFileUpload1"});
			var page = sap.ui.view({id:"idFileUpload1", 
	<body class="sapUiBody" role="application">
		<div id="content"></div>

3. Go to FileUpload.view.xml file and copy the below code to build the view.

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
	xmlns="sap.m" xmlns:u="sap.ui.unified" xmlns:l="sap.ui.layout.form"
	controllerName="fileupload.FileUpload" xmlns:html="">
	<Page title="Demo on CSV File Upload">
		<l:SimpleForm editable="true">
		  <Label text="File Name">
		 <u:FileUploader id="idfileUploader" width="50%"
		    sameFilenameAllowed="false" buttonText="" fileType="CSV"
		    placeholder="Choose a CSV file" style="Emphasized">
		<Button text="Upload" press="onUpload"></Button>

		<Table id="idTable" items="{/}">
			<Text text="{VBELN}"></Text>
			<Text text="{ERDAT}"></Text>
			<Text text="{VBTYP}"></Text>
			<Text text="{TRVOG}"></Text>
			<Text text="{AUART}"></Text>
			<Text text="Sales Document"></Text>
			<Text text="Date"></Text>
			<Text text="Type"></Text>
			<Text text="Sales Org"></Text>
			<Text text="Category"></Text>

4. Lets see what we have done in the previous step.We created the view to show File Uploader, Button and Table UI control.

5. Go to FileUpload.controller.js file and copy the below code.

sap.ui.controller("fileupload.FileUpload", {

    onUpload : function(e) {
	var fU = this.getView().byId("idfileUploader");
	var domRef = fU.getFocusDomRef();
	var file = domRef.files[0];
	// Create a File Reader object
	var reader = new FileReader();
	var t = this;
	reader.onload = function(e) {
	    var strCSV =;
	    var arrCSV = strCSV.match(/[\w .]+(?=,?)/g);
	    var noOfCols = 5;

	    // To ignore the first row which is header
	    var hdrRow = arrCSV.splice(0, noOfCols);

	    var data = [];
	    while (arrCSV.length > 0) {
		var obj = {};
		// extract remaining rows one by one
		var row = arrCSV.splice(0, noOfCols)
		for (var i = 0; i < row.length; i++) {
		    obj[hdrRow[i]] = row[i].trim()
		// push row to an array
	    // Bind the data to the Table
	    var oModel = new sap.ui.model.json.JSONModel();
	    var oTable = t.byId("idTable");

6. The above code inside onUpload event handler will read the data from the CSV file and bind the data to the Table.

You have successfully created a SAPUI5 application to load the data from CSV file. Please stay tuned to us for more SAPUI5 Tutorials.


  1. Hi Team,
    Great Work
    Thanks a Lot for this post. I was searching for this from a very long Time.
    I would like to add the .csv file that is not available in this post. 🙂

    Please find the below .csv file format which should be copied into a CSV file.

  2. Please i have a question, i saw in fileUpload view that there is {VBELN} and other fields.. Should i define any model,? how does it apply data binding?

  3. Hi Team,

    Thankyou. It was very helpfull. But can you can tell what changes i have to make to upload the same file to backend system

  4. Hi. Do you have any example using gateway to upload CSV into backend? I tried with FileUpload but it’s not working.


  5. Hello,

    Thank you for this. I have created the same file and getting below error –

    Uncaught TypeError: Cannot read property ‘createTextField’ of undefined
    at f.F.init (:8080/FileUploader/resources/sap/ui/unified/FileUploader.js:6)
    at f.constructor (sap-ui-core.js:134)
    at f.constructor (sap-ui-core.js:134)
    at f.constructor (sap-ui-core.js:134)
    at new f (sap-ui-core.js:122)
    at h (:8080/FileUploader/resources/sap/ui/core/library-preload.json/sap/ui/core/XMLTemplateProcessor.js:6)
    at e (:8080/FileUploader/resources/sap/ui/core/library-preload.json/sap/ui/core/XMLTemplateProcessor.js:6)
    at d (:8080/FileUploader/resources/sap/ui/core/library-preload.json/sap/ui/core/XMLTemplateProcessor.js:6)
    at y (:8080/FileUploader/resources/sap/ui/core/library-preload.json/sap/ui/core/XMLTemplateProcessor.js:6)
    at h (:8080/FileUploader/resources/sap/ui/core/library-preload.json/sap/ui/core/XMLTemplateProcessor.js:6)

    Could you please give any suggestion or idea to rectify the error or any solution to come out from this error!

    Arindam Samanta.


Please enter your comment!
Please enter your name here