Quantcast
Channel: SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 789

OFFLINE Data Storage

$
0
0

Hi,

 

As we know SAP Next transformations are SAP Fiori/UX design approach. The main agenda for this transformations are to reduce more number of clicks in SAP Screen and Code Once RUN on ANY DEVICE.

 

Scenarios:

 

- Tablet/Mobile

- WareHouse Area

- Wifi Health : weak

- Assume my user id have thousands of records. If I am calling all the time to hit GW services, my application performance will move to Bad health. So what to do?

 

Sol: OFFLINE DATA

 

 

Here is the solution to solve this problem. While rendering SAP UI5/Fiori application (view) we should call services at one time and use below code to store all user details into local memory ( Not in application memory).

 

var filePath = "MyFileName.JSON";

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(FS) {

     FS.root.getFile(filePath, {create:false, exclusive:false},

         function(fileEntry) {

             fileEntry.file(function(file) {

          var reader = new FileReader();

 

 

          reader.onloadend = function(e) {

          funCall(this.result);

          };

          reader.readAsText(file);

          });

         }, fail);

  }, fail);

 

 

function fail(){

  var objJSON = null;

  funCall(objJSON);

  }

 

Based on create:false/true flag, we can read or create new file from/to local memory.

 

This way will helps you to do offline functionality .

 

Thanks,

Karthik A


Viewing all articles
Browse latest Browse all 789

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>