IBM Support

Array not updated in BPEL snippet in a For Each loop

Troubleshooting


Problem

A BPEL snippet in a For Each loop is trying to update an array variable but the array is not being updated after the first loop iteration.

Symptom

The output of a For Each loop should be an array of elements, but the array only contains one element.

Cause

The same BPEL variable is being added in each loop iteration.

Diagnosing The Problem

To determine if your BPEL program is affected by this limitation compare it to the following sample. This is a For Each loop that iterates over an array of customers in the input and generates an array of events for output.

The activity Assign CustomerInfo to eventRequest assigns some information to the BPEL variable eventRequest. Then the activity Add eventRequest to ArrayList adds this BPEL variable to an array in another BPEL variable called sendEventRequest in the snippet:


In the first iteration of the loop BPEL creates an instance of eventRequest and it is added to the list normally. Subsequent iterations update the same instance of this variable and when the snippet attempts to add it to the list the attempt fails. There are no warning messages except for the output message seen in the snippet above.

Resolving The Problem

To resolve this problem you must create a new instance of the BPEL variable eventRequest for each iteration of the loop. In the snippet activity Create SendEvent Entities we create all the new variables we need. Highlighted is the variable described in this article.

[{"Product":{"code":"SSQQFK","label":"WebSphere Integration Developer"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Business Process Editor","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.0.0.4;7.0.0.3;7.0.0.2;7.0.0.1;7.0","Edition":"All Editions","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21517118