Please enable JavaScript to view this site.
Program to total values with a varying number of input decimals and output a value with a specific number of decimals. The result may be rounded and include comma delimiters if required. You can also specify a bucket (1 – 99) into which you wish to put your total to allow for more than one running total.
First call – This should be called when you wish to zero the total and start again, possibly inside a Page = *FIRST condition.
Parameter  | 
In  | 
Len  | 
Comment  | 
PARM1  | 
Number of output decimals (0 – 5)  | 
1  | 
If left blank defaults to 0  | 
PARM2  | 
Round up result  | 
4  | 
*YES to round or blank  | 
PARM3  | 
Thousand delimiter etc.  | 
1  | 
Enter delimiter if required e.g. “,”  | 
PARM4  | 
Negative sign?  | 
4  | 
*NO to stop minus sign on Total  | 
PARM5  | 
Decimal point e.g. “.” or ”,”  | 
1  | 
If left blank defaults to “.”  | 
PARM6  | 
*FIRST  | 
  | 
Sum call – This should be called when you wish to pass in a value to be added to / subtracted from your total, possibly inside a “Loop”
Parameter  | 
In  | 
Len  | 
Out  | 
Len  | 
Comment  | 
PARM1  | 
Value to sum  | 
30  | 
Sub Total #2  | 
20  | 
Subtotal values (passed in Sum call)  | 
PARM2  | 
Bucket No  | 
2  | 
Negative  | 
4  | 
*NEG if result is negative  | 
PARM3  | 
-  | 
  | 
  | 
||
PARM4  | 
-  | 
  | 
  | 
||
PARM5  | 
-  | 
  | 
  | 
||
PARM6  | 
*ADD or *SUB #1  | 
  | 
  | 
| #1 | If using *ADD you may pass in a number with a minus sign and it will subtract the value. If you do not have minus signs on your spooled file then you may use *SUB to subtract a number from your total. It does not matter if the value that you pass in PARM1 has more or less decimals than the decimals required for the total value. | 
| #2 | If there is an error in the value being passed in *ERROR will be returned in PARM1. | 
Reset call – This should be called when you wish to clear a specific counter.
Parameter  | 
In  | 
Len  | 
Out  | 
Len  | 
Comment  | 
PARM1  | 
Bucket No  | 
4  | 
  | 
Bucket no to clear (1 – 99)  | 
|
PARM2  | 
-  | 
  | 
  | 
or *ALL for all buckets  | 
|
PARM3  | 
-  | 
  | 
  | 
||
PARM4  | 
-  | 
  | 
  | 
||
PARM5  | 
-  | 
  | 
  | 
||
PARM6  | 
*RESET  | 
  | 
  | 
Last call – This should be called when you wish to produce a total, possibly inside a Page = *LAST condition.
Parameter  | 
In  | 
Len  | 
Out  | 
Len  | 
Comment  | 
PARM1  | 
-  | 
  | 
  | 
Grand Total #3  | 
|
PARM2  | 
-  | 
  | 
  | 
||
PARM3  | 
-  | 
  | 
  | 
||
PARM4  | 
-  | 
  | 
  | 
||
PARM5  | 
-  | 
  | 
  | 
||
PARM6  | 
*LAST  | 
  | 
  | 
#3 The sum of all the buckets will be returned in PARM1.