cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a Database for MBO

Former Member
0 Kudos

Hi All,

Iam trying to do an application in Native android, I have copied the generated MBO codes to my project in eclipse.Now I want a functionality where my app should store data into Local Mobile DB if no network connection exist.

So my question is,

1- Should I create my own DB for this using sqlite or will MBO create it?

2- In case MBO is creating it, what will be the fields will be there in the Tables?

3- How can I check for network and Do the sync accordingly?

4- What should I do if User closes the application and still data was not sync'd and it exists in LocalDB?

I'm badly stuck here .Please help me in this.

Regards,

Pratheek

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Pratheek ,

Trying to answer your queries.

1. If you totally want to implement offline scenario you can always have Sq lite DB in your app .In this case you will have to do the modelling according to the data you have in your actual back end.

MBO will create a device database when you run the application.you can store the same after the first successful sync and use it for offline scenarios .

2.The DB created by MBO should be mapping to your actual back end DB.

3. I am not sure about android but there are API's available to check for network connectivity .like in iOS one can use reachbility api to check for network connections and proceed accordingly .

4. You can delete and recreate the DB every time to have a fresh sync each time you run the application .

Hope this helps !!

Thanks ,

Amit Nalawade.

Former Member
0 Kudos

Hi Amit,

Thanks a TON for your reply, I find a CreateDatabase method in MBODB does this create tables?

Will it have Attributes of MBO or Load Parameters of my BAPI?.

I am not sure about how I will sync my data if i create my own database and Tables. Can you help me with this?

Former Member
0 Kudos

Yes Pratheek .

[MBODB createdatabase] is used to create device side database with tables mapping to your MBO's.

[MBODB deletedatabase] is used to delete the database .

You dont have to worry about it .Create database will create the schema for your tables .

When you call MBODB beginsychronize/synchronize api data will pe pushed to the tables .

you can go infocenter.sybase.com ,select your sup version and refer android developer guide there.

Answers (1)

Answers (1)

midhun_vp
Active Contributor
0 Kudos

1. Should I create my own DB for this using sqlite or will MBO create it?

You don't have to create a DB. It will be done by SUP itself. It is the advantage of using SUP. It will reduce the complexity of development of an Enterprise mobile app. If the SUP project name is "Test" means the DB name will be "TestDB".

2. In case MBO is creating it, what will be the fields will be there in the Tables?

The fields will be the same as in the MBO. Let's say MBO attribute is "name" same will be there in the DB which is created.

3. How can I check for network and do the sync accordingly?

This would help you.

public final boolean isInternetOn()

          {

            ConnectivityManager connec = (ConnectivityManager)

              getSystemService(Context.CONNECTIVITY_SERVICE);

            if ( connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED ||

                 connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED )

            {

               return true;

            }

            else if ( connec.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED

              ||  connec.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED  )

            {

              return false;

            }

            return false;

          }

You can call this method to before sync.

4. What should I do if User closes the application and still data was not sync'd and it exists in LocalDB?

Android allows multi- tasking, even you close the app to run another like "contacts" it will be working in the background. The synchronise API you are using will give a success response on success sync. Based on this response you can understand whether the sync is success or not.

Also in android it is possible to use background task. You can perform that to do sync/operation asynchronously whenever the network is available.

- Midhun VP

Former Member
0 Kudos

Hi Midhun,

Thanks for the answer.

Now my Question is,

I have a RFC which has different Importing and Exporting parameter, Now when I update or Create a new Record I will be using client parameter and passing the value, So if MBO is storing the attributes of the specific MBO how will it do sync when client parameter is what is needed to be passed?

Regards,

Pratheek

midhun_vp
Active Contributor
0 Kudos

I don't understand the question. Can you please elaborate.

- Midhun VP

Former Member
0 Kudos

OK.

I have an RFC which inserts data into database, It has some parameters say, Name and Age and Exporting Parameter "Success" which indicates result of insert operation.

Now I create an MBO for this RFC, it has Attribute "Success". So I created a Create Operation for this MBO and mapped Name and Age to 2 Client parameters.

Now when I call create method I pass these client Parameters.

As you have mentioned above the MBODB will create database using MBO attributes, so here Success will be the field of the table.

But I want to store name and age, not the success variable.

What should I do in this case?

and MBODB.createDatabase is giving me an error as well, is there any specific steps to be followed when doing this?

Kindly provide me some Inputs

I'm really Stuck.

Thanks and Regards,

Pratheek

midhun_vp
Active Contributor
0 Kudos

I got your requirement. You are trying to save the input parameters. The input parameters are static here if you want to save these values means you need to use Android APIs of your choice. http://developer.android.com/guide/topics/data/data-storage.html

- Midhun VP