Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
ashish_rawat
Explorer

    This article tend to address  registration and login issue with Sybase. 

    There are two ways to sync with Sybase RBS and MBS.

    RBS is the replication based sync which is usually default available  for all devices except IOS. However from Sybase 2.1.3 IOS will also migrate to RBS.

    MBS (message BS) was only  supported for IOS. For details about replication methods you can see the following  link.

    http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01205.0152/doc/html/mqu1250107188294...

    As RBS is the way forward and all offline application are moving to it . I will summaries the way to login/connect using RBS.

    If you are trying to connect your Windows mobile /Android /IOS devices to sybase. Do it in following order.

  1. Registration.
  2. Registration occurs between SUP -----> Mobile devices.  In RBS scenario registration is auto. You not need to register user in Sybase server and use activation code. The only thing that need to be maintained in server is auto registration template. 

    Auto registration template should be maintained in such a way that it should give  unique result for your  input parameters.

    Eg if you have give "application id"  than there should be only one auto registration template for each application,  if you give "application id "  and security configuration, then combination should be unique. 

    Most scenario of Login/Registration fails here. 

    Registration code for android devices  is a  follows. .

    com.sbase.mobile.Application app = com.sybase.mobile.Application.getInstance();

    if (app.getApplicationIdentifier()== null)

    {

    app.setApplicationIdentifier("sapretailex");

    app.setApplicationContext(context);

    }

    //connection properties

    ConnectionProperties profile = app.getConnectionProperties();

    profile.setServerName(servername);

    profile.setPortNumber(portnumber);

    //profile.setActivationCode(strActivationCode);

    profile.setNetworkProtocol(networkprotocol);

    //if user name pwd doesn't work then create credential

    LoginCredentials logcred = new LoginCredentials(userid,password);

    profile.setLoginCredentials(logcred);

    SAPRetailExDB.setApplication(app);

    //enable logs

    SAPRetailExDB.enableChangeLog();

    if (app.getRegistrationStatus()!= RegistrationStatus.REGISTERED)

    app.registerApplication(1000);

    After execution of  the last line of above code, you must be able to see  an entry in  SCC-> application connections, showing your simulator or device id . This random number is generated by SCC and assigned to your device/simulator.  If you reregister the device again with different user, it will generate a different number for same device/simulator.

    One important thing to notice is same user can't be registered with 2 devices for a give device type. Haven't tried multiple devices for same user yet, so can't comment.

  3. Authentication
  4. Once  a device is registered. It is by default authenticated., user need not to authenticate it twice.

    However for every subsequent  synchronization, user should open connection.

    if (app.getConnectionStatus()!=        ConnectionStatus.CONNECTED)

    app.startConnection(1000);

    However as our application should work in offline more in case of no network connection, you can use offlineauthentication method as well.

  5. Database Creation
  6.   

    Once user is registered and authenticated, the  MBO database has to be created in device, the code is straight forward and self explanatory. Following is code for android device

    ConnectionProfile  conprof = SAPRetailExDB.getConnectionProfile();

    File dir = Environment.getExternalStorageDirectory();

    File yourFile = new File(dir, "RETAILEXECUTION/SAPRETAILEX10.ulj");

    conprof.setProperty("databaseFile", yourFile+"");

    //conprof.setEncryptionKey("SAP");

    conprof.setCacheSize(102400);

    conprof.save();

    if (!SAPRetailExDB.databaseExists())

    SAPRetailExDB.createDatabase();

    SAPRetailExDB.openConnection();

    Connection profile determine the database connection properties õf local database.

  7. Synchronization
  8. Once database has been created, user registered and authenticated, the final step is synchronization.

    For sync, first you need to maintain the synchronization profile, which unfortunately is also named as ConnectionProfile and adds to confusion(people tend to think it is same as connectionprofile) .

    However this profile is purely used for sync,  and its properties are prefilled from server, when user is registered.  Still it is safe to provide all possible value again manually

    ConnectionProfile syncProfile = SAPRetailExDB.getSynchronizationProfile();

    LoginCredentials cred = new LoginCredentials(userid,password);

    syncProfile.setCredentials(cred );

    syncProfile.setServerName(server);

    syncProfile.setPortNumber(syncPort);

    syncProfile.setNetworkProtocol(networkProtocol);

    //syncProfile.setDomainName("ANDROID");

    syncProfile.setDomainName(domain);

    syncProfile.save();

    Once synchronization profile is set the only thing pending is to set the personalization parameter and sync.  Personalization parameter is an important concept and has to be mandatorily given even if it  is not being used. It has to be saved blank for the MBO's you have declared them in server.

    If personalization parameters are not maintained, the sync will fail, even if you are not using them.

    PersonalizationParameters pp =          SAPRetailExDB.getPersonalizationParameters();

    // Assign values to the PersonalizationParameters object:

    //String value ="002BC74DB9D8446FE10000000A428970";

    String value = generateRandomId();

    pp.setSyncGuidPK( value);

    pp.setLanguagePK("EN");

    pp.save();

    YourMBO.getSynchronizationParameters().save();

    SAPRetailExDB.synchronize("ActivitySyncGroup", listener);

    Each of the above steps has more intricacies to it.  I have just jotted down the most common things to do to achieve the sync. However for each of above topic it is advised to read in great length in http://infocenter.sybase.com/help/index.jsp?workingSet=SUP2.1

    Happy Coding !!!!!

2 Comments