on 10-17-2013 8:41 AM
Hello Friends,
In my sample program getting the customer list, I am synchronizing the data base at the application startup. below is the code.
try {
Log.d(TAG, "Synchronizing..");
// Set synchronization profile
ConnectionProfile cp = SampleOneDB.getSynchronizationProfile();
cp.setServerName(SERVER);
cp.setPortNumber(SYNC_PORT);
cp.setNetworkProtocol(PROTOCOL);
cp.setAsyncReplay(true);
cp.setDomainName(DOMAIN);
cp.save();
} catch (Exception e) {
e.printStackTrace();
Log.d(TAG, e.getMessage());
}
try {
SampleOneDB.subscribe();
SynchronizationGroup sg = SampleOneDB
.getSynchronizationGroup("default");
sg.setEnableSIS(true);
sg.save();
SampleOneDB.synchronize();
} catch (Exception e) {
e.printStackTrace();
Log.d(TAG, e.getMessage());
}
after this code execution i m getting my initial screen with a button. if i click on the button i should get the customers list. below is the code.
GenericList<customer> customerIds = Customer.findAll();
here Customer is my MBO. after execution of this statement i am getting the size of list is 0. but i have the customers in my database. Can some body help me in this.
thanks,
Your codes looks fine. Use the below code for findall and check
for (Customer production : Customer.findAll()) {
String Name = production.getName;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Midhun,
I think there is no difference in this code. When ever I call "Customer.findAll()" i m getting the result size 0. So obviously its not going inside the for stmt.
As an alternative I tried with below code at the time of start up instead of the code which i sent in my first post.
CustomerSynchronizationParameters syncParameter = Customer
.getSynchronizationParameters();
syncParameter.delete();
syncParameter = Customer.getSynchronizationParameters();
syncParameter.setState_sp("MN");
syncParameter.save();
SampleOneDB.synchronize();
after this if i were call Customer.findAll() i am getting the result set size as 4, but those 4 are of state "MN". But here i want to synchronize the complete package not just with the state param.
Can you plz help me.
Thanks
The MBO is having mandatory load parameter and you created sync parameter for it. Hence when you are passing load sync parameter only you will get the data. Findall will not fetch all the data since mandatory load parameters are present. If the the load parameter is nullable / there is no load parameter only you will get all the data using findall.
- Midhun VP
My point is that the MBO has a load parameter. If you fill this value only you will get the data. Thats why you are getting "0" for the findall query. Since you have a load parameter you will not get the data for findall. Is the customer MBO associated with any RFC ? The cache DB is not filled while you are making a sync call without any input. if you pass input only the cache will be filled and you will be able to query.
- Midhun VP
Thanks Midhun,
My Customer MBO does not associated with any RFC in this sample.
I have only one sync parameter in my customer table. Now I want to retrieve the complete customer list into the Android UI. To get this I am trying to do the synchronize at start up. But as you said I made the sync parameter as nullable and now what should I do to get this?
Thanks,
In this case you don't have to maintain a sync key.Delete the sync key. In queries you will be having a findall query. In the properties of MBO click on query and check it is present. After synchronize call from device you should be able to use findall and it should get you all the data.
- Midhun VP
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.