Skip to Content
0
Former Member
Dec 12, 2006 at 04:10 PM

Can not create ITEM

22 Views

Hi ! I need to create a syncbo instance from the clinet.This syncbi contains 1

item row ("010"). I need to insert data in both the header and item rows.But When I use the following code,Only the header record is created.The item record is not persisted. Plese explain me.

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

SyncBoDataFacade dataFacade = SmartSyncRuntime.getInstanc().getSyncBoDataFacade();

SyncBoDescriptor sbd = descriptorFacade.getSyncBoDescriptor("Z_SYNCBO");

SyncBo syncbo = null;

try{

syncbo = dataFacade.createEmptySyncBo(sbd);

}

catch(Exception e)

{}

Row headerRow = syncbo.getTopRow();

RowDescriptor rowdes = sbd.getTopRowDescriptor();

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

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

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

SmartSyncTransactionManager transactionManager =null;

try{

transactionManager = dataFacade.getSmartSyncTransactionManager();

if (!transactionManager.isTransactionStarted())

transactionManager.beginTransaction();

}

catch(Exception e ){

Log.log(Severities.DEBUG,"transaction manager failed"+e.toString());

}

try {

row.modifyFieldValue(fid, "VEERA");

row.modifyFieldValue(fid1,"AU");

row.modifyFieldValue(fid2,"12");

syncbo.modifyRow(row);

Log.log(Severities.DEBUG,"header inserted");

}

catch (Exception e) {

Log.log(Severities.DEBUG,"error2"+e.getMessage());

}

RowDescriptor itemRow = sbd.getRowDescriptor("010");

Row item = null;

try{

item =syncbo.createEmptyRow(itemRow);

}

catch(Exception e)

{

}

FieldDescriptor ifd1 = itemRow.getFieldDescriptor("FIELD1");

FieldDescriptor ifd2 = itemRow.getFieldDescriptor("ITEM_FIELD2");

FieldDescriptor ifd3 = itemRow.getFieldDescriptor("ITEM_FIELD3");

try{

item.modifyFieldValue(ifd1,"VEERA");

item.modifyFieldValue(ifd2,"0010");

item.modifyFieldValue(ifd3,"33");

syncbo.modifyRow(item);

Log.log(Severities.DEBUG,"item inserted");

dataFacade.insertSyncBo(syncbo);

Log.log(Severities.DEBUG,"success in inserting syncbo");

}

catch(Exception e)

{

Log.log(Severities.DEBUG,"error4"+e.toString());

}

try{

transactionManager.commit();

}

catch(Exception e )

{

}

I am able to see the message "item inserted" in the trace file. The above code compiles without any errors.But The data is not persisted for the item.

Am I missing anything.

Please do help me in this

Thanks in Advacnce

Veera.