Output document list in a java service

Hi,

I have a document list within a document and I have to read from a table and populate the fields in the list. How do I define the IData and IDataCursor. What should be the heirarchy? I have no inputs and I do all selects withing the code itself.
The output is something like
Document
DocumentList
Field1
Field2
.
Fieldn

Rehan,

I think there are some useful examples in the WmSamples package in the sample.idata:readAndWriteDocumentList service.

In short here’s what you’ll do.

  1. Get a cursor on “Document” (let’s say idcDoc) []Use idcDoc.first(“DocumentList”) to move the cursor to the DocumentList key []Use IData myDocList = IDataUtil.getIDataArray(idcDoc,“DocumentList”) to get the value of the DocumentList []Use a for or while loop to loop over the elements in the DocumentList []Inside the loop get a cursor on each element (document) (let’s say idcListElement) []Perform whatever work you need to on that element []destroy your idcListElement cursor

HTH,

Mark

1 Like

Hi Mark,

Thanks for your inputs. Also thanks for pointing me to the sample package.
I have a little different requirement here. I do not have any inputs and I have to create output in form I described.
The data comes from a read of the table hence I do not know the size of the document list in advance so I am unable to define using
IData documentListOut = new IData[I don’t know this length];

Thanks,
Rehan

Using the Tools | Generate Code… selection from the menu will guide you through a wizard that will create the skeleton of code you need for the outputs.

As you don’t know how long the number of items are, you can use java.util.ArrayList or java.util.Vector to build up your results. Then convert them to an array when you’re done.

Another approach is to divide the reading of the data from the formatting. Use JDBC Adapter service(s) to select the data you need, then pass the results to the service that puts the data into the document format you need.

Are you sure you need to do this as a Java service? This type of operation is exactly what IS is designed for and can usually be easily accomplished without dropping to Java.

Hi,Can you provide me the code for same requirement as i am new to web methods.