The IF command supports arithmetic operations between fields, even fields of different numeric data types. This is useful in checking some of the 'business rules' that most applications have. These rules are usually included in the data entry programs but sometimes 'stuff happens' and the data gets messed up. Here is a simple task that uses this feature to isolate which records are breaking the rule of "Invoice amount = price times quantity".
>base sales.db,5,reader {MPE, on HP-UX use >open ..} >get d-invoices {MPE, on HP-UX use >select ..} >if price * quantity < > amount >list standard title "Price * Qty not = Amount" device LP >xeq
This idea can be used in a monthend job that prints exception reports.
If exceptions are found, you could just not delete the spoolfile:
!if suprtoolfullcount <= 0 then ! set stdlist=delete !endifOn HP-UX, the total is written to the stoutcount file, which can be tested as follows:
if [ `cat .stoutcount` -ge 10 ]; then echo "More than 10 records found" fi
Or you could handle exceptions in a more creative way, but emailing the exception report to the person in charge. To find out how to accomplish this, read our application note on remote database admin.
>base fms.gl,5,reader {MPE, on HP-UX use >open ..} >get d-transactions {MPE, on HP-UX use >select ..} >output $null >total trans-amt >xeq Totals (SUN, JAN 29, 1995, 2:56 PM): TRANS-AMT 81451+ IN=6, OUT=6. CPU-Sec=1. Wall-Sec=1.
By default the results of the Total command are displayed on the screen ($STDLIST), but can be appended to the output file. To do, this you need to turn Set Squeeze Off and add a new Total command as follows:
total $file filename,append {MPE only}
Up to 15 fields can be totalled in each pass.