0
votes
(deffunction slabV10071 ( ?totalQuantity ?quantityBuilder )
    (bind ?promoQuantities (integer (/ ?totalQuantity 6)))
    if(>= ?totalQuantity 12) then
    (assert(Output (promoId V10071)(promotionTypeCode 1)(productIds 3089 2264 2090 )(quantities ?quantityBuilder)(uom EA)(promoQuantities ?promoQuantities)(values  1666.6666666)(rewardId  3089,2264,2090)(repeatingRange 1)(proRata N)(exclusionFlag 1)(sequenceNumber 3335)(effectiveFrom 2020-05-27)))
    (return))(bind ?promoQuantities (integer (/ ?totalQuantity 12)))
    if(>= ?totalQuantity 6) then
    (assert(Output (promoId V10071)(promotionTypeCode 1)(productIds 3089 2264 2090 )(quantities ?quantityBuilder)(uom EA)(promoQuantities ?promoQuantities)(values  1700)(rewardId  3089,2264,2090)(repeatingRange 1)(proRata N)(exclusionFlag 1)(sequenceNumber 3335)(effectiveFrom 2020-05-27)))
    (return)))
(defrule V10071
(exists (Product(productId 3089)(quantity ?q&:(> ?q 1))(date ?orderDate&:(<= 20200527 ?orderDate 20201231))))
=>
(bind ?totalQuantity 0)
(bind ?quantityBuilder "")
(do-for-all-facts ((?p Product))
(or (eq ?p:productId 3089)
(eq ?p:productId 2264)
(eq ?p:productId 2090)
)
(bind (str-cat ?quantitybuilder ?p:quantity " " ))
(bind ?totalQuantity (+ ?totalQuantity ?p:quantity)))
(if(>= ?totalQuantity 1) then
(slabV10071 ?totalQuantity ?quantityBuilder)))

This is the code. The slabV10071 function is working fine. But In the rule im getting the error

[PRNTUTIL2] Syntax Error: Check appropriate syntax for bind function.

[PRNTUTIL2] Syntax Error: Check appropriate syntax for fact-set query function.

Please help.

1

1 Answers

0
votes

The error message shows you the position in your rule where the error is occurring:

ERROR:
(defrule MAIN::V10071
   (exists
        (Product (productId 3089) (quantity ?q&:(> ?q 1)) (date ?orderDate&:(<= 20200527 ?orderDate 20201231))))
   =>
   (bind ?totalQuantity 0)
   (bind ?quantityBuilder "")
   (do-for-all-facts ((?p Product))
      (or (eq ?p:productId 3089) (eq ?p:productId 2264) (eq ?p:productId 2090))
      (bind(

This is the line of code causing the error:

(bind (str-cat ?quantitybuilder ?p:quantity " " ))

You're not providing a variable to which the function call will be bound. This is probably what you want:

(bind ?quantitybuilder (str-cat ?quantitybuilder ?p:quantity " " ))