Loop and addition Urgent

Hi all,
I appreciate your immediate response.

I need to calculate total quantity that I can get using pub.math:addFloats. But it looks like I cannot use this transformer service in a loop. Are there any alternate ways to do this. PLEASE reply asap.

Regards,
Roger

Hello,

Yemi Bedu

Yemi Bedu,
Thanks for the reply.
Yes, that is what I started doing. But I get an error ‘cannot loop over list elements’ when I try to do that. Please adivse.

Regards,
Roger

Check if the LOOP statement has a typo. Maybe the FLOW editor has lost its mind. If your map statement doesn’t show the list as a single element, then the LOOP is not correct. You may have to redo it from scratch.

Before using addFloats you may want to review http://www.wmusers.com/ezine/2002oct1_reamon_1.shtml to see if using addFloats is what you really want to do.

Roger,

I problem could be when you use any transformer especially mapping from stringlist or recordlist after you map to the input of the transformer set index=0 for the element.

And if use transformer inside the loop try to invoke the service addFloats instead of a transformer invoke.

This way you can get rid of this problem “transformer cannot loop over list elements”. i have faced this situation few times before and wmusers have a great discussion on this.

HTH
RMG

Here’s the explanation from the 6.1 Developer User’s guide:

Transformers and Array Variables
When creating links between pipeline variables and transformers, differences in dimensionality for the source and target variables may cause an exception. If the dimensionality of the target variable is greater than the dimensionality of the source variable, an exception will not be thrown. However, if the dimension of the source variable is greater than the dimension of the target variable, an exception will occur.

What Is Dimensionality?

Dimensionality refers to the number of arrays to which a variable belongs. For example, the dimensionality of a single String is 0, that of a single String list or document list is 1, and that of a single String table is 2. A String that is a child of a document list has a
dimensionality of 1. A String list that is a child of a document list has a dimensionality of 2.

Solution
To solve this, you can either:
Change the service invoked by the transformer to accept arrays as data, or Create a flow service in which a LOOP step loops over the array variable. Then, (in the same flow service) invoke the service you originally wanted to use as a transformer, and make that INVOKE step a child of the LOOP. Finally, insert the resulting flow service as a transformer in the MAP.

Of the two options, changing the service to accept arrays as data results in faster execution of flow services.

Roger, can you post a screen shot of the map statement within your loop with the doc list and transformer expanded? Attached is a package with a single service that does what you’re trying to do.

LoopSample
LoopSample.zip (4.2 k)

Thank you all for your immediate response. I sincerely appreciate it.

As Rob and RMG suggested, I made sure my loop statement was on a single record. I basically deleted the loop and map and re-created it. It fixed my problem.

Tim, thanks for your explanation on transformers and array variables.

Roger