on 10-23-2007 12:42 PM
Hi, i´m doing a smart project and i need only one row, how can obtain it?
The row i want obtain it from an attribute.
Thanks,
Sorry, i hven´t the sync Key... how can obtain a row, with an attribute that it isn´t the sync key.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Victor,
well, if you do not have the sync key, two possible ways:
A.) Create a query - look int the MDK, this example is really good
B) You have the list of BOs. The listengs above give you the list of BOs if you want them. Make an iteration over that list and do a simple IF.... then.... statement. This is the easiest way to develop it!
Regards,
Oliver
Finally i do it with this method:
public Vector getFile(MeIterator syncBos, int fromIndex, int count, String id) {
// We want usually all items in the MEIterator because the SmartSync API already delivered
// the correct part of items we want to display.
// the fromIndex and count variable are only there in case we need a single entry.
Vector retVec = new Vector();
int i = 0;
if (syncBos != null) {
syncBos.reset();
// Fill table header with Field Names of Top Row
while (syncBos.hasNext()) {
/* SyncBo sb = (SyncBo) syncBos.next();
if (i >= fromIndex) {
Vector rowData = new Vector();
for (int col = 0; col < getColumns(); col++) {
rowData.addElement(getHeaderFieldValue(sb, tableHeaderNames[col]));
}
retVec.addElement(rowData);
} */
Row row = (Row) syncBos.next();
if (i >= fromIndex) {
Vector rowData = new Vector();
if ((getHeaderFieldValue(row, tableHeaderNames[1])).equals(id)) {
for (int col = 0; col < getColumns(); col++) {
rowData.addElement(getHeaderFieldValue(row, tableHeaderNames[col]));
}
retVec.addElement(rowData);
}
}
i++;
// return when count has been reached, when count is greater 0.
// if count less 0 we get all records.
if (count > 0) {
if (i >= (fromIndex + count))
return retVec;
}
}
}
return retVec;
}
Thanks,
Solve it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Victor,
you can either use the KEY of the row and access it directly as written above.
Or get the complete list and iteate through it - mentioned above as well.
Or you write a Query and select this item with the Query. This is explained in the MDK and really easy - well, a few lines of code are necessary.
The question is here: what information do you have about the row? While you have the key, number 1 is the simplest option.
If you can not really select it with a query, then option two is the best one, even it is a little time consuming on a PDA - but as long as the dataset is not too big it should be ok.
Hope this helps you to come a step forward.
Regard,s
Oliver
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don´t understand... I have the key and i have the method getSyncBoInstance, and this method for obtain the SyncBO, but i don´t know how can obtain the row...
public void getDataArrayFila(String id) {
RowCollection[] rows = (dbAccess.getSyncBoInstance(currentSync, id)).getRows();
MeIterator ri = rows.iterator();
return;
}
I can´t use MeIterator ri = rows.iterator(); because is a Collection...
Thanks,
Message was edited by:
Victor Capi
Hi Victor,
this I do not understand. You say you have the key - but you want to go via the iteration?
Well, if you really have the key, I think this is your code:
SyncBo sb = dataFacade.getSyncBo(sbd, syncKey);
Or is it: you have the TOP row already with its key and now you want to get all the items for that SyncBO?
Regards,
Oliver
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;
}
}
public void getDataArrayFila(String id) {
RowCollection rc = dbAccess.getSyncBoInstance(currentSync, id).getRows();
Row row = rc.get(id);
}
Exception in rc --> Type mismatch: cannot convert from RowCollection[] to RwoCollection.
Hi Victor,
Okay can you please add the try and catch block in this method getDataArrayFila(String id) like this
try {
SyncBo sc = dbAccess.getSyncBoInstance(currentSync, id);
RowCollection rc = sc.getRows();
Row row = rc.get(id);
} catch (PersistenceException pex) {
System.out.println(pex.getMessage());
return null;
}
Regards,
Rajan
Hi Victor,
Yes thats right,i forgot the argument.
A RowDescriptor instance describes the metadata definition for a Row object. It provides access to the following:
*Row name; ("TOP" represents the top row)
*FieldDescriptor of the key field
*Specific FieldDescriptor instance belonging to this RowDescriptor instance
*All FieldDescriptor instances belonging to this RowDescriptor
*All RelationDescriptor instances which are relating to this RowDescriptor
*SyncBoDescriptor instance which this RowDescriptor is member of
You can obtain RowDescriptor from the SyncBoDescriptior as per the last point mentioned above.
SyncBoDescriptor sbd = descriptorFacade.getSyncBoDescriptor(syncBoName);
RowDescriptor rd = sbd.getTopRowDescriptor();
You can pass this argument in the getRows() method to obtaing RowCollection.
Thanks and Regards,
Rajan
Hi, finally i write:
public void getDataArrayFila(String id) {
try {
SyncBo sc = dbAccess.getSyncBoInstance(currentSync, id);
SyncBoDescriptor sbd = dbAccess.getSyncBoDescriptor(currentSync, id);
RowDescriptor rd = sbd.getTopRowDescriptor();
RowCollection rc = sc.getRows(rd);
Row row = rc.get(id);
} catch (PersistenceException pex) {
System.out.println(pex.getMessage());
}
}
I think that work, but... how can show this row... and the attributes.
Thanks,
Message was edited by:
Victor Capi
Message was edited by:
Victor Capi
The previous method is called:
public void loadBeanFila(String id) {
// Set headerpanel
// The left side displays the MI icon, that canbe clicked to go back to the MI home page
<b>tableViewDefinition.setHeaderPanelEntryLeft("<a href=\"http://127.0.0.1:4444/me\" > <img src=\"mimes/milogo.gif\" alt=\"MI Home\" ></a>");</b>
// The right side displays the text MDK
<b>tableViewDefinition.setHeaderPanelEntryRight("MDK");</b>
// Setup Commands for this example. Commands are displayed on the top of the centerpage.
// In this example we use add, delete, filter and list all commands.
<b>setCommands();</b>
// Set footerpanel
// The left side displays the application name
<b>tableViewDefinition.setFooterPanelEntryLeft(current_filter_string);</b>
// The right side displays the type of the example
<b>tableViewDefinition.setFooterPanelEntryRight(currentPageFooter);</b>
// set commands for application - the commands have been set in the initialize method already
<b>tableViewDefinition.setCommandLine(commandLine)</b>;
// set title of the center window
<b>tableViewDefinition.setCenterPageTitle(pageTitle);</b>
// Generate table header
<b>setTableHeader();</b>
// Generate data and set Vector in bean
<b>dataHandler.getDataArrayFila(id);</b>
// The following variables are necessary for the navigation
<b>dataHandler.setTableRows(MAX_TABLE_ROWS);</b>
<b>dataHandler.setTableColumns(dataHandler.getColumns());</b>
d<b>ataHandler.setRowsInDataset(dataHandler.getRowsInDataset());</b>
<b>dataHandler.setCurrentIndex(start_index);</b>
}
Thanks,
Message was edited by:
Victor Capi
Hi Victor,
I am not sure how far this info is going to help you ,however you can consider
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();
I would suggest you to go through the <a href="https://help.sap.com/javadocs/NW04/current/me/index.html">API</a> Doc which is clearly explained about all the methods which would be useful for you to do all sort of operation.
Thanks and Regards,
Rajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.