An example that illustrates the basic code requirements for
connecting to SAP Mobile Server, updating mobile business object (MBO) data,
and synchronizing the device application from a device application based on the Client
Object API.
Subscribe to the package using synchronization APIs in the generated database class, specify the groups to be synchronized, and invoke the asynchronous synchronization method (beginSynchronize).
- Set the synchronization parameters if there are any.
- Make a blocking synchronize call to
SAP Mobile Server to pull in all MBO data:
[SMP101SMP101DB synchronize];
- List all customer MBO instances from the local database using
an object query, such as findAll, which is a
predefined object query.
SUPObjectList *objlist = [SMP101Customer findAll];
- Find and update a particular MBO instance, and save it to the local database.
SMP101Customer *customer = [SMP101Customer findByPrimaryKey:32838];
//Change some sttribute of the customer record
customer.fname= @"New Name";
[customer save];
- Submit the pending changes. The changes are ready for upload,
but have not yet been uploaded to the SAP Mobile Server.
[Customer submitPending];
- Use non-blocking synchronize call to upload the pending changes to the
SAP Mobile Server. The previous replay results and new
changes are downloaded to the client device in the download phase of the
synchronization session.
[SMP101SMP101DB beginSynchronize];