No, you can't retract the fact like that, for several reasons. Why would
you want to do that?

    If you are using the SLS_SLES_DTLS for this rule, and you don't want to
keep them in memory for other rules, you can use  "from" to pull them
on-demand. Another option is that you can write another rule that retract
your facts, with a lower salience, but you will have to use lock-on-active
to avoid the accumulate rule being re-activated after the retraction of your
facts.

    One more comment, not related to your question, but I think it is a good
example. Most people don't know that accumulate functions can take
expressions as the parameter. So, instead of using a custom accumulate code
like you have in your rule, would be simpler to just use the sum()
accumulate function with an expression. Using java dialect as it seems you
are, it would be:

    brand_total:Number(doubleValue >=1500)
        from accumulate ( sa:SLS_SALES_DTLS( PK!=null,
PK.ITEM_ID.BRAND_CD.BRAND_CD=="N00" ) ,
                                   sum( sa.getTRN_QTY()*
sa.getPK().getITEM_ID().getSALES_TO_BASE_CONV() ) )

     With MVEL, it would be a bit cleaner:

    brand_total:Number(doubleValue >=1500)
        from accumulate ( sa:SLS_SALES_DTLS( PK!=null,
PK.ITEM_ID.BRAND_CD.BRAND_CD=="N00" ) ,
                                   sum( sa.TRN_QTY *
sa.PK.ITEM_ID.SALES_TO_BASE_CONV )

     Hope it helps.

     []s
     Edson



2009/1/26 niraj manandhar <[email protected]>

> Can i retract the objects from accumulate function
> rule "Brand base free Item "
> salience 10
> when
>     brand_total:Number(doubleValue >=1500)
>         from accumulate ( sa:SLS_SALES_DTLS(
>         PK!=null,
>         PK.ITEM_ID.BRAND_CD.BRAND_CD=="N00"
>     ) ,    init ( double single_total=0; ),
>     action (single_total=single_total+(sa.getTRN_QTY()*
>     sa.getPK().getITEM_ID().getSALES_TO_BASE_CONV()
> // I want to retract the sa over here
>
> );
>     ),
>     result (single_total  ) );
> then
> double item_discounted=brand_total.doubleValue()/    1500;
> System.out.println("The discount given qty "+item_discounted+" multiplied
> slot 10");
> double item_left=brand_total.doubleValue()%1500;
> if(item_left>=1)
> {
> doit(item_left,"N00");
> }
> end
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to