Reputation:
I want to map an array which in WebMethods is a document list. I thought that you could just map that variable over without mapping all of the children. I have done this and nothing shows in the PassArea. (PassArea is the data array that is being sent to a mainframe program afterwards.)
A --> B
Field1 F1
Field2 F2
field3 F3
The document is A and the input document into the Natural program is B. The --> is the link that connects them together.
I don't have an image to show, because that would reveal some company information.
Upvotes: 3
Views: 11486
Reputation: 398
There's a lot ways to map between arrays of documents. But before you create one, consider these writings:
As hint from #2 said that there's 6 ways they ranked as follows from fastest to slowest (but I'm going to give an example in first three, because the latter three is quite obviously slow, which considered to be avoided):
public static final void mappingDocuments(IData pipeline) throws ServiceException {
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
// Instantiate input A
IData[] A = IDataUtil.getIDataArray(pipelineCursor, "A");
// Initiate output B
IData[] B = new IData[A.length];
if (A != null)
{
for (int i = 0; i < A.length; i++)
{
// Populate the Field in doc A
IDataCursor ACursor = A[i].getCursor();
String Field1 = IDataUtil.getString(ACursor, "Field1");
String Field2 = IDataUtil.getString(ACursor, "Field2");
String Field3 = IDataUtil.getString(ACursor, "Field3");
ACursor.destroy();
// Create IData[i] and cursors finally put all Fields into B[i] variable output
B[i] = IDataFactory.create();
IDataCursor BCursor = B[i].getCursor();
IDataUtil.put(BCursor, "F1", Field1);
IDataUtil.put(BCursor, "F2", Field2);
IDataUtil.put(BCursor, "F3", Field3);
BCursor.destroy();
// OR JUST USE CLONE BELOW IF YOU DON'T HAVE ANY MODIFICATION INSIDE THE VARIABLE
// B[i] = IDataUtil.clone(A[i]);
}
}
pipelineCursor.destroy();
// Finally to put the B Map(IData) to output.
// Actually you can use only single pipelineCursor throughout all code but it's just for readable
IDataUtil.put(pipelineCursor, "B", B);
pipelineCursor.destroy();
}
Hope these helps...
Upvotes: 1
Reputation: 4278
If the fields of document list "A" has different names than the fields of document list "B" then no, you cannot map document list "A" to document list "B". WebMethods doesn't know which field from A corresponds to what field from "B".
You will have to do the following:
Step #2 screenshot
Step #3 screenshot
Upvotes: 7