You are on page 1of 33

Infosys Technologies Limited

BOK

Intrinsic Functions in Cobol


INTRINSIC FUNCTIONS IN COBOL......................................................................................................................1
PURPOSE OF THIS DOCUMENT............................................................................................................................2
INTRODUCTION.........................................................................................................................................................2
SPECIFYING A FUNCTION......................................................................................................................................2
FUNCTION DEFINITION AND EVALUATION...................................................................................................................3
TYPES OF FUNCTIONS..................................................................................................................................................3
RULES FOR USAGE......................................................................................................................................................4
ARGUMENTS................................................................................................................................................................4
ALL SUBSCRIPTING.....................................................................................................................................................5
FUNCTIONS.................................................................................................................................................................7
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.

ACOS..................................................................................................................................................................7
ANNUITY..........................................................................................................................................................7
ASIN...................................................................................................................................................................7
ATAN..................................................................................................................................................................8
CHAR.................................................................................................................................................................8
COS.....................................................................................................................................................................8
CURRENT-DATE...............................................................................................................................................9
DATE-OF-INTEGER.......................................................................................................................................10
DATE-TO-YYYYMMDD................................................................................................................................11
DATEVAL.....................................................................................................................................................12
DAY-OF-INTEGER......................................................................................................................................14
DAY-TO-YYYYDDD..................................................................................................................................14
FACTORIAL................................................................................................................................................15
INTEGER.....................................................................................................................................................15
INTEGER-OF-DATE...................................................................................................................................16
INTEGER-OF-DAY.....................................................................................................................................16
INTEGER-PART..........................................................................................................................................17
LENGTH.......................................................................................................................................................17
LOG..............................................................................................................................................................18
LOG10..........................................................................................................................................................18
LOWER-CASE.............................................................................................................................................18
MAX.............................................................................................................................................................19
MEAN...........................................................................................................................................................19
MEDIAN.......................................................................................................................................................20
MIDRANGE.................................................................................................................................................20
MIN...............................................................................................................................................................20
MOD.............................................................................................................................................................21
NUMVAL.....................................................................................................................................................22
NUMVAL-C.................................................................................................................................................22
ORD..............................................................................................................................................................24
ORD-MAX...................................................................................................................................................24
ORD-MIN.....................................................................................................................................................25
PRESENT-VALUE.......................................................................................................................................25
RANDOM.....................................................................................................................................................25

328519205.doc

Infosys Technologies Limited


35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.

BOK

RANGE.........................................................................................................................................................26
REM..............................................................................................................................................................26
REVERSE.....................................................................................................................................................27
SIN................................................................................................................................................................27
SQRT.............................................................................................................................................................27
STANDARD-DEVIATION..........................................................................................................................28
SUM..............................................................................................................................................................28
TAN...............................................................................................................................................................28
UNDATE.......................................................................................................................................................29
UPPER-CASE...............................................................................................................................................29
VARIANCE..................................................................................................................................................30
WHEN-COMPILED.....................................................................................................................................30
YEAR-TO-YYYY........................................................................................................................................32
YEARWINDOW..........................................................................................................................................33

CONTACT PERSON:................................................................................................................................................33

Purpose of this document


This document lists various intrinsic functions used in COBOL.

Introduction
Data processing problems often require the use of values that are not directly accessible in the data storage
associated with the object program, but instead must be derived through performing operations on other data. An
intrinsic function is a function that performs a mathematical, character, or logical operation, and thereby allows you
to make reference to a data item whose value is derived automatically during the execution of the object program.
The functions can be grouped into six categories, based on the type of service performed: mathematical, statistical,
date/time, financial, character-handling, and general.
You can reference a function by specifying its name, along with any required arguments, in a Procedure Division
statement.

Specifying a Function
The general format of a function-identifier is:
___ Format _____________________________________________________________
|
|
| >>__FUNCTION__function-name-1________________________________________> |
|
|
<____________
|
|
|
|_(____argument-1_|__)_|
|
|
|
| >___________________________________________________________________>< |
|
|_reference-modifier_|
|
|
|
|________________________________________________________________________|
function-name-1
Function-name-1 must be one of the Intrinsic Function names.
argument-1
Argument-1 must be an identifier, literal (other than a figurative constant), or arithmetic expression. Argument-1
cannot be a windowed date field, except in the UNDATE intrinsic function.
328519205.doc

Infosys Technologies Limited

BOK

reference-modifier
Can be specified only for functions of the category alphanumeric
Below, we will show examples of an intrinsic function invocation for an alphanumeric source statement and a
numeric source statement.
The alphanumeric source statement:
MOVE FUNCTION UPPER-CASE("hello") TO DATA-NAME.
replaces each lowercase letter in the argument with the corresponding uppercase letter, resulting in the movement of
HELLO into DATA-NAME.
The numeric source statement,
COMPUTE NUM-ITEM = FUNCTION SUM(A B C)
Adds the values of A, B, and C and places the result in NUM-ITEM.
Within a Procedure Division statement, each function-identifier is evaluated at the same time as any reference
modification or subscripting associated with an identifier in that same position would be evaluated.
Subtopics:
Function Definition and Evaluation
Types of Functions
Rules for Usage
Arguments
ALL Subscripting

Function Definition and Evaluation


The class and characteristics of a function, and the number and types of arguments it requires, are determined by its
function definition. These characteristics include:
For some functions, the class and characteristics are determined by the arguments to the function
For alphanumeric functions, the size of the returned value
For numeric and integer functions, the sign of the returned value, and whether the function is integer
The actual value returned by the function
The evaluation of any intrinsic function is not affected by the context in which it appears; in other words, function
evaluation is not affected by operations or operands outside the function. However, evaluation of a function can be
affected by the attributes of its arguments.

Types of Functions
There are three types of functions:
Alphanumeric
Numeric
Integer
Alphanumeric functions are of the class and category alphanumeric. The value returned has an implicit usage of
DISPLAY and is in standard data format characters. The number of character positions in the value returned is
determined by the function definition.
Numeric functions are of the class and category numeric. The returned value is always considered to have an
operational sign and is a numeric intermediate result. For more information, see the IBM COBOL Programming
Guide for your platform.

328519205.doc

Infosys Technologies Limited

BOK

Rules for Usage


Alphanumeric Functions
An alphanumeric function can be specified anywhere in the general formats that an identifier is permitted and where
the rules associated with the general formats do not specifically prohibit reference to functions, except as follows:
As a receiving operand of any statement
Where the rules associated with the general formats require the data item being referenced to have
particular characteristics (such as class and category, usage, size, and permissible values) and the evaluation
of the function according to its definition and the particular arguments specified would not have these
characteristics.
A reference modification for an alphanumeric function is allowed. If reference modification is specified for a
function, the evaluation of the reference modification takes place immediately after the evaluation of the function.
An alphanumeric function can be referenced as an argument for a function which allows an alphanumeric argument.
Numeric Functions
A numeric function can be used only where an arithmetic expression can be specified.
A numeric function can be referenced as an argument for a function which allows a numeric argument.
A numeric function cannot be used where an integer operand is required, even if the particular reference will yield
an integer value. The INTEGER or INTEGER-PART functions can be used to force the type of a numeric argument
to be an integer.
Integer Functions
An integer function can be used only where an arithmetic expression can be specified.
An integer function can be referenced as an argument for a function which allows an integer argument.
Special Usage Notes:
Identifier-2 of the CALL statement must not be a function-identifier.
The COPY statement will allow function-identifiers of all types in the REPLACING phrase.

Arguments
The values returned by some functions are determined by the arguments specified in the function-identifier when the
functions are evaluated. Some functions require no arguments; others require a fixed number of arguments, and still
others allow a variable number of arguments.
An argument must be one of the following:
An identifier
An arithmetic expression
A function-identifier
A literal other than a figurative constant.
A special-register
The argument to a function can be any function or an expression containing a function, including another evaluation
of the same function, whose result meets the category requirement for the argument.
An argument cannot be a DBCS literal or data item. See "Function Definitions" in topic 1.2 for function specific
argument specifications.
The types of arguments are:
Alphabetic. An elementary data item of the class alphabetic or a nonnumeric literal containing only
alphabetic characters. The content of the argument will be used to determine the value of the function. The
length of the argument can be used to determine the value of the function.
Alphanumeric. A data item of the class alphabetic or alphanumeric or a nonnumeric literal. The content of
the argument will be used to determine the value of the function. The length of the argument can be used to
determine the value of the function.
328519205.doc

Infosys Technologies Limited

BOK

Integer. An arithmetic expression that will always result in an integer value. The value of this expression,
including its sign, is used to determine the value of the function.
Numeric. An arithmetic expression, whose value, including its sign, is used to determine the value of the
function.
Some functions place constraints on their arguments, such as the range of values acceptable. If the values assigned
as arguments for a function do not comply with specified constraints, the returned value is undefined.
If a nested function is used as an argument, the evaluation of its arguments will not be affected by the arguments in
the outer function.
Only those arguments at the same function level interact with each other. This interaction occurs in two areas:
The computation of an arithmetic expression that appears as a function argument will be affected by other
arguments for that function.
The evaluation of the function takes into consideration the attributes of all of its arguments.
When a function is evaluated, its arguments are evaluated individually in the order specified in the list of arguments,
from left to right. The argument being evaluated can be a function-identifier, or it can be an expression containing
function-identifiers.
If an arithmetic expression is specified as an argument, and if the first operator in the expression is a unary plus or a
unary minus, it must be immediately preceded by a left parenthesis.
Floating-point literals are allowed wherever a numeric argument is allowed, and in arithmetic expressions used in
functions that allow a numeric argument. They are not allowed where an integer argument is
required.
External floating-point items are allowed wherever a numeric argument is allowed, and in arithmetic expressions
used in functions that allow a numeric argument.
External floating-point items are not allowed where an integer argument is required, or where an argument of
alphanumeric class is allowed in a function identification, such as in the LOWER-CASE, REVERSE,
UPPERCASE, NUMVAL, and NUMVAL-C functions.

ALL Subscripting
When a function allows an argument to be repeated a variable number of times, you can refer to a table by
specifying the data-name and any qualifiers that identify the table. This can be followed immediately by subscripting
where one or more of the subscripts is the word ALL.
Note: The evaluation of an ALL subscript must result in at least one argument or the value returned by the function
will be undefined; however, the situation can be diagnosed at run-time by specifying the SSRANGE compiler option
and the CHECK run-time option.
Specifying ALL as a subscript is equivalent to specifying all table elements possible using every valid subscript in
that subscript position.
For a table argument specified as "Table-name(ALL)", the order of the implicit specification of each table element
as an argument is from left to right, where the first (or leftmost) argument is "Table-name(1)" and ALL has been
replaced by 1. The next argument is "Table-name(2)", where the subscript has been incremented by 1. This process
continues, with the subscript being incremented by 1 to produce an implicit argument, until the ALL subscript has
been incremented through its range of values.
For example,
FUNCTION MAX(Table(ALL))
is equivalent to
FUNCTION MAX(Table(1) Table(2) Table(3)... Table(n))
where n is the number of elements in Table.

328519205.doc

Infosys Technologies Limited

BOK

If there are multiple ALL subscripts, "Table-name(ALL, ALL, ALL)", the first implicit argument is "Table-name(1,
1, 1)", where each ALL has been replaced by 1. The next argument is "Table-name(1, 1, 2)", where the rightmost
subscript has been incremented by 1. The subscript represented by the rightmost ALL is incremented through its
range of values to produce an implicit argument for each value.
Once a subscript specified as ALL has been incremented through its range of values, the next subscript to the left
that is specified as ALL is incremented by 1. Each subscript specified as ALL to the right of the newly incremented
subscript is set to 1 to produce an implicit argument. Once again, the subscript represented by the rightmost ALL is
incremented through its range of values to produce an implicit argument for each value. This process is repeated
until each subscript specified as ALL has been incremented through its range of values.
For example,
FUNCTION MAX(Table(ALL, ALL))
is equivalent to
FUNCTION MAX(Table(1, 1) Table(1, 2) Table(1, 3)... Table(1, n)
Table(2, 1) Table(2, 2) Table(2, 3)... Table(2, n)
Table(3, 1) Table(3, 2) Table(3, 3)... Table(3, n)
.
.
.
Table(m, 1) Table(m, 2) Table(m, 3)... Table(m, n))
where n is the number of elements in the column dimension of Table, and m is the number of elements in the row
dimension of Table.
ALL subscripts can be combined with literal, data-name, or index-name subscripts to reference multidimensional
tables.
For example,
FUNCTION MAX(Table(ALL, 2))
is equivalent to
FUNCTION MAX(Table(1, 2)
Table(2, 2)
Table(3, 2)
.
.
.
Table(m, 2))
where m is the number of elements in the row dimension of Table.
If an ALL subscript is specified for an argument and the argument is reference modified, then the reference-modifier
is applied to each of the implicitly specified elements of the table.
If an ALL subscript is specified for an operand that is reference-modified, the reference-modifier is applied to each
of the implicitly specified elements of the table.
If the ALL subscript is associated with an OCCURS DEPENDING ON clause, the range of values is determined by
the object of the OCCURS DEPENDING ON clause.
For example, given a payroll record definition such as:
01 PAYROLL.
02 PAYROLL-WEEK
PIC 99.
02 PAYROLL-HOURS PIC 999 OCCURS 1 TO 52
DEPENDING ON PAYROLL-WEEK.
The following COMPUTE statements could be used to identify total year-to-date hours, the maximum hours worked
in any week, and the specific week corresponding to the maximum hours:
COMPUTE YTD-HOURS = FUNCTION SUM (PAYROLL-HOURS(ALL))
COMPUTE MAX-HOURS = FUNCTION MAX (PAYROLL-HOURS(ALL))
COMPUTE MAX-WEEK = FUNCTION ORD-MAX (PAYROLL-HOURS(ALL))
In these function invocations the subscript ALL is used to reference all elements of the PAYROLL-HOURS array
(depending on the execution time value of the PAYROLL-WEEK field).
328519205.doc

Infosys Technologies Limited

BOK

FUNCTIONS
1. ACOS
The ACOS function returns a numeric value in radians that approximates the arccosine of the argument specified.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION ACOS__(argument-1)_____________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric. The value of argument-1 must be greater than or equal to -1 and less than or equal to +1.
The returned value is the approximation of the arccosine of the argument and is greater than or equal to zero and less
than or equal to Pi.

2. ANNUITY
The ANNUITY function returns a numeric value that approximates the ratio of an annuity paid at the end of each
period, for a given number of periods, at a given interest rate, to an initial value of one. The number of periods is
specified by argument-2; the rate of interest is specified by argument-1. For example, if argument-1 is zero and
argument-2 is four, the value returned is the approximation of the ratio 1 / 4.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION ANNUITY__(argument-1 argument-2)_______________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric. The value of argument-1 must be greater than or equal to zero.
argument-2
Must be a positive integer.
When the value of argument-1 is zero, the value returned by the function is the approximation of:1 / ARGUMENT-2
When the value of argument-1 is not zero, the value of the function is the approximation of:
ARGUMENT-1 / (1 - (1 + ARGUMENT-1) ** (- ARGUMENT-2))

3. ASIN
The ASIN function returns a numeric value in radians that approximates the arcsine of the argument specified.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION ASIN__(argument-1)_____________________________________>< |
328519205.doc

Infosys Technologies Limited

BOK

|
|
|________________________________________________________________________|
argument-1
Must be class numeric. The value of argument-1 must be greater than or equal to -1 and less than or equal to +1.
The returned value is the approximation of the arcsine of argument-1 and is greater than or equal to -Pi/2 and less
than or equal to +Pi/2.

4. ATAN
The ATAN function returns a numeric value in radians that approximates the arctangent of the argument specified.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION ATAN__(argument-1)_____________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the approximation of the arctangent of argument-1 and is greater than -Pi/2 and less than
+Pi/2.

5. CHAR
The CHAR function returns a 1-character alphanumeric value that is a character in the program collating sequence
having the ordinal position equal to the value of the argument specified.
The function type is alphanumeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION CHAR__(argument-1)_____________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be an integer. The value must be greater than zero and less than or equal to the number of positions in the
collating sequence.
If more than one character has the same position in the program collating sequence, the character returned as the
function value is that of the first literal specified for that character position in the ALPHABET clause.
If the current program collating sequence was not specified by an ALPHABET clause:
Under OS/390 and VM, the EBCDIC collating sequence is usedUnder AIX, OS/2, and Windows, the
COLLSEQ compiler option indicates the collating sequence used. For example, if COLLSEQ(EBCDIC) is
specified and the PROGRAM COLLATING SEQUENCE is not specified (or is NATIVE), the EBCDIC
collating sequence is applied.

6. COS

328519205.doc

Infosys Technologies Limited

BOK

The COS function returns a numeric value that approximates the cosine of the angle or arc specified by the argument
in radians.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION COS__(argument-1)______________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the approximation of the cosine of the argument and is greater than or equal to -1 and less than
or equal to +1.

7. CURRENT-DATE
The CURRENT-DATE function returns a 21-character alphanumeric value that represents the calendar date, time of
day, and time differential from Greenwich Mean Time provided by the system on which the function is evaluated.
The function type is alphanumeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION CURRENT-DATE___________________________________________>< |
|
|
|________________________________________________________________________|
Reading from left to right, the 21 character positions in the value returned can be interpreted as follows:
Character Positions Contents

1-4
Four numeric digits of the year in the Gregorian calendar.
5-6
Two numeric digits of the month of the year, in the range 01 through 12.
7-8
Two numeric digits of the day of the month, in the range 01 through 31.
9-10
Two numeric digits of the hours past midnight, in the range 00 through 23.
11-12
Two numeric digits of the minutes past the hour, in the range 00 through 59.
13-14
Two numeric digits of the seconds past the minute, in the range 00 through 59.
328519205.doc

Infosys Technologies Limited

BOK

15-16
Two numeric digits of the hundredths of a second past the second, in the range 00 through
99. The value 00 is returned if the system on which the function is evaluated does not have
the facility to provide the fractional part of a second.
17
Either the character '-' or the character '+'. The character '-' is returned if the local time
indicated in the previous character positions is behind Greenwich Mean Time. The character
'+' is returned if the local time indicated is the same as or ahead of Greenwich Mean Time.
The character '0' is returned if the system on which this function is evaluated does not have
the facility to provide the local time differential factor.
18-19
If character position 17 is '-', two numeric digits are returned in the range 00 through 12
indicating the number of hours that the reported time is behind Greenwich Mean Time. If
character position 17 is '+', two numeric digits are returned in the range 00 through 13
indicating the number of hours that the reported time is ahead of Greenwich Mean Time. If
character position 17 is '0', the value 00 is returned.
20-21
Two numeric digits are returned in the range 00 through 59 indicating the number of
additional minutes that the reported time is ahead of or behind Greenwich Mean Time,
depending on whether character position 17 is '+' or '-', respectively. If character position 17
is '0', the value 00 is returned.
For more information, see the IBM COBOL Programming Guide for your platform.

8. DATE-OF-INTEGER
The DATE-OF-INTEGER function converts a date in the Gregorian calendar from integer date form to standard date
form (YYYYMMDD).
The function type is integer.
The function result is an 8-digit integer.
If the DATEPROC compiler option is in effect, then the returned value is an expanded date field with implicit
DATE FORMAT YYYYXXXX.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION DATE-OF-INTEGER__(argument-1)__________________________>< |
|
|
|________________________________________________________________________|

328519205.doc

10

Infosys Technologies Limited

BOK

argument-1
A positive integer that represents a number of days succeeding December 31, 1600, in the Gregorian calendar. The
valid range is 1 to 3,067,671, which corresponds to dates ranging from January 1, 1601 thru December 31, 9999.
>_Host_> Under OS/390 and VM, the INTDATE compiler option affects the starting date for the integer date
functions. For details, see the IBM COBOL for OS/390 & VM Programming Guide. <_Host_<
The returned value represents the International Standards Organization (ISO) standard date equivalent to the integer
specified as argument-1.
The returned value is an integer of the form YYYYMMDD where YYYY represents a year in the Gregorian
calendar; MM represents the month of that year; and DD represents the day of that month.

9. DATE-TO-YYYYMMDD

The DATE-TO-YYYYMMDD function converts argument-1 from a date with a 2-digit year (YYnnnn) to a date
with a 4-digit year (YYYYnnnn).
Argument-2, when added to the year at the time of execution, defines the ending year of a 100-year interval, or
sliding century window, into which
the year of argument-1 falls.
The function type is integer.
If the DATEPROC compiler option is in effect, then the returned value is an expanded date field with implicit
DATE FORMAT YYYYXXXX.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION DATE-TO-YYYYMMDD__(argument-1________________)_________>< |
|
|_argument-2_|
|
|
|
|________________________________________________________________________|
argument-1
Must be zero or a positive integer less than 1,000,000.
argument-2
Must be an integer. If argument-2 is omitted, the function is evaluated assuming the value 50 was specified.
The sum of the year at the time of execution and the value of argument-2 must be less than 10,000 and greater than
1,699.

Example
Some examples of returned values from the DATE-TO-YYYYMMDD function
follow:
________________________________________________________________________
328519205.doc

11

Infosys Technologies Limited

BOK

|
|
| Argument-2
| DATE-TO-YYYYMMDD|
| Current Year
| Argument-1 Value | Value
| Return Value
|
|_________________|__________________|_________________|_________________|
| 2002
| 851003
| 120
| 20851003
|
|_________________|__________________|_________________|_________________|
| 2002
| 851003
| -20
| 18851003
|
|_________________|__________________|_________________|_________________|
| 2002
| 851003
| 10
| 19851003
|
|_________________|__________________|_________________|_________________|
| 1994
| 981002
| -10
| 18981002
|
|_________________|__________________|_________________|_________________|

10. DATEVAL

The DATEVAL function converts a non-date to a date field, for unambiguous


use with date fields.

If the DATEPROC compiler option is in effect, the returned value is a date


field containing the value of argument-1 unchanged.
If the NODATEPROC compiler option is in effect, the DATEVAL function has no effect, and returns the value of
argument-1 unchanged.
The function type depends on the type of argument-1:
Argument-1 Type Function Type

Alphanumeric
Alphanumeric
Integer
Integer
___ Format _____________________________________________________________
|
|
| >>__FUNCTION DATEVAL__(__argument-1__argument-2__)__________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be one of the following:

A class alphanumeric item with the same number of characters as the date format specified by argument-2.
328519205.doc

12

Infosys Technologies Limited

BOK

An integer. This can be used to specify values outside the range specified by argument-2, including
negative values.
The value of argument-1 represents a date of the form specified by argument-2.
argument-2
Must be a nonnumeric literal specifying a date pattern, as defined in "DATE FORMAT Clause" in topic 5.3.6. The
date pattern consists of YY or YYYY (representing a windowed year or expanded year, respectively), optionally
preceded or followed by one or more Xs (representing other parts of a date, such as month and day), as follows.
Note that the values are case-insensitive; the letters X and Y in argument-2 may be any mix of uppercase and
lowercase.
Date-pattern string... Specifies that argument-1 contains...

YY
A windowed (2-digit) year.
YYYY
An expanded (4-digit) year.
X
A single character; for example, a digit representing a semester or quarter (1-4).
XX
Two characters; for example, digits representing a month (01-12).
XXX
Three characters; for example, digits representing a day of the year (001-366).
XXXX
Four characters; for example, 2 digits representing a month (01-12) and 2 digits representing
a day of the month (01-31).
Note: You can use apostrophes as the literal delimiters instead of quotes (independent of the APOST/QUOTE
compiler option).
328519205.doc

13

Infosys Technologies Limited

BOK

11. DAY-OF-INTEGER
The DAY-OF-INTEGER function converts a date in the Gregorian calendar from integer date form to Julian date
form (YYYYDDD).
The function type is integer.
The function result is a 7-digit integer.
If the DATEPROC compiler option is in effect, then the returned value is
an expanded date field with implicit DATE FORMAT YYYYXXX.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION DAY-OF-INTEGER__(argument-1)___________________________>< |
|
|
|________________________________________________________________________|
argument-1
A positive integer that represents a number of days succeeding December 31, 1600, in the Gregorian calendar. The
valid range is 1 to 3,067,671, which corresponds to dates ranging from January 1, 1601 thru December 31, 9999.
>_Host_>
Under OS/390 and VM, the INTDATE compiler option affects the starting date for the integer date functions. For
details, see the IBM COBOL for OS/390 & VM Programming Guide.
<_Host_<
The returned value represents the Julian equivalent of the integer specified as argument-1. The returned value is an
integer of the form YYYYDDD where YYYY represents a year in the Gregorian calendar and DDD represents the
day of that year.

12. DAY-TO-YYYYDDD
The DAY-TO-YYYYDDD function converts argument-1 from a date with a 2-digit
year (YYnnn) to a date with a 4-digit year (YYYYnnn). Argument-2, when
added to the year at the time of execution, defines the ending year of a
100-year interval, or sliding century window, into which the year of
argument-1 falls.
The function type is integer.
If the DATEPROC compiler option is in effect, then the returned value is
an expanded date field with implicit DATE FORMAT YYYYXXX.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION DAY-TO-YYYYDDD__(argument-1________________)___________>< |
|
|_argument-2_|
|
|
|
|________________________________________________________________________|

328519205.doc

14

Infosys Technologies Limited

BOK

argument-1
Must be zero or a positive integer less than 100,000.
argument-2
Must be an integer. If argument-2 is omitted, the function is evaluated assuming the value 50 was specified.
The sum of the year at the time of execution and the value of argument-2 must be less than 10,000 and greater than
1,699.

Example
Some examples of returned values from the DAY-TO-YYYYDDD function follow:
________________________________________________________________________
|
|
| Argument-2
| DAY-TO-YYYYDDD |
| Current Year
| Argument-1 Value | Value
| Return Value
|
|_________________|__________________|_________________|_________________|
| 2002
| 10004
| -20
| 1910004
|
|_________________|__________________|_________________|_________________|
| 2002
| 10004
| -120
| 1810004
|
|_________________|__________________|_________________|_________________|
| 2002
| 10004
| 20
| 2010004
|
|_________________|__________________|_________________|_________________|
| 2013
| 95005
| -10
| 1995005
|
|_________________|__________________|_________________|_________________|

13. FACTORIAL
The FACTORIAL function returns an integer that is the factorial of the argument specified.
The function type is integer.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION FACTORIAL__(argument-1)________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be an integer greater than or equal to zero and less than or equal to 28.
If the value of argument-1 is zero, the value 1 is returned; otherwise, its factorial is returned.

14. INTEGER
The INTEGER function returns the greatest integer value that is less than or equal to the argument specified.
The function type is integer.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION INTEGER__(argument-1)__________________________________>< |
328519205.doc

15

Infosys Technologies Limited

BOK

|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the greatest integer less than or equal to the value of argument-1. For example,
FUNCTION INTEGER (2.5)
will return a value of 2; and
FUNCTION INTEGER (-2.5)
will return a value of -3.

15. INTEGER-OF-DATE
The INTEGER-OF-DATE function converts a date in the Gregorian calendar from standard date form
(YYYYMMDD) to integer date form.
The function type is integer.
The function result is a 7-digit integer with a range from 1 to 3,067,671.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION INTEGER-OF-DATE__(argument-1)__________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be an integer of the form YYYYMMDD, whose value is obtained from the calculation (YYYY * 10,000) +
(MM * 100) + DD.
YYYY represents the year in the Gregorian calendar. It must be an integer greater than 1600, but not
greater than 9999.
MM represents a month and must be a positive integer less than 13.
DD represents a day and must be a positive integer less than 32, provided that it is valid for the specified
month and year combination.
The returned value is an integer that is the number of days the date represented by argument-1, succeeds December
31, 1600 in the Gregorian calendar.
>_Host_> Under OS/390 and VM, the INTDATE compiler option affects the starting date for the integer date
functions. For details, see the IBM COBOL for OS/390 & VM Programming Guide. <_Host_<

16. INTEGER-OF-DAY
The INTEGER-OF-DAY function converts a date in the Gregorian calendar from Julian date form (YYYYDDD) to
integer date form.
The function type is integer.
The function result is a 7-digit integer.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION INTEGER-OF-DAY__(argument-1)___________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be an integer of the form YYYYDDD whose value is obtained from the calculation (YYYY * 1000) + DDD.
328519205.doc

16

Infosys Technologies Limited

BOK

YYYY represents the year in the Gregorian calendar. It must be an integer greater than 1600, but not
greater than 9999.
DDD represents the day of the year. It must be a positive integer less than 367, provided that it is valid for
the year specified.

>_Host_> Under OS/390 and VM, the INTDATE compiler option affects the starting date for the integer date
functions. For details, see the IBM COBOL for OS/390 & VM Programming Guide. <_Host_<
The returned value is an integer that is the number of days the date represented by argument-1, succeeds December
31, 1600 in the Gregorian calendar.

17. INTEGER-PART
The INTEGER-PART function returns an integer that is the integer portion of the argument specified.
The function type is integer.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION INTEGER-PART__(argument-1)_____________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
If the value of argument-1 is zero, the returned value is zero. If the value of argument-1 is positive, the returned
value is the greatest integer less than or equal to the value of argument-1. If the value of argument-1 is negative, the
returned value is the least integer greater than or equal to the value of argument-1.

18. LENGTH
The LENGTH function returns an integer equal to the length of the argument in bytes. The function type is integer.
The function result is a 9-digit integer.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION LENGTH__(argument-1)___________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Can be a nonnumeric literal or a data item of any class or category
(except DBCS).
If argument-1, or any data item subordinate to argument-1, is described with the DEPENDING phrase of the
OCCURS clause, the contents of the data item referenced by the data-name specified in the DEPENDING phrase
are used at the time the LENGTH function is evaluated.
A data item described with USAGE IS POINTER or USAGE IS PROCEDURE-POINTER can be used as
argument-1 to the LENGTH function.
The ADDRESS OF special register can be used as argument-1 to the LENGTH function.
If the ADDRESS OF special register or LENGTH OF special register is used as argument-1 to the LENGTH
function, the result will always be 4, independent of the ADDRESS OF or LENGTH OF object.
If argument-1 is a nonnumeric literal, an elementary data item, or a group data item that does not contain a variable
occurrence data item, the value returned is an integer equal to the length of argument-1 in character positions.
328519205.doc

17

Infosys Technologies Limited

BOK

If argument-1 is a group data item containing a variable occurrence data item, the returned value is an integer
determined by evaluation of the data item specified in the DEPENDING phrase of the OCCURS clause for that
variable occurrence data item. This evaluation is accomplished according to the rules in the OCCURS clause
regarding the data item as a sending data item. For more information, see the discussions of the OCCURS clause and
USAGE clause.
If argument-1 is a null-terminated nonnumeric literal, then the returned value is the number of characters in the
literal excluding the null character that is added at the end of the literal.
The returned value includes implicit FILLER characters, if any.

19. LOG
The LOG function returns a numeric value that approximates the logarithm to the base e (natural log) of the
argument specified.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION LOG__(argument-1)______________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric. The value of argument-1 must be greater than zero.
The returned value is the approximation of the logarithm to the base e of argument-1.

20. LOG10
The LOG10 function returns a numeric value that approximates the logarithm to the base 10 of the argument
specified.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION LOG10__(argument-1)____________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric. The value of argument-1 must be greater than zero.
The returned value is the approximation of the logarithm to the base 10 of argument-1.

21. LOWER-CASE
The LOWER-CASE function returns a character string that is the same length as the argument specified with each
uppercase letter replaced by the corresponding lowercase letter.
The function type is alphanumeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION LOWER-CASE__(argument-1)_______________________________>< |
328519205.doc

18

Infosys Technologies Limited

BOK

|
|
|________________________________________________________________________|
argument-1
Must be class alphabetic or alphanumeric and must be at least one character in length.
The same character string as argument-1 is returned, except that each uppercase letter is replaced by the
corresponding lowercase letter.
The character string returned has the same length as argument-1.

22. MAX
The MAX function returns the content of the argument that contains the maximum value.
The function type depends on the argument types, as follows:
Argument Type
Function Type
Alphabetic
Alphanumeric
Alphanumeric
Alphanumeric
All arguments integer
Integer
Numeric (some arguments can be
Numeric
integer)
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION MAX__(____argument-1_|__)______________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric, alphanumeric, or alphabetic.
If more than one argument-1 is specified, the combination of alphabetic and alphanumeric arguments is allowed.
The returned value is the content of argument-1 having the greatest value. The comparisons used to determine the
greatest value are made according to the rules for simple conditions. If more than one argument has the same
greatest value, the leftmost argument having that value is returned.
If the type of the function is alphanumeric, the size of the returned value is the same as the size of the selected
argument.

23. MEAN
The MEAN function returns a numeric value that approximates the arithmetic average of its arguments.
The function type is numeric.
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION MEAN__(____argument-1_|__)_____________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the arithmetic mean of the argument-1 series. The returned value is defined as the sum of the
argument-1 series divided by the number of occurrences referenced by argument-1.

328519205.doc

19

Infosys Technologies Limited

BOK

24. MEDIAN
The MEDIAN function returns the content of the argument whose value is the middle value in the list formed by
arranging the arguments in sorted order.
The function type is numeric.
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION MEDIAN__(____argument-1_|__)___________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the content of argument-1 having the middle value in the list formed by arranging all
argument-1 values in sorted order.
If the number of occurrences referenced by argument-1 is odd, the returned value is such that at least half of the
occurrences referenced by argument-1 are greater than or equal to the returned value and at least half are less than or
equal. If the number of occurrences referenced by argument-1 is even, the returned value is the arithmetic mean of
the values referenced by the two middle occurrences.
The comparisons used to arrange the argument values in sorted order are made according to the rules for simple
conditions.

25. MIDRANGE
The MIDRANGE function returns a numeric value that approximates the arithmetic average of the values of the
minimum argument and the maximum argument.
The function type is numeric.
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION MIDRANGE__(____argument-1_|__)_________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the arithmetic mean of the value of the greatest argument-1 and the value of the least
argument-1. The comparisons used to determine the greatest and least values are made according to the rules for
simple conditions.

26. MIN
The MIN function returns the content of the argument that contains the minimum value.
The function type depends on the argument types, as follows:
Argument Type
Function Type
Alphabetic
Alphanumeric
Alphanumeric
Alphanumeric
All arguments integer
Integer
Numeric (some arguments can be
Numeric
328519205.doc

20

Infosys Technologies Limited

BOK

integer)
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION MIN__(____argument-1_|__)______________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric, alphanumeric, or alphabetic.
If more than one argument-1 is specified, the combination of alphabetic and alphanumeric arguments is allowed.
The returned value is the content of argument-1 having the least value. The comparisons used to determine the least
value are made according to the rules for simple conditions. If more than one argument-1 has the same least value,
the leftmost argument-1 having that value is returned.
If the type of the function is alphanumeric, the size of the returned value is the same as the size of the selected
argument-1.

27. MOD
The MOD function returns an integer value that is argument-1 modulo argument-2.
The function type is integer.
The function result is an integer with as many digits as the shorter of argument-1 and argument-2.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION MOD__(argument-1 argument-2)___________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be an integer.
argument-2
Must be an integer. Must not be zero.
The returned value is argument-1 modulo argument-2. The returned value is defined as:
argument-1 - (argument-2 * FUNCTION INTEGER (argument-1 / argument-2))
The following table illustrates the expected results for some values of argument-1 and argument-2.
___________________________________________________________________________
| Argument-1
| Argument-2
| Return
|
|________________________|_________________________|________________________|
| 11
|
5
|
1
|
|________________________|_________________________|________________________|
| -11
|
5
|
4
|
|________________________|_________________________|________________________|
| 11
| -5
| -4
|
|________________________|_________________________|________________________|
| -11
| -5
| -1
|
|________________________|_________________________|________________________|

328519205.doc

21

Infosys Technologies Limited

BOK

28. NUMVAL
The NUMVAL function returns the numeric value represented by the alphanumeric character string specified in an
argument. The function strips away any leading or trailing blanks in the string, producing a numeric value that can
be used in an arithmetic expression.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION NUMVAL__(argument-1)___________________________________>< |
|
|
|________________________________________________________________________|
argument-1
must be a nonnumeric literal or an alphanumeric data item whose content has either of the following formats:
________________________________________________________________________
|
|
| >_________________________________digit______________________________> |
|
|_space_| |_+_| |_space_| |
|_.____________| |
|
|
|_-_|
|
|_digit_|
|
|
|
|_.__digit________________|
|
|
|
| >____________________________________________________________________> |
|
|_space_|
|
|
|
|________________________________________________________________________|
________________________________________________________________________
|
|
| >_______________digit________________________________________________> |
|
|_space_| |
|_.____________| | |_space_| |_+__|
|
|
|
|_digit_|
|
|_-__|
|
|
|_.__digit________________|
|_CR_|
|
|
|_DB_|
|
|
|
| >____________________________________________________________________> |
|
|_space_|
|
|
|
|________________________________________________________________________|
space
A string of one or more spaces.
digit
A string of one or more digits. The totals number of digits must not exceed 18.
If the DECIMAL-POINT IS COMMA clause is specified in the SPECIAL-NAMES paragraph, a comma must be
used in argument-1 rather than a decimal point.
The returned value is an approximation of the numeric value represented by argument-1.

29. NUMVAL-C
The NUMVAL-C function returns the numeric value represented by the alphanumeric character string specified as
argument-1. Any optional currency sign specified by argument-2 and any optional commas preceding the decimal
point are stripped away, producing a numeric value that can be used in an arithmetic expression.
328519205.doc

22

Infosys Technologies Limited

BOK

The function type is numeric.


The NUMVAL-C function cannot be used if any of the following are true:

The program contains more than one CURRENCY SIGN clause in the SPECIAL-NAMES paragraph of
the Environment Division.
Literal-6 in the CURRENCY SIGN clause is a lowercase letter.
The PICTURE SYMBOL paragraph is specified in the CURRENCY SIGN clause.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION NUMVAL-C__(argument-1________________)_________________>< |
|
|_argument-2_|
|
|
|
|________________________________________________________________________|
argument-1
Must be a nonnumeric literal or an alphanumeric data item whose content has either of the following formats:
________________________________________________________________________
|
|
| >____________________________________________________________________> |
|
|_space_| |_+_| |_space_| |_cs_| |_space_|
|
|
|_-_|
|
|
|
| >____digit___________________________________________________________> |
|
|
| <__________ | |_.____________| | |_space_|
|
|
|
|___,__digit_|_|
|_digit_|
|
|
|
|_.__digit__________________________________|
|
|
|
|________________________________________________________________________|
________________________________________________________________________
|
|
| >____________________________________________________________________> |
|
|_space_| |_cs_| |_space_|
|
|
|
| >____digit___________________________________________________________> |
|
|
| <__________ | |_.____________| | |_space_|
|
|
|
|___,__digit_|_|
|_digit_|
|
|
|
|_.__digit__________________________________|
|
|
|
| >____________________________________________________________________> |
|
|_+__| |_space_|
|
|
|_-__|
|
|
|_CR_|
|
|
|_DB_|
|
|
|
|________________________________________________________________________|
space
A string of one or more spaces.
cs
The string of one or more characters specified by argument-2. At most, one copy of the characters specified by cs
can occur in argument-1.
digit
A string of one or more digits. The total number of digits must not exceed 18.

328519205.doc

23

Infosys Technologies Limited

BOK

If the DECIMAL-POINT IS COMMA clause is specified in the SPECIAL-NAMES paragraph, the functions of the
comma and decimal point in argument-1 are reversed.
argument-2
If specified, must be a nonnumeric literal or alphanumeric data item, subject to the following rules:
argument-2 must not contain any of the digits 0 through 9, any leading or trailing spaces, or any of the
special characters + - . ,
argument-2 can be of any length valid for an elementary or group data item, including zero
Matching of argument-2 is case-sensitive. For example, if you specify argument-2 as 'Dm', it will not match
'DM', 'dm' or 'dM'.
If argument-2 is not specified, the character used for cs is the currency symbol specified for the program.
The returned value is an approximation of the numeric value represented by argument-1.

30. ORD
The ORD function returns an integer value that is the ordinal position of its argument in the collating sequence for
the program. The lowest ordinal position is 1.
The function type is integer.
The function result is a 3-digit integer.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION ORD__(argument-1)______________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be one character in length and must be class alphabetic or alphanumeric.
The returned value is the ordinal position of argument-1 in the collating sequence for the program; it ranges from 1
to 256 depending on the collating sequence.

31. ORD-MAX
The ORD-MAX function returns a value that is the ordinal number position, in the argument list, of the argument
that contains the maximum value.
The function type is integer.
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION ORD-MAX__(____argument-1_|__)__________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric, alphanumeric, or alphabetic.
If more than one argument-1 is specified, the combination of alphabetic and alphanumeric arguments is allowed.
The returned value is the ordinal number that corresponds to the position of argument-1 having the greatest value in
the argument-1 series.
The comparisons used to determine the greatest valued argument-1 are made according to the rules for simple
conditions.

328519205.doc

24

Infosys Technologies Limited

BOK

If more than one argument-1 has the same greatest value, the number returned corresponds to the position of the
leftmost argument-1 having that value.

32. ORD-MIN
The ORD-MIN function returns a value that is the ordinal number of the argument that contains the minimum value.
The function type is integer.
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION ORD-MIN__(____argument-1_|__)__________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric, alphanumeric, or alphabetic.
If more than one argument-1 is specified, the combination of alphabetic and alphanumeric arguments is allowed.
The returned value is the ordinal number that corresponds to the position of the argument-1 having the least value in
the argument-1 series.
The comparisons used to determine the least valued argument-1 are made according to the rules for simple
conditions.
If more than one argument-1 has the same least value, the number returned corresponds to the position of the
leftmost argument-1 having that value.

33. PRESENT-VALUE
The PRESENT-VALUE function returns a value that approximates the present value of a series of future period-end
amounts specified by argument-2 at a discount rate specified by argument-1.
The function type is numeric.
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION PRESENT-VALUE__(argument-1____argument-2_|__)__________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric. Must be greater than -1.
argument-2
Must be class numeric.
The returned value is an approximation of the summation of a series of calculations with each term in the following
form:
argument-2 / (1 + argument-1) ** n
There is one term for each occurrence of argument-2. The exponent, n, is incremented from one by one for each
term in the series.

34. RANDOM
The RANDOM function returns a numeric value that is a pseudo-random number from a rectangular distribution.
The function type is numeric.
___ Format _____________________________________________________________
328519205.doc

25

Infosys Technologies Limited

BOK

|
|
| >>__FUNCTION RANDOM_________________________________________________>< |
|
|_(argument-1)_|
|
|
|
|________________________________________________________________________|
argument-1
If argument-1 is specified, it must be zero or a positive integer, up to and including (10**18)-1 which is the
maximum value that can be specified in a PIC9(18) fixed item; however, only those in the range from zero up to and
including 2,147,483,645 will yield a distinct sequence of pseudo-random numbers.
If a subsequent reference specifies argument-1, a new sequence of pseudo-random numbers is started.
If the first reference to this function in the run unit does not specify argument-1, the seed value used will be zero.
In each case, subsequent references without specifying argument-1 return the next number in the current sequence.
The returned value is exclusively between zero and one.
For a given seed value, the sequence of pseudo-random numbers will always be the same.

35. RANGE
The RANGE function returns a value that is equal to the value of the maximum argument minus the value of the
minimum argument.
The function type depends on the argument types, as follows:
Argument Type
Function Type
All arguments integer
Integer
Numeric (some arguments can be
Numeric
integer)
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION RANGE__(____argument-1_|__)____________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is equal to argument-1 with the greatest value minus the argument-1 with the least value. The
comparisons used to determine the greatest and least values are made according to the rules for simple conditions.

36. REM
The REM function returns a numeric value that is the remainder of argument-1 divided by argument-2.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION REM__(argument-1 argument-2)___________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric
argument-2
Must be class numeric. Must not be zero.
The returned value is the remainder of argument-1 divided by argument-2. It is defined as the expression:
argument-1 - (argument-2 * FUNCTION INTEGER-PART (argument-1/argument-2))
328519205.doc

26

Infosys Technologies Limited

BOK

37. REVERSE
The REVERSE function returns a character string of exactly the same length of the argument, whose characters are
exactly the same as those specified in the argument, except that they are in reverse order.
The function type is alphanumeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION REVERSE__(argument-1)__________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class alphabetic or alphanumeric and must be at least one character in length.
If argument-1 is a character string of length n, the returned value is a character string of length n such that, for 1 <= j
<= n, the character in position j of the returned value is the character from position n-j+1 of argument-1.

38. SIN
The SIN function returns a numeric value that approximates the sine of the angle or arc specified by the argument in
radians.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION SIN__(argument-1)______________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the approximation of the sine of argument-1 and is greater than or equal to -1 and less than or
equal to +1.

39. SQRT
The SQRT function returns a numeric value that approximates the square root of the argument specified.
The function type is numeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION SQRT__(argument-1)_____________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric. The value of argument-1 must be zero or positive.
The returned value is the absolute value of the approximation of the square root of argument-1.

328519205.doc

27

Infosys Technologies Limited

BOK

40. STANDARD-DEVIATION
The STANDARD-DEVIATION function returns a numeric value that approximates the standard deviation of its
arguments.
The function type is numeric.
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION STANDARD-DEVIATION__(____argument-1_|__)_______________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the approximation of the standard deviation of the argument-1 series. The returned value is
calculated as follows:
1. The difference between each argument-1 and the arithmetic mean of the argument-1 series is calculated and
squared.
2. The values obtained are then added together. This quantity is divided by the number of values in the
argument-1 series.
3. The square root of the quotient obtained is then calculated. The returned value is the absolute value of this
square root.
If the argument-1 series consists of only one value, or if the argument-1 series consists of all variable occurrence
data items and the total number of occurrences for all of them is one, the returned value is zero.

41. SUM
The SUM function returns a value that is the sum of the arguments.
The function type depends on the argument types, as follows:
Argument Type
Function Type
All arguments integer
Integer
Numeric (some arguments can be
Numeric
integer)
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION SUM__(____argument-1_|__)______________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the sum of the arguments. If the argument-1 series are all integers, the value returned is an
integer. If the argument-1 series are not all integers, a numeric value is returned.

42. TAN
The TAN function returns a numeric value that approximates the tangent of the angle or arc that is specified by the
argument in radians.
328519205.doc

28

Infosys Technologies Limited

BOK

The function type is numeric.


___ Format _____________________________________________________________
|
|
| >>__FUNCTION TAN__(argument-1)______________________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the approximation of the tangent of argument-1.

43. UNDATE
The UNDATE function converts a date field to a non-date for unambiguous use with non-dates.
If the NODATEPROC compiler option is in effect, the UNDATE function has no effect.
The function type depends on the type of argument-1:
Argument-1 Type Function Type

Alphanumeric
Alphanumeric
Integer
Integer
___ Format _____________________________________________________________
|
|
| >>__FUNCTION UNDATE__(argument-1)___________________________________>< |
|
|
|________________________________________________________________________|
argument-1
A date field.
The returned value is a non-date that contains the value of argument-1
unchanged.

44. UPPER-CASE
The UPPER-CASE function returns a character string that is the same length as the argument specified, with each
lowercase letter replaced by the corresponding uppercase letter.
328519205.doc

29

Infosys Technologies Limited

BOK

The function type is alphanumeric.


___ Format _____________________________________________________________
|
|
| >>__FUNCTION UPPER-CASE__(argument-1)_______________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class alphabetic or alphanumeric and must be at least one character in length.
The same character string as argument-1 is returned, except that each lowercase letter is replaced by the
corresponding uppercase letter.
The character string returned has the same length as argument-1.

45. VARIANCE
The VARIANCE function returns a numeric value that approximates the variance of its arguments.
The function type is numeric.
___ Format _____________________________________________________________
|
|
|
<____________
|
| >>__FUNCTION VARIANCE__(____argument-1_|__)_________________________>< |
|
|
|________________________________________________________________________|
argument-1
Must be class numeric.
The returned value is the approximation of the variance of the argument-1 series.
The returned value is defined as the square of the standard deviation of the argument-1 series. This value is
calculated as follows:
4. The difference between each argument-1 value and the arithmetic mean of the argument-1 series is
calculated and squared.
5. The values obtained are then added together. This quantity is divided by the number of values in the
argument series.
If the argument-1 series consists of only one value, or if the argument-1 series consists of all variable occurrence
data items and the total number of occurrences for all of them is one, the returned value is zero.

46. WHEN-COMPILED
The WHEN-COMPILED function returns the date and time the program was compiled as provided by the system on
which the program was compiled.
The function type is alphanumeric.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION WHEN-COMPILED__________________________________________>< |
|
|
|________________________________________________________________________|
Reading from left to right, the 21 character positions in the value returned can be interpreted as follows:
Character Positions Contents

328519205.doc

30

Infosys Technologies Limited

BOK

1-4
Four numeric digits of the year in the Gregorian calendar.
5-6
Two numeric digits of the month of the year, in the range 01 through 12.
7-8
Two numeric digits of the day of the month, in the range 01 through 31.
9-10
Two numeric digits of the hours past midnight, in the range 00 through 23.
11-12
Two numeric digits of the minutes past the hour, in the range 00 through 59.
13-14
Two numeric digits of the seconds past the minute, in the range 00 through 59.
15-16
Two numeric digits of the hundredths of a second past the second, in the range 00 through
99. The value 00 is returned if the system on which the function is evaluated does not have
the facility to provide the fractional part of a second.
17
Either the character '-' or the character '+'. The character '-' is returned if the local time
indicated in the previous character positions is behind Greenwich Mean Time. The character
'+' is returned if the local time indicated is the same as or ahead of Greenwich Mean Time.
The character '0' is returned if the system on which this function is evaluated does not have
the facility to provide the local time differential factor.
18-19
If character position 17 is '-', two numeric digits are returned in the range 00 through 12
indicating the number of hours that the reported time is behind Greenwich Mean Time. If
character position 17 is '+', two numeric digits are returned in the range 00 through 13
indicating the number of hours that the reported time is ahead of Greenwich Mean Time. If
character position 17 is '0', the value 00 is returned.
20-21

328519205.doc

31

Infosys Technologies Limited

BOK

Two numeric digits are returned in the range 00 through 59 indicating the number of
additional minutes that the reported time is ahead of or behind Greenwich Mean Time,
depending on whether character position 17 is '+' or '-', respectively. If character position 17
is '0', the value 00 is returned.
The returned value is the date and time of compilation of the source program that contains this function. If the
program is a contained program, the returned value is the compilation date and time associated with the containing
program.

47. YEAR-TO-YYYY
The YEAR-TO-YYYY function converts argument-1, a 2-digit year, to a 4-digit year. Argument-2, when added to
the year at the time of execution, defines the ending year of a 100-year interval, or sliding century window, into
which the year of argument-1 falls.
The function type is integer.
If the DATEPROC compiler option is in effect, then the returned value is an expanded date field with implicit
DATE FORMAT YYYY.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION YEAR-TO-YYYY__(argument-1________________)_____________>< |
|
|_argument-2_|
|
|
|
|________________________________________________________________________|
argument-1
Must be a non-negative integer that is less than 100.
argument-2
Must be an integer. If argument-2 is omitted, the function is
evaluated assuming the value 50 was specified.
The sum of the year at the time of execution and the value of argument-2
must be less than 10,000 and greater than 1,699.

Example
Two examples of return values from the YEAR-TO-YYYY function follow:
________________________________________________________________________
|
|
| Argument-2
| YEAR-TO-YYYY
|
| Current Year
| Argument-1 Value | Value
| Return Value
|
|_________________|__________________|_________________|_________________|
| 1995
| 4
| 23
| 2004
|
|_________________|__________________|_________________|_________________|
| 1995
| 4
| -15
| 1904
|
|_________________|__________________|_________________|_________________|
| 2008
| 98
| 23
| 1998
|
328519205.doc

32

Infosys Technologies Limited

BOK

|_________________|__________________|_________________|_________________|
| 2008
| 98
| -15
| 1898
|
|_________________|__________________|_________________|_________________|

48. YEARWINDOW
If the DATEPROC compiler option is in effect, the YEARWINDOW function returns the starting year of the
century window specified by the YEARWINDOW compiler option. The returned value is an expanded date field
with implicit DATE FORMAT YYYY.
If the NODATEPROC compiler option is in effect, the YEARWINDOW function returns 0.
The function type is integer.
___ Format _____________________________________________________________
|
|
| >>__FUNCTION YEARWINDOW_____________________________________________>< |
|
|
|________________________________________________________________________|

Contact Person:
Amol Barbare

328519205.doc

Emp. No.: 2958

33

You might also like