sap.n.Database & AppSync

sap.n.Database & AppSync is a component of the AppSync framework that enables the offline usage of large data sets in frontend applications. It allows for downloading and storing substantial amounts of data from the backend into an SQLite Database on the browser or device. By using Models and bindings, data can be seamlessly synchronized between the frontend and backend. This component is particularly useful when extensive data needs to be available offline for efficient and uninterrupted user experiences.

Supported browsers and OS

On Desktop:

  • Google Chrome

  • Microsoft Edge

On Mobile:

  • Android

  • iOS

  • Windows 10

It is always recommended to check if your specific platform and browser version is supported at: https://caniuse.com/#feat=sql-storage

Procedure

Start Neptune Application Designer (NAD) and create or change an Application.

On the Libraries section, drag a Database object to your application.

sap database appsync 0

Add a nested Table inside the Database and give it a name .In the example below, TableDD02L is the given name.

sap database appsync 1

Your application should have one Database object and as many Tables as needed inside it.

Bind the Table component to one of your ABAP internal tables.

sap database appsync 2

Internal tables must be declared as public attributes of your ABAP Class

sap database appsync 3

Select the Key Field for the Table.

sap database appsync 4

Add the statement to trigger the AppSync process. In the example below, it will trigger 4 processes in parallel:

AppSyncStart(4);

sap database appsync 5

Set the logic for the ajaxSuccess and ajaxError events. These will be triggered once the AppSync is completed (or failed).

sap database appsync 6

When AppSync(…​) is triggered, HANDLE_ON_SYNC_OUT method is executed on the ABAP Class.

The logic for retrieving the data must be coded there:

sap database appsync 7

sap database appsync 8

Accessing the offline data

Once the Data is stored in the sap.n.Database, it can be accessed via JavaScript in two ways:

1. Using ModelData.FindDB

In the example below, records where TableDD02L-TABNAME contains inFilterMatnr.getValue() will be added to modeltabData (the model behind tabData )

sap database appsync 9

2. Using SQL Query

More complex SQL queries can be done on the SQLite database. In the example below, the number of records of TableDD02L is fetched.

sap database appsync 10

AppSync

The AppSync framework, utilized by sap.n.database, offers the capability to employ multiple threads for data retrieval. These threads can operate either in parallel or serial mode, providing flexibility and efficiency.

When initiating the sync process, it is essential to specify the desired number of threads. By default, the framework employs a single thread, but this value can be adjusted to suit the specific requirements of the application.

Please keep in mind that each thread will trigger an Ajax call to the backend, and therefore a new session will run in your ABAP stack

Properties

List of properties

sap database appsync 11

AppSync Progress Dialog

sap database appsync 12