cancel
Showing results for 
Search instead for 
Did you mean: 

retaining data for Upload Sync BO

Former Member
0 Kudos

Hi all ,

If I am using an Upload type of Sync BO , the local data on client is sent to server after synchronization . But if I want to retain the data on client after synchronization , what setting should done or methods called in Java classes ?

I think I need to edit SyncInboxObserver class and the class which has method to save the data locally and call getLocal() setLocal() methods . But I am not sure .

Can anybody help in this ?

Thank You

Rucha Atre

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi rucha,

there's no way to prevent MI client from deleting your upload SyncBo once it had

reached the backend. this is by design. now if you want to save your data once it

gets uploaded, you can register an outbound listener (SyncBoOutDeltaObserver)

or the MessageReplyObserver to copy your data somewhere.

SyncBoOutDeltaObserver is deprecated and if you don't want to use it, you may

use MessageReplyObserver interface to listen for MessageReplyType.SYNC_BEGIN.

now where to put your data is of your preference. you can either create a local

SyncBo version for that SyncBo element and insert it there prior to synchronization; or create your own serializer class.

hope this help.

jo

Former Member
0 Kudos

hi Jo,

can you give me a step by step procedure how to add / make the changes ? I can only use syncInboxObserver class .

Thanks

Rucha Atre

Former Member
0 Kudos

hi rucha,

just a summary of steps:

1) modify your metadata (meRepMeta.xml) and copy the definition of your upload

SyncBo giving it a new name. e.g: you have BOXXXX syncbo & the corresponding

local SyncBo BOXXXX_LOCAL. <b>notice the attributes too.</b>

you need to include your modified meRepMeta.xml in the app and re-deploy it.


<SyncBO id="BOXXXX" version="1" type="upload" allowCreate="false" allowModify="false" allowDelete="false">
 <TopStructure name="TOP">
 <Field name="SYNC_KEY" type="N" length="10" decimalLength="0" signed="false" isKey="true" isIndex="true">
  <Input type="create">false</Input> 
  <Input type="modify">false</Input> 
  </Field>
  :
   </TopStructure>
  </SyncBO>

<SyncBO id="BOXXXX_LOCAL" version="1" type="twoWay" allowCreate="true" allowModify="true" allowDelete="true" suppressUpload="true" suppressDownload="true">
 <TopStructure name="TOP">
 <Field name="SYNC_KEY" type="N" length="10" decimalLength="0" signed="false" isKey="true" isIndex="true">
  <Input type="create">false</Input> 
  <Input type="modify">false</Input> 
  </Field>
  :
   </TopStructure>
  </SyncBO>

2) implement the MessageReplyObserver and listen for MessageReplyType.SYNC_BEGIN

here's a sample implementation for MessageReplyObserver. you can make use

of the SyncBoOutDeltaObserver as well however it is deprecated.


class BOXXXBackupObserver implements MessageReplyObserver{
  public MessageReplyType[] observeMessageReplyTypes(){
    return new MessageReplyType[]{MessageReplyType.SYNC_BEGIN};
  }

  public void messageReplyReceived(MessageReply messageReply){
    if(MessageReplyType.SYNC_BEGIN == messageReply.getType()){
       SyncBoDataFacade df = SmartSyncRuntime.getInstance().getSyncBoDataFacade();
       SyncBoDescriptorFacade dc = SmartSyncRuntime.getInstance().getSyncBoDescriptorFacade();
       SyncBoDescriptor bdo= dc.getSyncBoDescriptor("BOXXX");
       SyncBoDescriptor bdl = dc.getSyncBoDescriptor("BOXXX_LOCAL");
       try {
         if(bdl!=null){
            SyncBoCollection sbc = df.getSyncBos(bdo);
            for(MeIterator sit = sbc.iterator(); sit.hasNext();){
              SyncBo bo = (SyncBo)sit.next();
              SyncBo bl = df.createEmptySyncBo(bdl);
              copyToLocal(bo,bl);
              df.insertSyncBo(bl);
           }
         }
       } catch (Exception e) {
        e.printStackTrace();
       }
    }
  }
  
  private void copyToLocal(SyncBo orig, SyncBo local) throws Exception{
     SyncBoDescriptor bdl = local.getSyncBoDescriptor();
     copyFields(orig.getTopRow(),local.getTopRow());
     RowCollection[] rca = orig.getRows();
     for(int idx = 0; idx < rca.length; idx++){
       for(MeIterator rit = rca[idx].iterator(); rit.hasNext();){
         Row ro = (Row)rit.next();
         RowDescriptor rd = bdl.getRowDescriptor(ro.getRowDescriptor().getRowName());
         if(rd!=null){
           Row rl = local.createEmptyRow(rd);
           copyFields(ro,rl);
           local.insertRow(rl);
         }
       }
     }
  }

  private void copyFields(Row orig, Row local) throws ModificationNotAllowedException{
    Field[] o= orig.getFields();
    Field[] l = local.getFields();
    for(int idx=1;  idx<o.length;idx++){
      l[idx].modifyValue(o[idx].getValue());
     }
  }
}
 

3) register your observer somewhere in your app. could be in your starting jsp.


  SmartSyncRuntime.getInboxNotifier().registerMessageReplyObserver(new BOXXXBackupObserver());

4) modify your existing pages or add new ones for listing of your local syncbo.

that's it... just note that i never had tested this. im writing it just to give you an

idea and basis for your needs. (typo errors might present).

i didnot put any comments on the code as well. they're pretty self-explanatory i

guess... but if you have questions, just let me know.

regards

jo

prashantha_hj
Employee
Employee
0 Kudos

Hi Rucha,

If you do not want to have one more SyncBo, you can use one more feature in MI itself to store the data locally. There is an API called MultiObjectFileStorage in package com.sap.ip.me.api.services, which helps in storing the Object on filesystem. This is basically an helper to serialize java objects on file system.

You have to still follow most of the "Jo's" post and example but only difference is, there will not be any LOCAL SyncBo, but a plain vanilla java class which is serializable.

Instead of using MI helper MultiObjectFileStorage api. You can still use other ways of local data storage also.

Regards,

Prashanth

Former Member
0 Kudos

Hi Rucha,

U01 type of syncbo only uploads the data in backend,but it will not be pushed back to client.

For this we need to use T01/S01 type of syncbo from client to retrive the data back to client.

For example you create a Hotel using U01 type of syncbo and that hotel gets created in backend and will not come to client, so you can retrive the hotel back to client using T01/S01 type of syncbo(hotel syncbo) of the same functionality.

For T01 syncbo we need to replicate the hotel syncbo from backend to middleware and then perform a sync from client so that T01(Hotel syncbo) will retrive the data to client.

For S01 we can just sync the client to get the data to client(sync once to upload and sync again to get the data back)

Hope this is helpful.

Kindly let me know if you need more information.

Cheers,

Karthick

Former Member
0 Kudos

Hi Rucha,

It seems you working on customization of MAM appplication, correct me if i am wrong. I understand that you want to supress a download request and retain data on the client.

The API you are talking is in " <b>com.sap.mbs.mam.sync.SyncInboxObserver</b> ".

<b><i>addNoRequestSyncBos(SyncBoName)</i></b> The method set the processing type of the specified SyncBO to “NO_REQUEST”.

you can use 2. <b><i>removeNoRequestSyncBos(SyncBoName).</i></b> to set the processing type back to its default state.

In order for the mentioned methods to work, prior to syncing the first time on the device, the user must enter MAM application first. This will register this call and with this the methods will now be available to execute.

Hope this helps.

Regards

Divya

Former Member
0 Kudos

hi Divya ,

When you say suppress download request , what does that mean ? My requirement is that data should be sent to server . At the same time I should be able to retain the data on client .

I would need getLocal() and setLocal() methods isnt it?

Thanks

Rucha

Former Member
0 Kudos

Hi Rucha,

If i am not mistaken you want to get the data back to client for U01 type of syncbo.

As i mentioned we cannot directly get the data back to client using U01.

We can use other syncbo of same functionality(t01/s01) to get the data back to client.

Using U01 we cannot get the data back to client(It supports only create).

Cheers,

Karthick

Former Member
0 Kudos

hi Karthik ,

I dont want data back from server . Before I synchronize , the data is locally stored on the client . So I simply want to retain that data on client after synchronization .

Thanks

Rucha

Former Member
0 Kudos

Hi Rucha,

I have a doc which i think will help you. please share you email ID.

Regards

Divya

Former Member
0 Kudos

Hi Divya ,

my id is ruchaatre@gmail.com

Kindly let me know after you have mailed me .

Thank You very much

Rucha

Former Member
0 Kudos

Hi Rucha,

Hope this doc helps you. I have not seen any article or supporting API which exactly serve your needs. SyncBo(Out/In)DeltaObserver, SyncBo(Out/In)Delta all these have been deprecated.I am afraid if these will be helpful.

Are you working on MAM application?

Regards

Divya