AnsweredAssumed Answered

How to get the sum/total of a repeating array element

Question asked by amudhavani.shanthosh181426 on Jul 26, 2018
Latest reply on Aug 1, 2018 by amudhavani.shanthosh181426

Hi,

 

Below is the sample. The elements "Condiments" and "MenuItem" are repeating array elements. I need to get the total of "MiOverridePrice" from both "Condiments" and "MenuItem".

 

1. I tried the numeric functions like sum, running total for "Condiments" and "MenuItem" individually and then thought of getting these two totals added up to get the full total. But it is not getting iterated over the array elements, and picking up only the first value21.3800 for the Menu item, where I was expecting the total to be 23.37 ( 21.3800 + 1.9900)

2. Also, This XML is mapped to a Flat file profile, and then a data process shape to combine the documents. This give single document as output. But when this output is passed to "Flat file to JSON" map, I am getting two documents, because of the steps that I have tried in 1. 

 

Can you please help to solve this. Thanks. 

 

<ppMenuItems>
<SimphonyPosApi_MenuItem>
<Condiments>
<SimphonyPosApi_MenuItemDefinition>@
<MiObjectNum>102001012</MiObjectNum>
<MiOverridePrice>10</MiOverridePrice>
<MiReference>&lt;ExtraData&gt;&lt;MiQuantity&gt;3&lt;/MiQuantity&gt;&lt;/ExtraData&gt;</MiReference>
<MiMenuLevel>0</MiMenuLevel>
<MiSubLevel>0</MiSubLevel>
<MiPriveLevel>1</MiPriveLevel>
</SimphonyPosApi_MenuItemDefinition>
</Condiments>
<MenuItem>
<MiObjectNum>101000001</MiObjectNum>
<MiOverridePrice>21.3800</MiOverridePrice>
<MiReference/>
<MiMenuLevel>0</MiMenuLevel>
<MiSubLevel>0</MiSubLevel>
<MiPriveLevel>1</MiPriveLevel>
</MenuItem>
</SimphonyPosApi_MenuItem>
<SimphonyPosApi_MenuItem>
<MenuItem>
<MiObjectNum>101000002</MiObjectNum>
<MiOverridePrice>1.9900</MiOverridePrice>
<MiReference/>
<MiMenuLevel>0</MiMenuLevel>
<MiSubLevel>0</MiSubLevel>
<MiPriveLevel>1</MiPriveLevel>
</MenuItem>
</SimphonyPosApi_MenuItem>
</ppMenuItems>

Outcomes