<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><br><span></span></div><div><span>I'm assuming that </span>c6066 is really a number and not a string....if not you will need to change this to parse the string into a number.</div><div><br></div><div>I think something like this should do it.&nbsp; You first get the list from a SegmentGroup8 then sum the values you need. This is untested code.<br></div><div><br><span></span></div><div><span>$seg: </span><span>SegmentGroup8()</span></div><div><span><br></span></div><div><span>$sum: Number() from accumulate( $cntTotal: ControlTotal() from $seg.</span>getCnt(), sum($<span>cntTotal.</span>getC6066<span>()))</span></div><div><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><font face="Arial" size="2"><hr size="1"><b><span
 style="font-weight:bold;">From:</span></b> pamerida &lt;elpamm@hotmail.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> rules-users@lists.jboss.org<br><b><span style="font-weight: bold;">Sent:</span></b> Tuesday, September 20, 2011 5:35 PM<br><b><span style="font-weight: bold;">Subject:</span></b> [rules-users] accumulate function<br></font><br>Hi everyone, <br><br>I have this scenario:<br>I have assserted a few elements of the type "SegmentGroup8" into the working<br>memory, this SegmentGroup8 class have inside a list called private<br>List&lt;ControlTotal&gt; cnt;<br><br>What I need to achieve is to perform a "sum" of one of the fields called<br>c6066 inside the ControlTotal for all the SegmentGroup8 asserted into the<br>WM...<br><br>I would like to use the accumulate functions but I really dont know how, any<br>help would be appreciated, thanks in advance...<br><br>the classes code is the following...<br><br><br>public class
 SegmentGroup8<br>&nbsp; &nbsp; implements Serializable<br>{<br> <br>&nbsp; &nbsp; private List&lt;ControlTotal&gt; cnt;<br>&nbsp; &nbsp; private List&lt;MonetaryAmount&gt; moa;<br> <br>public List&lt;ControlTotal&gt; getCnt() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return cnt;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; public void setCnt(List&lt;ControlTotal&gt; cnt) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.cnt = cnt;<br>&nbsp;&nbsp;&nbsp; }<br><br>......<br>}<br><br><br><br>public class ControlTotal extends Segment<br>&nbsp; &nbsp; implements Serializable<br>{<br><br>&nbsp; &nbsp; private String c6069;<br>&nbsp; &nbsp; private String c6066;<br>&nbsp; &nbsp; <br> ........<br><br>&nbsp;&nbsp;&nbsp; public String getC6069() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return c6069;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; public void setC6069(String c6069) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.c6069 =
 c6069;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; public String getC6066() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return c6066;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; public void setC6066(String c6066) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.c6066 = c6066;<br>&nbsp;&nbsp;&nbsp; }<br><br>.........<br>}<br><br><br><br><br><br>--<br>View this message in context: <a href="http://drools.46999.n3.nabble.com/accumulate-function-tp3353507p3353507.html" target="_blank">http://drools.46999.n3.nabble.com/accumulate-function-tp3353507p3353507.html</a><br>Sent from the Drools: User forum mailing list archive at Nabble.com.<br>_______________________________________________<br>rules-users mailing list<br><a ymailto="mailto:rules-users@lists.jboss.org" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br><br></div></div></div></body></html>