3

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.

Christian Strempfer
  • 7,291
  • 6
  • 50
  • 75
  • I will see about putting up a screen shot. list document to another list document. But I found that you cannot just map each field that you have to map the document list which then maps all of the instances in the fields. –  Aug 29 '14 at 14:45

2 Answers2

7

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:

  1. LOOP over document list "A"
  2. Map each field of "A" to a generic document containing the same fields as document list "B"
  3. Append the generic document to document list "B"
  4. Drop the generic document.

Step #2 screenshot

Step #2 screenshot

Step #3 screenshot

Step #3 screenshot

TchiYuan
  • 4,258
  • 5
  • 28
  • 35
0

There's a lot ways to map between arrays of documents. But before you create one, consider these writings:

  1. Techcommunity SoftwareAG - performance impact with appendToDocumentList
  2. quest4apps.com - Reason to avoid appendToDocumentList

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):

1. Java Loop: looping done through a Java service.

  • The easiest way to create java service is to map the input output first. input output doc
  • Right-click and click on "Generate Code" until the dialog box appears Generate code for Implementing Service Choose the option "For implementing this service" Generated service And the service is created
  • Just re-arrange the code into this:
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();
        
}
  • Result resultJavaService

2. Implicit Loop: for simple lists of the same size, you may want to link them directly in a MAP step

  • Create flow service and input & output document
  • Create MAP step
  • Select both document in ForEach loop. ForEach

3. Explicit Loop: using a LOOP step and its Output Array.

  • Create flow service and input & output document
  • Create LOOP step
  • Change the properties of LOOP, input array=A; output array=B; and create a map under LOOP step LoopProperties
  • Map all parameters in A to B MapAtoB

Hope these helps...

Community
  • 1
  • 1
Ivan Herlambang
  • 368
  • 2
  • 8