I solved the counting of detail lines this way:
rule "Contador de lineas detalle vs Header"  salience 10  when       
Number($count : intValue) from accumulate(              $mp : 
Map(this["_TYPE_"] == "D"), count($mp))       $map : Map(this["_TYPE_"] == "H", 
                 this["NU_REGISTROS"] != $count)  then    
System.out.println("NumRecs=" + $count);    listBitacora.add(new 
BitacoraDTO($map.get("_NUMLINE_"),                                          "El 
número del lineas de detalle (" + $count +                                      
    ") no empareja con lo del encabezado (" + $map.get("NU_REGISTROS") + ")")); 
end
However, I still got problem with summarize the amounts. I wrote
rule "Sumatoria de lineas detalle vs Header"  salience 10  when       Number( 
$total : doubleValue) from accumulate(               Map(this["_TYPE_"] == "D", 
              $monto : ((Number) this["MONTO"]),               sum($monto)))    
   $map : Map(this["_TYPE_"] == "H",                  this["MT_TOTAL"] != 
$total)  then    System.out.println("TOTAL=" + $total);    listBitacora.add(new 
BitacoraDTO($map.get("_NUMLINE_"),                                          
"Error en el Detalle: El número del lineas de detalle (" +  $total +            
                              ") no empareja con lo del encabezado (" + 
$map.get("NU_REGISTROS") + ")")); end
And i am getting  mismatched input" so my question is how to convert a string 
to double in this line "$monto : ((Number) this["MONTO"])," ?
TIA
Yamil
From: yamilbra...@hotmail.com
To: rules-users@lists.jboss.org
Date: Tue, 9 Mar 2010 17:41:43 +0000
Subject: [rules-users] Problems count and sumarizing data in facts








Hi, I have two kind of facts in a map.There is a field called _TYPE_ (H)eader, 
D)etail)In the Header line I have two String fields, one for the number of 
details lines ("NU_REGISTROS") and another for the sum of the detail line 
("MT_TOTAL")In the detail lines I only have a String field called "MONTO" 
I would like to build two rules. One to check the count of detail lines versus 
the field in the header line so I wrote :
rule "Contador de lineas detalle vs Header"  salience 10  when       $numRecs : 
Number()                from accumulate(Map(this["_TYPE_"] == "D", $d : 
this["_NUMLINE_"]), count($d))       $map : Map(this["_TYPE_"] == "H",          
        this["NU_REGISTROS"] != $numRecs)  then    
System.out.println("NumRecs=" + $numRecs);    listBitacora.add(new 
BitacoraDTO($map.get("_NUMLINE_"),                                          
"Error en el Detalle: El número del lineas de detalle (" +  $total +            
                              ") no empareja con lo del encabezado (" + 
$map.get("NU_REGISTROS") + ")")); end  However I always got "NumRecs=1" when i 
print out the value of $numRecs but I am absolute sure there is two details 
lines...  Second when i try to sumarize the total field in the details line i 
got (MONTO in the detail line is a string):  rule "Sumatoria de lineas detalle 
vs Header"  salience 10  when       $total : Number()                from 
accumulate(Map(this["_TYPE_"] == "D",                                $monto : 
this["MONTO"]),                                sum(eval(Double.valueOf((String) 
$monto ))))       $map : Map(this["_TYPE_"] == "H",                  
this["MT_TOTAL"] != $total)  then    System.out.println("TOTAL=" + $total);    
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),                         
                 "Error en el Detalle: El número del lineas de detalle (" +  
$total +                                          ") no empareja con lo del 
encabezado (" + $map.get("NU_REGISTROS") + ")")); end  but I got Rule 
Compilation error : [Rule name='Sumatoria de lineas detalle vs Header']        
rule/Rule_Sumatoria_de_lineas_detalle_vs_Header_0.java (9:1313) : The method 
eval(Double) is undefined for the type 
Rule_Sumatoria_de_lineas_detalle_vs_Header_0

  Any help in those tow problems  TIA
Yamil                                     
Actualízate gratis al nuevo Internet Explorer 8 y navega más seguro             
                          
_________________________________________________________________
¿Quieres saber qué PC eres? ¡Descúbrelo aquí!
http://www.quepceres.com/
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to