How to: |
You may provide your own calculation routines in RECAP rows to perform special-purpose calculations, a useful feature when these calculations are mathematically complex or require extensive look-up tables.
User-written functions are coded as subroutines in any language that supports a call process, such as FORTRAN, COBOL, PL/1, and BAL. See the Using Functions manual for information about creating your own functions.
RECAP calcname[(s,e,i)][/format]=function (input1,...,inputn,'format2');
where:
Make sure that the values being passed to the function agree in number and type with the arguments as coded in the function.
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.
ASSETS AND MONEY AVAILABLE FOR INVESTMENT YEAR 1986 1985 ---------------------------------------- CASH 2,100 1,684 ACCOUNTS RECEIVABLE 875 619 INTEREST RECEIVABLE 4,026 3,360 FUEL INVENTORY 6,250 5,295 MATERIALS AND SUPPLIES 9,076 7,754 ------ ------ TOTAL ASSETS 22,327 18,712 ------ ------ AVAIL. FOR INVESTMENT 3,481 2,994 ====== ======
Information Builders |