x
Syntax: How to Call a Function in a RECAP Command
RECAP calcname[(s,e,i)][/format]=function
(input1,...,inputn,'format2');
where:
- calcname
- Is the name you assign to the calculated value.
- (s,e,i)
- Specify a start (s), end (e), and increment (i) value for
the column where you want the value displayed. If omitted, the value
appears in all columns.
- format
- The format for the calculation is optional. The default is
the format of the column. If the calculation consists of only the
subroutine, make sure that the format of the subroutine output value
(format2) agrees with the calculation format. If the calculation
format is larger than the column width, the value displays in that
column as asterisks.
- function
- Is the name of the function, up to eight characters long.
It must be different from any row label and cannot contain any of
the following special characters: = -, / ().
- input1, inputn
- Are the input
arguments for the call to the function. They may include numeric
constants, alphanumeric literals, row and column references ® notation,
E notation, or labels), or names of other RECAP calculations.
Make
sure that the values being passed to the function agree in number
and type with the arguments as coded in the function.
- format2
- Is the format of the return value, which must be enclosed
in single quotation marks.
Example: Calling a Function in a RECAP Command
Suppose
you have a function named INVEST in your private collection of functions (INVEST
is not available in the supplied library), and it calculates an
amount on the basis of cash on hand, total assets, and the current
date. In order to create a report that prints an account of company
assets and calculates how much money the company has available to invest,
you must create a report request that invokes the INVEST function.
The
current date is obtained from the &YMD system variable. The
NOPRINT option beside it prevents the date from appearing in the
report. The date is solely used as input for the next RECAP statement.
The request is:
TABLE FILE LEDGER
HEADING CENTER
"ASSETS AND MONEY AVAILABLE FOR INVESTMENT </2"
SUM AMOUNT ACROSS HIGHEST YEAR
IF YEAR EQ 1985 OR 1986
FOR ACCOUNT
1010 AS 'CASH' LABEL CASH OVER
1020 AS 'ACCOUNTS RECEIVABLE' LABEL ACR OVER
1030 AS 'INTEREST RECEIVABLE' LABEL ACI OVER
1100 AS 'FUEL INVENTORY' LABEL FUEL OVER
1200 AS 'MATERIALS AND SUPPLIES' LABEL MAT OVER
BAR OVER
RECAP TOTCAS = CASH+ACR+ACI+FUEL+MAT; AS 'TOTAL ASSETS' OVER
BAR OVER
RECAP THISDATE/A8 = &YMD; NOPRINT OVER
RECAP INVAIL = INVEST(CASH,TOTCAS,THISDATE,'D12.2'); AS
'AVAIL. FOR INVESTMENT' OVER
BAR AS '='
END
The output is shown in
the following image.
