Wednesday, November 10, 2010

Working with array in Oracle BPEL

This is an extension usage of array based from my previous post.

In the following example the variable Variable_whileLoopIteration is the iteration counter in the WHILE activity.

Reading from a specific element in an array:
<assign name="Extract_ProductName">
<copy>
<from expression="bpws:getVariableData('Variable_PurchaseOrder',concat('/ns1:purchaseOrder/ns1:items/ns1:item[',bpws:getVariableData('Variable_whileLoopIteration'),']/ns1:productName'))"/>
<to variable="Variable_productName"/>
</copy>
</assign>
Writing to a specific element in an array:
<assign name="Assign_NewProductNameToPO">
<copy>
<from expression="'NewProductName'"/>
<to variable="Variable_PurchaseOrder" query="/ns1:purchaseOrder/ns1:items/ns1:item[position() = bpws:getVariableData('Variable_whileLoopIteration')]/ns1:productName"/>
</copy>
</assign>

My advise is don't rely on JDeveloper Design view alone. Most of the time you have to manually edit the source to get it to do exactly what you want.