cancel
Showing results for 
Search instead for 
Did you mean: 

Can not create ITEM

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

kishorg
Advisor
Advisor
0 Kudos

Hi Veera,

The code you have pasted here for inserting the item wont work since you are not explicitly inserting the ITEM, instead you are modifying.

<<

syncbo = dataFacade.createEmptySyncBo(sbd);

>>

We cannot create header instance(TOP) for one syncbo since it is automatically creating the header instance with the above statement itself.

<<

Row headerRow = syncbo.getTopRow();

>>

retrieving the TOP row. On this obect, we are doing modifications and finally inserting the data on the persistence.

Inorder to insert the item data, you can code like this...

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

Row item = null;

item = syncbo.createEmptyRow(itemRow);

.

..

.

<b>instead of syncbo.modifyRow(item);

try

syncbo.insertRow(item);</b>

dataFacade.insertSyncBo(syncbo);

//Commit the transaction

transactionManager.commit();

Just refer these forum also. I have pasted code templates for creating instances in this forum.. try it out..

refer these links also,,

Let me know , whats the outcome is !!!

Regards,

Kishor Gopinathan

Former Member
0 Kudos

Hi Kishor,

Thank you very much for your help.

As you have mentioned

instead of syncbo.modifyRow(item); I used syncbo.insertRow(item); Now the problem is solved.I am able to create an item row and it is persisted to the local DB and to the backend after synchronization.

Thank you once again,

Veera

Answers (0)