INEDIFACT V96A DESADV: appendToDocumentList - Transformers cannot loop over list elements

How to output my data into the result below:
LIN+1++123456:EN::9’
PIA+1+654321:IN::92’
PIA+1+987654:SA::92’

when I debug the result, it show me this error:
com.wm.app.b2b.server.ServiceException: java.lang.RuntimeException: [ISC.0049.9027] Error at pub.list:appendToDocumentList - Transformers cannot loop over list elements

The failure seems to occur because the immediate parent DocType “LIN” is a Document List.

  • If “LIN” will ALWAYS have one array element (i.e., 0th record only) at runtime, then indicate that explicitly in your PIA → toList map, by using the “index” property (click on the map link and you’ll see it on the Property tab at top-right corner)
  • Else, if “LIN” will also be a Document List at runtime, you will have to Loop over “LIN” and collate the “PIA” lists

On the other side, it may also be due to the “PIA” list under “fromItem” in your transformer. You’ll have to indicate the index, but I’d recommend changing “PIA” under “fromItem” to a Document instead of a Document List.

P.S - I don’t see the need for a transformer here; call the service directly as a flow step instead

KM

2 Likes

PIA is a document list and hence you cannot “implicitly” loop if using transformers. You need to embed your map step in a LOOP step, specify the in attribute to …/CPS/LIN/PIA.

You will need to remap the attributes from left to right.
regards,
John.

Your mean is:
First LOOP is
LOOP over ‘/DESADV_OUT_LIN’
input array: /DESADV_OUT_LINE
output array: /TDESADVDT/UNH/CPS

Second LOOP is:
LOOP over ‘/DESADV_OUT_LIN’
input array: /DESADV_OUT_LINE
output array: /TDESADVDT/UNH/CPS/LIN/PIA

I try it, it is not work!

Hi Emerson,

specifying an output array on LOOP step will only work when the resulting list does have exactly the same number of entries as list specified as input array.

I partially agree with Kasi that calling appendToList as a transformer is not needed here.
Remember to drop the fromItem after the invocation before entering the next iteration of the loop otherwise you will encounter a mix up of data between the entries.
But I would suggest to use cascaded loops here (inside the loop for /DESADV_OUT_LINE):

  • Outer Loop for LIN
  • Inner Loop for PIA

Additionally you might need to use temp lists during the loops to avoid duplication of entries while appending.
When one loop completes map the resulting temp list back to the list in the document structure while replacing the original list and drop the temp list afterwards. Otherwise you will have the incoming list extended by the same, now enriched, entries.

Can you share some samples of the documents prior entering the loop and what they should look like after the transformation?

Regards,
Holger

If input and output lists are of the same size and you are on a resonable up to date version of webMethods (I do not remember exactly when this was introduced), you can even use implicit loops (foreach) inside one map step (can even be nested), which imho is much better to read than having a loop first and then a map inside the loop (there are some usecases though where this is the better approach):

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.