COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Example 223 VARIANCE Function
Code:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NUMERIC-ARRAY
05 PICTURE 9V99 VALUE 0.05.
05 PICTURE 9V99 VALUE 1.15.
05 PICTURE 9V99 VALUE 2.50.
05 PICTURE 9V99 VALUE 3.75.
05 PICTURE 9V99 VALUE 4.55.
01 NUM-ARRAY REDEFINES NUMERIC-ARRAY.
05 NUM OCCURS 5 TIMES PICTURE 9V99.
01 A PICTURE 9V99.
PROCEDURE DIVISION.
MOVE FUNCTION VARIANCE (NUM(ALL)) TO A
DISPLAY A..
MOVE FUNCTION VARIANCE (9 2 5 3) TO A.
DISPLAY A.
MOVE FUNCTION VARIANCE (1.5 3.6 7.8 4.9) TO A.
DISPLAY A.
MOVE FUNCTION VARIANCE (5) TO A.
DISPLAY A.
Output:
2.70
7.18
5.21
0.00
WHEN-COMPILED Function
WHEN-COMPILED, an alphanumeric function, returns a 21-character string that represents the
date and time the program was compiled, according to the system on which the program was
compiled.
The returned value is the date and time of compilation of the source program that calls the
WHEN-COMPILED function. If the program is a contained program, the returned value is the date
and time of the separately compiled program that contains it.
The returned value represents the current date this way (where character position 1 is the leftmost
character position):
Represented byDate Part RepresentedCharacter Positions
Four digitsYear in Gregorian calendar1-4
Two digits in the range 01 through 12Month of the year5-6
Two digits in the range 01 through 31Day of the month7-8
Two digits in the range 00 through 23Hours past midnight9-10
Two digits in the range 00 through 59Minutes past the hour11-12
Two digits in the range 00 through 59Seconds past the minute13-14
Two digits in the range 00 through 99Hundredths of seconds past the second15-16
Minus (-) if the reported time is behind Greenwich
mean time, plus (+) if it is the same as or ahead of
Greenwich mean time
Relationship to Greenwich mean time17
WHEN-COMPILED Function 697