cancel
Showing results for 
Search instead for 
Did you mean: 

how to insert the data using SyncoBo Object

Former Member
0 Kudos

Hi ,

please provide the code for inserting the data such tat my meRepMeta.xml

contains

one Top Row

&

4 Child Row

i done the coding for inserting top row

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Rajan ..,

I code wat u hav posted , it returns number of rows , but i need to query the data based on SYNC_KEY value which is present in all the top row and 2 child row

Example

Top Row

<b>Sync_Key 00000001</b>

Name Rajan

Specilaty IM

First Child Row

<b>Sync_Key 00000001</b>

Desgn PNP

Second Child Row

<b>Sync_Key 00000001</b>

Phone_No 012-234-0980

<u>

OutPut should be</u>

<b>Rajan IM PNP 012-234-0980</b>

Edited By Saravana

rajan_venkatachalam
Participant
0 Kudos

Hi Saravana,

I am not sure about the query based on sync_key value but i am suggesting the code snippet that you can use to get the SyncBo by the SyncBoName and SyncKey.

  public SyncBo getSyncBoInstance(String syncBoName, String syncKey) {
		SyncBoDescriptor sbd = descriptorFacade.getSyncBoDescriptor(syncBoName);
		try {
			SyncBo sb = dataFacade.getSyncBo(sbd, syncKey);
			return sb;
		} catch (PersistenceException pex) {
			System.out.println(pex.getMessage());
			return null;
		}
	}
 

Based on the SyncBo value from the previous code snippet , you can obtain the rowCollection thru this method.

public RowCollection[] getRows()
                        throws PersistenceException 

Ex:

sb.getRows()

Once you obtain the RowCollection for the particular syncBo,you can iterate thru rowCollection to get the row entities.

//To get the iterator of the Row entities in this RowCollection.
 MeIterator it = rowList.iterator();

From each row entity you can get the field values by this method

public MeIterator getFieldValues()

I would suggest you to go through the API Doc which is clearly explained about all the methods which would be useful for you to do all sort of operation.

Regards,

Rajan

Former Member
0 Kudos

Sarvan, you mean , you need the code from front-end-point of view. I mean from java point of view, to insert a row.

Regards,

Murthy

Former Member
0 Kudos

S , from front end java ,

i done the coding for inserting the data for top & child structure...

its creating the seperate file for each child & TOP Structure

Now the problem is i can retreive only top or child structure one at a time

......................

I need the coding [java] to retrieve both TOP & Child Structure

i done the coding its always returns blank value

SyncBoDescriptor sbd = descriptorFacade.getSyncBoDescriptor(syncBoName);

MeIterator iteratorRows = null;

System.out.println("Size ===" + sbd.getAllRowDescriptors().size());

SmartSyncQueryFactory queryFactory = SmartSyncRuntime.getInstance().getQueryFactory();

RowDescriptor rd = sbd.getTopRowDescriptor();

RowDescriptor rd1 = sbd.getRowDescriptor("030");

RowDescriptor rd2 = sbd.getRowDescriptor("170");

FieldDescriptor fd = rd.getFieldDescriptor(THNames[sortIndex]);

FieldDescriptor fd1 = rd1.getKeyFieldDescriptor();

FieldDescriptor fd2 = rd2.getKeyFieldDescriptor();

Condition cond1 = queryFactory.createCondition(fd, RelationalOperatorType.GREATER_THAN, "0");

Condition cond2 = queryFactory.createCondition(fd1, RelationalOperatorType.GREATER_THAN, "0"); Condition cond3 = queryFactory.createCondition(fd2, RelationalOperatorType.GREATER_THAN, "0");

Condition cond = queryFactory.createCondition(new Condition[]{cond1, cond2,cond3},LogicalOperatorType.AND);

SortOrder singleSortOrder = queryFactory.createSortOrder(fd, sortOrder);

Query rowQuery = queryFactory.createQuery(sbd,cond,singleSortOrder, start, count);

iteratorRows = dataFacade.getRows(rowQuery).iterator();

return iteratorRows;

rajan_venkatachalam
Participant
0 Kudos

Hi Saravana,

Here is the code snippet to confirm that wheather you are able to get all Syncbos both(header and item) available on the client or not.

SyncBoDescriptor sbd =descriptorFacade.getSyncBoDescriptor(syncBoName)

MeIterator iteratorRows = null;

iteratorRows = dataFacade.getSyncBos(sbd).iterator();

return iteratorRows;

Let me know wheather you are able to get all syncbos available on the client.For Java API doc refer to <a href="https://help.sap.com/javadocs/NW04/current/me/index.html">this</a>

Former Member
0 Kudos

hi sara,

you are using the API incorrectly. the field descriptor to which you specify in the

condition should belong to the row descriptor of the items or top rows which you

are trying to retrieve. oneway to retrieve what you want it use the simple query apis

to query for the synbos having such synckey and then query for rows having the

field that matches the parent's synckey.

so your code should be something like:


 :
 :
RowDescriptor rd = sbd.getTopRowDescriptor();
RowDescriptor rd1 = sbd.getRowDescriptor("030");
RowDescriptor rd2 = sbd.getRowDescriptor("170");
 
FieldDescriptor fd =  rd.getFieldDescriptor(THNames[sortIndex]);	
FieldDescriptor fd1 = rd1.getKeyFieldDescriptor();
FieldDescriptor fd2 = rd2.getKeyFieldDescriptor();
 
Condition boCond= queryFactory.createCondition(fd,RelationalOperatorType.GREATER_THAN, "0");
Condition itm030Cond= queryFactory.createCondition(fd1,RelationalOperatorType.GREATER_THAN, "0");
Condition itm170Cond= queryFactory.createCondition(fd2,RelationalOperatorType.GREATER_THAN, "0");

topRows = queryRows(rd,boCond,sortOrder, start, count);
itm030Rows = queryRows(rd1,itm030Cond,sortOrder, start, count);
itm170Rows = queryRows(rd2,itm170Cond,sortOrder, start, count);
//you can then loop into each iterators and put them inside an array or collection.
//Row[] allRows 
//Vector allRows

}

MeIterator queryRows(RowDescriptor rd, Condition cond, SortOrder, int start, int cout){
 return queryFactory.createQuery(rd,cond,sortOrder, start, count);
}

the other way is to use the JQuery which is the join query. however this requires

more understanding of the object fields. please refer to the javadocs for details.

regards

jo

Former Member
0 Kudos

Hello,

You don't actually add it yourself. You export it from the middleware. You have to go to merep_sbuilder. From the menu Go To chose Download Meta data XML. Then chose the MCD you want to generate the XML for (creat the MCD in MI_MCD). Whatever you modeled in sbuilder will be exported as a xml.

Thank you,

Julien.