4gl filtering tables and pop-up for incorrect prices

Hello,

I am trying to set up a SPE for the client to have an info box message pop-up if the invoice price (being NETPRI from PINVOICED table) is different than the price listed on the price list (PRI from PPRICLIST table). The problem with these 2 tables is that they require filtering in order to limit the search (ex. UOMs have to be the same, qty must be within qty range on price list), product and supplier must be the same (PLICRI1 and PLICRI2), and ACCDAT must be within the validity date range (PLISTRDAT and PLIENDDAT). What I have so far is this, but I am not well versed in 4GL, so I know there are a couple structural errors with this :

#######

$ACTION
Case ACTION
When "OUVRE" : Gosub OUVRE
When Default
Endcase
Return

$OUVRE
If clalev([PPL]) = 0 : Local File PPRICLIST [PPL] : Endif
Return

Subprog AM_NETPRI(VALEUR)
Variable Decimal VALEUR
Read [PPL]PPL0 = "T20" ; [F:PPL]PLICRD ; [F:PPL]PLILIN
Filter [PPL] Where ([M:PIH3]ITMREF(nolign-1) = [F:PPL]PLICRI2) & ([M:PIH3]BPSNUM = [F:PPL]PLICRI1) & ([F:PPL]UOM = [M:PIH3]UOM) & ([F:PPL]PLISTRDAT <= [M:PIH0]ACCDAT <= [F:PPL]PLIENDDAT) & ([F:PPL]MINQTY <= [M:PIH3]QTYUOM <= [F:PPL]MAXQTY)
If !fstat
Infbox "evalue(num$([L]VALEUR - [F:PPL]PRI))"
Endif
GPE=1
End

#########

--error message (incorrect syntax near '<'. - SQL error) is what I am getting. I am also using an AM action, but since these lines are loaded from the left list (from receipt), it only fires if the user actually changes the field, as opposed to evaluating it in all cases.

Has anyone had experience with something like this before? If this is too complicated, a workflow may be a better option I guess. 


Thanks,
MIke