Skip to Content
avatar image
Former Member

Offline SUP iOS app

Hi All,

I got stuck somewhere where we are creating operations in offline mode.

scenario: I have create customer screen with few input parameters like name and address:

Now where i am confused is if user create 4 customers in offline mode, how to manage to update all 4 customers to SAP.

I know there is surrogate key which generate unique number, but i am confused here how to handle this.

Another thing, when i got my connectivity back do i need to call method onConnectSuccess.

Waiting for suggestions.

Regards

Saket

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    May 17, 2013 at 06:43 AM

    Dear Saket,

    To create the customer in offline mode simply call the create operation on your MBO which is mapped with RFC to create customer at Backend... Also you need to put the operation in submitPending state.

    if you are creating the customer 4 times then for every time your operation goes into the submitPending state NOw when your app come to online state do the synchronization.. (hope ur using onDemand policy)

    At the back end, RFC will get call four times and it will create a 4 new customer that you have created in offline mode.

    Kind Regards,

    Amey

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Dear Saket,

      Basically there are different ways to achieve this task.

      1. before SUP server release 2.1.3, the MBO Object api contains some method like LoginToSync(), offlineLogin(), onLineLogin()

      LoginToSync() method itself calls offlineLogin() method (internally) when there is not network connectivity when user still tries to access the application i.e. tries to login.

      2 But from SUP 2.1.3 and later release the approach has been changed and now you need to register you the application with respect to device. by using registerApplication api. Now in this scenario if you want that your application should work in offline mode then follow below approach [I am using the same with my sup application]

      1. Register the application with sup server

      User is by default authenticated when application register successfully

      2. On successful registration store the username and password in to the device store

      3. Now suppose you are in network mode and tries to access the application then

      simply get the application instance and call the startConnection() method

      4. But now suppose you are not in network mode [you can check that by using network api supported by device platform] and you want to access the application, then what ever credentials user has entered in the Login screen just verify those credentials with the one which you have stored in device store when application was successfully registered. If the credentials match then allow user to navigate in to the application.

      below is the sample code snippet:

      Note: this is only sample code. You can refer this to get the idea about offlineLogin scenario

      **********************************************************************************

      static boolean offlineLoginFlag = false;

      public void TestOfflineLogin(){

      Initialize application();

      }

      public viod Initialize application{

      // Initialize Application settings

      Application app = Application.GetInstance();

      // The identifier has to match the application ID deployed to the SUP server

      app.ApplicationIdentifier = "SUP101";

      IApplicationCallback appCallback = new MyApplicationCallback();

      app.ApplicationCallback = appCallback;

      // set connection properties, login credentials, etc

      ConnectionProperties connProps = app.ConnectionProperties;

      LoginCredentials loginCred = new LoginCredentials("supAdmin", "supPwd");

      connProps.LoginCredentials = loginCred;

      SUP101DB.SetApplication(app);

      if (app.RegistrationStatus != RegistrationStatus.REGISTERED)

      {

      // If the application has not been registered to the server, register now

      app.RegisterApplication(<timeout_value>);

      offlineLoginFlag =true

      }

      else

      {

      if(network availabe){

      // start the connection to server

      app.StartConnection(<timeout_value>);

      }

      else{

      // retirve the last successful stored credential from the store and compare with the one entered by user

      if(match){

      //Navigate the user to login screen

      }

      else{

      //display a invalid credentials pop up message to the user

      }

      }

      }

      if(offlineLoginFlag){

      //set the offlineLoginFlag to false

      offlineLoginFlag = false;

      //store the application credentials to the device store.

      }

      }

      **********************************************************************************

      Hope this will help you to understand the offlineLogin concept.

      This is the approach what I have following to achieve the offlineLogin scenario, If there any other alternate available then I request all the sup expert to comment your thoughts!!!

      Kind Regards,

      -Amey Baisane