cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying Data!

Former Member
0 Kudos

Hi Everyone!

I want modify the data which has been inserted using create Bapi wrapper.

The change Bapi wrapper which i have written for the same is perfectly working.

My problem is iam not able to modify the row in header which i have inserted earlier!

The Data is getting stored locally but not in the backend, which i could find out by querrying the local db2e.

My code goes like this,

public void inserUP()

{

descriptorFacade = SmartSyncRuntime.getInstance().getSyncBoDescriptorFacade();

sbd = descriptorFacade.getSyncBoDescriptor("ZUP");

dataFacade = SmartSyncRuntime.getInstance().getSyncBoDataFacade();

SyncBo syncbo = null;

try{

syncbo = dataFacade.createEmptySyncBo(sbd);

}

catch(Exception e)

{

}

Row row = syncbo.getTopRow();

RowDescriptor rowdes = sbd.getTopRowDescriptor();

FieldDescriptor fid = rowdes.getFieldDescriptor("USERID");

FieldDescriptor fid1 = rowdes.getFieldDescriptor("DESCRIPTION");

FieldDescriptor fid2 = rowdes.getFieldDescriptor("AGE");

try {

row.modifyFieldValue(fid,"Mohan" );

row.modifyFieldValue(fid1,"SE");

row.modifyFieldValue(fid2,"22");

syncbo.modifyRow(row);

} catch (Exception e) {

}

try {

dataFacade.insertSyncBo(syncbo);

}

catch (Exception e) {

}

SyncManager smgr = SyncManager.getInstance();

smgr.synchronizeWithBackend();

}

This is for insertion!!! It is working fine!

While modifying,,

i have written in similar way and used the method

syncbo.replaceRow(row);

It wasn't working!! I tried using the method "setHeaderFieldValue()" In SmartSyncDBAccess...

I'm not sure how to get the syncKey of the inserted row!

Please help me understanding this!

Thanking you in Advance,

Regards,

krishna.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi jo!

Thanks a lot! But i still have issues.

The changes i make while modifying the same record i inserted earlier are not reflecting in the backend.

In the trace file of my mobile client i could see the "update" being called for modification. I could see the data being updated into local DB2E but not to backend.

In the middleware i checked the Worklist monitor and found the following message in the Outbound Worklists data:

" Conflict : R/3 = modify , Device = modify "

After this the new modified data is being shown as zero for all fields,

I am not able to resolve this, please help me,

Thanks in Advance,

Regards,

krishna.

Former Member
0 Kudos

Hi Krishnamohan,

If every thing is working fine from Client view.

Then there must be some problem with you Modify Bapi.

Kindly check it.(Recommended to unit test your Modify-Bapiwrappers)

Kindly debug the bapi.

There you may find the solution

Thanks,

Karthick

Former Member
0 Kudos

hello krishna,

your insertion code is fine and you can use the same way

you modify the toprow to modify the field values.


//retrieve the inserted syncBo using the boDescriptor
//and the synckey value which is assigned when the SyncBo
//is inserted into the data facade.
SyncBo syncbo = dataFacade.getSyncBo(boDesc, syncKey);
Row row = syncbo.getTopRow();
RowDescriptor rowdes = sbd.getTopRowDescriptor();
FieldDescriptor fid = rowdes.getFieldDescriptor("USERID");
FieldDescriptor fid1 = rowdes.getFieldDescriptor("DESCRIPTION");
FieldDescriptor fid2 = rowdes.getFieldDescriptor("AGE");

try {
row.modifyFieldValue(fid,"New Field Value" );
row.modifyFieldValue(fid1,"New Fid1");
row.modifyFieldValue(fid2,"New Fid2");
syncbo.modifyRow(row);
} catch (Exception e) {
}

take note that you are trying to modify the toprow. the Row

instance assigned to a SyncBo instance as the top row

instance CAN'T be replaced!.

try catching the exception when calling the SyncBo.replaceRow

and you will get a ModificationNotAllowedException when

trying to replace the top row.

see <a href="https://media.sdn.sap.com/javadocs/NW04/SPS15/me/com/sap/ip/me/api/smartsync/SyncBo.html">SyncBo</a> for details.

hope this helps.

regards

jo