+ All Categories
Home > Documents > Mapping_PL1_to_COBOL-0[1].3.doc

Mapping_PL1_to_COBOL-0[1].3.doc

Date post: 27-Oct-2015
Category:
Upload: deepak-dada
View: 24 times
Download: 0 times
Share this document with a friend
Description:
na
175
LEGENDS/COLOR CODES The topic is often used in the PL/I programs / High priority topics The topic needs more investigation and input / Reference material not adequate The topic is to be covered later / Low priority topics COBOL programs to be tested / COBOL programs not working properly COBOL programs tested and working properly General Documentation for PL/I – COBOL Constructs Introduction PL/I (Programming Language / 1) is a general purpose language supporting scientific, data processing, text processing, systems programming Supports features of COBOL,PASCAL and ALGOL COBOL is a Business-Oriented Language COBOL is one of the most widespread commercial applications languages in use today. COBOL is an abbreviation for COmmon Business Oriented Language It provides : Structured programming Powerful exception handling capabilities Dynamic storage management Extensive data types, arrays and structures, all of which can be COBOL provides: Variables, Structures, Literals, and Constants Assignment and Terminal Interaction Built-In (Intrinsic) Functions Tables and Pointers Internal Use Only
Transcript
Page 1: Mapping_PL1_to_COBOL-0[1].3.doc

LEGENDS/COLOR CODES

The topic is often used in the PL/I programs / High priority topics

The topic needs more investigation and input / Reference material not adequate

The topic is to be covered later / Low priority topics

COBOL programs to be tested / COBOL programs not working properly

COBOL programs tested and working properly

General Documentation for PL/I – COBOL Constructs

Introduction

PL/I (Programming Language / 1) is a general purpose language supporting scientific, data processing, text processing, systems programming Supports features of COBOL,PASCAL and ALGOL

COBOL is a Business-Oriented LanguageCOBOL is one of the most widespread commercial applications languages in use today.COBOL is an abbreviation for COmmon Business Oriented Language

It provides : Structured programming Powerful exception handling capabilities Dynamic storage management Extensive data types, arrays and structures, all of which can be used in combination Extensive input/output capabilities Large no of built-in functions

COBOL provides: Variables, Structures, Literals, and Constants Assignment and Terminal Interaction Built-In (Intrinsic) Functions Tables and Pointers

Column 1 reserved for use by O/S (e.g. %PROCESS, %INCLUDE etc.).Columns 2 to 72 are used for coding PL/1 statements. Each statement should end with a semicolon.Column 73-80 is used for the program identification names PL/1 statements are organized as blocks

COBOL programs must be written in the COBOL reference format.

The following areas are described below in terms of a 72-character line:Sequence Number AreaColumns 1 through 6

Internal Use Only

Page 2: Mapping_PL1_to_COBOL-0[1].3.doc

Indicator AreaColumn 7Positions 8--72 of a standard COBOL program contain program statements. If an entry is to be coded in Area A, it may begin in position 8, 9, 10, or 11.Most often, Area A entries begin in position 8. If an entry is to be coded in Area B, it may begin anywhere after position 11.Area AColumns 8 through 11Area BColumns 12 through 72

Basic Programming on Shell

Every PL/I program looks as follows:

MYPROG:PROCEDURE OPTIONS(MAIN); . /* this is a comment */ .END MYPROG;

MYPROG: is a labelPROCEDURE: tells the compiler that this statement marks the beginning of the block of PL/I statements.OPTIONS (MAIN) indicates entry point of program and must be indicated for one procedure in the programComments are encased in /* */

Every COBOL program consists of four separate divisions, each with a specific function, which are the following:

IDENTIFICATION DIVISION Identifies the program to the computer.ENVIRONMENT DIVISION Describes the specific computer equipment that will be used.DATA DIVISION Describes the input and output formats. Describes any constants and work areas.PROCEDURE DIVISION Contains the instructions necessary for reading input, processing it, and creating output.

A comment line is any line with an asterisk (*) or slash (/) in the indicator area (column 7) of the line. The comment may be written anywhere in Area A and Area B of that line, and may consist of any combination of characters from the character set of the computer. A comment line may be placed anywhere in the program following the Identification Division header.Multiple comment lines are allowed. Each must begin with either an asterisk (*) or a slash (/) in the indicator area.

Internal Use Only

Page 3: Mapping_PL1_to_COBOL-0[1].3.doc

Declarations

Data Types PL/I Attributes COBOL Data Description

Halfword Integer REAL FIXED BIN (15,0) PIC S9(4) USAGE COMP

Or

PIC S9(4) USAGE IS BINARY

Fullword Integer REAL FIXED BIN (31,0) PIC S9(9) USAGE COMP

Or

PIC S9(9) USAGE IS BINARY

Packed Decimal REAL FIXED DEC (m,n) PIC S9(m-n).9(n) USAGE IS COMP-3

Short Floating REAL FLOAT DEC (6) or REAL FLOAT BIN (21) USAGE IS COMP-1

Long Floating REAL FLOAT DEC (16) or REAL FLOAT BIN (53) USAGE IS COMP-2

Character String CHARACTER(n) PIC X(n)

Bit BIT(1) BYTE

Examples of PL/1 to COBOL Declarations

Note: Underscores should not be used in COBOL declarations.

PL/I Declarations COBOL Declarations

DCL REVFLGDB_PCB_PTR POINTER; 01 REVFLGDB-PCB-PTR USAGE IS POINTER

DCL 1 READ_AREA STATIC CHAR(250); 01 READ-AREA PIC X (250).

5 TP_10_RA_BILL_PROV_LOB PIC '999', 05 TP-10-RA-BILL-PROV-LOB PIC 9(3).

5 TP_10_RA_CLAIM_NO PIC '(9)9', 05 TP-10-RA-CLAIM-NO PIC 9(9).

5 WRK1_LINE_AMT_CHG PIC '(5)9V99', 05 WKR1_LINE_AMT_CHG PIC 9(5)v99.

10 IO_TIME FIXED DEC(7,1), 10 IO-TIME PIC S9(7)v9 COMP-3.

5 IO_MSG_COUNT FIXED BIN(31,0), 05 IO-MSG-COUNT PIC S9(9) USAGE COMP.

Internal Use Only

Page 4: Mapping_PL1_to_COBOL-0[1].3.doc

5 COV_FILL CHAR(2) INIT(' '); 05 COV-FILL PIC X(2) VALUE SPACES.

DCL PARMCNT5 FIXED BIN(31,0) INIT(5); 01 PARMCNT5 PIC S9(9) USAGE COMP VALUE ‘5’.

5 END_OF_TABLE BIT(1) INIT('0'B), 05 END-OF-TABLE PIC X(5) VALUE ‘FALSE’

5 START_OF_TABLE BIT(1) INIT('1'B), 05 START-OF-TABLE PIC X(4) VALUE ‘TRUE’

5 SELCARD1_CLMNO FIXED DECIMAL (09) INIT(0) 05 SELCARD1-CLMNO PIC S9(9) COMP-3 VALUE 0.

5 W_COUNT_STATUS FIXED BIN (31,0) INIT(0) 05 W-COUNT-STATUS PIC S9(9) BINARY VALUE 0.

10 PCDH7_FIL16 CHAR(29) INIT((29)'-') 10 PCDH7_FIL16 PIC X(29) VALUE ‘-‘ ALL.

10 D1_AGE_N_HSE PIC 'ZZ9'

DCL 1 REMARKS_TABLE(22) STATIC,

5 RMK_CODE CHAR(2) INIT(' ','PN','PH','PV','ES',

'EE','DN','DS','DE','SC','SE',

'SM','SA','SO','PC','DC','IS',

'PS','SP','FA','FO','FP'),

5 RMK_NUM PIC '99' INIT('00','76','77','78','79',

'80','81','82','83','84','85',

'86','87','88','00','00','89',

'90','91','92','93','94');

DCL 1 PEND_CLM_BY_PLCHLDR_IN BASED(REC_PTR),

%INCLUDE BATCH(A0752405);

10 REP6_FIELD1 PIC 'ZZ,ZZZ',

DCL JUL_DATE(10) PIC '(5)9' STATIC INIT((10) '00000');

5 FAM_DTL1_CURR_PRD_AMT PIC 'ZZZZZV.99'

5 FAM_DTL1_CURR_DEF_AMT PIC 'ZZZZ9V.99-'

DCL POLH_RCD STATIC CHAR(80);

Internal Use Only

Page 5: Mapping_PL1_to_COBOL-0[1].3.doc

DCL BUC_TERM_DTE_C CHAR(6) DEF POLH_RCD POS(25);

5 CAO_CURPOLNO PIC '(7)9' INIT(0)

5 W_EDT_NUMERIC PIC'(7)-9'

Declared Attributes Default Attributes

DECIMAL FIXED (5,0)DECIMAL FLOAT (6)BINARY FIXED (15,0)BINARY FLOAT (21)DECIMAL FLOAT(6)BINARY FLOAT(21)FIXED DECIMAL(5,0)FLOAT DECIMAL(6)None-initial I-N BINARY FIXED(15)None-other than I-N DECIMAL FLOAT(6)

N/A

Declare Statements & Attribute Types

Varying Attribute

The VARYING attribute specifies that the variable is to represent varying-length strings, in which case length (in the BIT, CHARACTER, or GRAPHIC attribute) specifies the maximum length. The length at any time is the length of the current value. The storage allocated for varying-length strings is 2 bytes longer than the declared maximum length. The leftmost 2 bytes hold the string's current length (in bytes for a character variable, bits for a bit variable, or graphics for a graphic variable).

EXAMPLE :

N/A

Internal Use Only

Page 6: Mapping_PL1_to_COBOL-0[1].3.doc

DCL ITEM CHAR(20) VARYING;

When a string smaller than 20 char is assigned to this variable, the string length is adjusted to a size just sufficient to hold the string obviating the need to pad on the right with blanks When a string larger than 20 char is assigned truncation takes place

DEFINED Attribute

Allows to equate two or more different names to the same storage area

EXAMPLE :

DCL A CHAR(20);DCL 1 B DEF A,

2 B-1 CHAR(10),2 B-2 FIXED DECIMAL(10);

DCL C CHAR(10) DEF A;

REDEFINES Clause

The REDEFINES clause allows you to use different data description entries to describe the same computer storage area.

EXAMPLE :

05 A PIC X(20).05 B REDEFINES A. 10 B-1 PIC X(10). 10 B-2 PIC 9(10).05 C PIC X(10) REDEFINES A.

In this example, A is the redefined item, and B and C are the redefining item. Redefinition begins with B and includes the two subordinate items B-1 and B-2.

One or more redefinitions of the same storage area are permitted. The entries giving the new descriptions of the storage area must immediately follow the description of the redefined area without intervening entries that define new character positions. Multipleredefinitions must all use the data-name of the original entry that defined this storage area. For example:

05 A PIC 9999.05 B REDEFINES A PIC 9V999.05 C REDEFINES A PIC 99V99.

Internal Use Only

Page 7: Mapping_PL1_to_COBOL-0[1].3.doc

INITIAL Attribute

The INITIAL attribute specifies an initial value or values assigned to a variable at the time storage is allocated for it. Only one initial value can be specified for an element variable; more than one can be specified for an array variable. A structure variable can be initialized only by separate initialization of its elementary names, whether they are element or array variables.

EXAMPLE :

DCL SUBJ CHAR(14) INIT(‘PL/I TRAINING’);

VALUE Clause

The VALUE clause specifies the initial contents of a data item or the value(s) associated with a condition name. In the Working-Storage Section, the VALUE clause can be used in condition-name entries, or in specifying the initial value of any data item. If the initial value is not explicitly specified, it is unpredictable.

SYNTAX 1: ………. VALUE [IS] literal.

EXAMPLE :

05 SUBJ PIC X(14) VALUE 'COBOL TRAINING'. Note: A VALUE clause specified in a data description entry that contains or is subordinate to an OCCURS clause causes every occurrence of the associated data item to be assigned the specified value. Each structure that contains the DEPENDING ON phrase of the OCCURS clause is assumed to contain the maximum number of occurrences for the purposes of VALUE initialization.

The editing characters must be included in the literal. For example, if the item is defined as PICTURE +999.99 and the value is to be +12.34, then the VALUE clause should be specifiedas VALUE "+012.34".

SYNTAX 2:

88 condition-name-1 VALUE[S] [IS/ARE] literal-1 [THRU] [literal-2].

Figurative ConstantsFigurative constants are reserved words that name and refer to specific constant values and can be used with the VALUE clause to initialize values to the variables. The reserved words for figurative constants and their meanings are:

Internal Use Only

Page 8: Mapping_PL1_to_COBOL-0[1].3.doc

ZERO/ZEROS/ZEROESRepresents the numeric value zero (0), or one or more occurrences of the nonnumeric character zero (0), depending on context.When the context cannot be determined, a nonnumeric zero is used.

SPACE/SPACESRepresents one or more blanks or spaces. SPACE is treated as a nonnumeric literal.

HIGH-VALUE/HIGH-VALUESRepresents one or more occurrences of the character that has the highest ordinal position in the collating sequence used. For the EBCDIC collating sequence, the character is X'FF'; for other collating sequences, the actual character used depends on the collating sequence indicated by the locale. HIGH-VALUE is treated as a nonnumeric literal.

LOW-VALUE/LOW-VALUESRepresents one or more occurrences of the character that has the lowest ordinal position in the collating sequence used. For the EBCDIC collating sequence, the character is X'00'; for other collating sequences, the actual character used depends on the collating sequence. LOW-VALUE is treated as a nonnumericliteral.

QUOTE/QUOTESQUOTE or QUOTES cannot be used in place of a quotation markto enclose a nonnumeric literal.

ALL literalRepresents one or more occurrences of the string of characters composing the literal. The literal must be either a nonnumeric literal or a figurative constant other than the ALL literal. When a figurative constant, other than the ALL literal is used, the word ALL is redundant and is used for readability only.

Internal Use Only

Page 9: Mapping_PL1_to_COBOL-0[1].3.doc

Internal Use Only

Page 10: Mapping_PL1_to_COBOL-0[1].3.doc

Declaring PICTURE Attributes

Variables, which are to hold both types of data, must be declared using picture attribute. A picture specification consists of a sequence of picture characters enclosed in quotation marks, which is either part of the PICTURE attribute or part of the P format itemfor edit-directed input and output.

Picture edit characters must be enclosed in quotation marks.

Minus and decimal point use storage spaces. If the number is non-negative, it is replaced by a blank.

A character pictured item can consist of alphabetic characters, decimal digits, blanks, and any other EBCDIC codes.

A numeric character pictured item can consist only of decimal digits, an optional decimal point, an optional letter E, and, optionally, one or two plus or minus signs.

Picture Characters for Character Data

Symbol Meaning

X Any character of the 256 possible bit combinations represented by the 8-bit byte.

A Any alphabetic character, #, @, $, or blank. 9 Any digit, or blank. (Note that the 9 picture specification character in numeric character specifications is different in that the corresponding character can only be a digit).

Picture Characters for Numeric Character Data

Symbol Meaning

PICTURE Clause

The PICTURE clause specifies the general characteristics and editing requirements of an elementary item.

The PICTURE clause must be specified for every elementary item except an index data item or the subject of the RENAMES clause. In these cases, use of this clause is prohibited.

The PICTURE clause can be specified only at the elementary level.

Symbol Meaning

A A character position that can contain only a letter Of the alphabet or a space. Occupies 1 byte

B For Non-DBCS data—a character position into which the space character is inserted. Occupies 1 byte

E Marks the start of the exponent in an external floating point item. Occupies 1 byte

G A DBCS character position Occupies 2 bytes

N A DBCS character position Occupies 2 bytes

P An assumed decimal scaling position. Used to Specify the Location of an assumed decimal point when the point is not within the number that appears in the data item. Not counted in the size of the data item. Scaling position characters are counted in determining the maximum number of digit positions (18) in numeric-edited items or in items that appear as arithmetic operands. The size of the value is the number of digit positions Represented by the PICTURE character-string.

Internal Use Only

Page 11: Mapping_PL1_to_COBOL-0[1].3.doc

9 V Digit and decimal-point characters

Z * Zero suppression characters

, . / B Insertion characters

S + - $ Signs and currency character

CR DB T I R Y Credit, debit, overpunched, and zero replacement characters

K E Exponent specifiers

F Scaling factor

S An indicator of the presence (but not the Representation nor, necessarily, the position) of an operational sign. An operational sign indicates whether the value of an item Involved in an operation is positive or negative. Not counted in determining the size of the elementary Item, unless an associated SIGN clause specifies the SEPARATE CHARACTER phrase (which would Occupy 1 Byte). Must be written as the leftmost Character in the PICTURE string.

V An indicator of the location of the assumed decimal point. Does not represent a character position. When the assumed decimal point is to the right of The Rightmost symbol in the string, the V is Redundant.Not counted in the size of the elementary item Can appear only once in a character-string.

X A character position that can contain any allowable Character from the character set of the computer. Occupies 1 byte

Z A leading numeric character position. When that position contains a zero, a space character replaces the zero. Each 'Z' is counted in the size of the data item.

9 A character position that contains a numeral. Each '9' is counted in the size of the data item.

0 A character position into which the numeral zero is inserted. Each '0' is counted in the size of the data item.

/ A character position into which the slash character is inserted. Each '/' is counted in the size of the data item.

, A character position into which a comma is inserted.Internal Use Only

Page 12: Mapping_PL1_to_COBOL-0[1].3.doc

EXAMPLE :

DECLARE PART PICTURE 'AAA99X';PUT EDIT PART (P 'AAA99X');

The following values are valid for PART:'ABC12M''bbb09/''XYZb13'The following values are not valid for PART (the invalid characters are underscored):'AB123M''ABC1/2''Mb#A5;'

DCL COUNT PICTURE '999';The following values are valid for COUNT:‘123’‘000’The following values are not valid for COUNT (the invalid

Each ',' is counted in the size of the data item.

. An editing symbol that represents the decimal point for alignment purposes. In addition, it represents a character position into which a period is inserted.

Each '.' is counted in the size of the data item.If the period insertion character is the last symbol in thePICTURE character-string, the PICTURE clause must be thelast clause of that data description entry and must beimmediately followed by the separator period.

+ Editing sign control symbols. - Each represents the character position into which the editing CR sign control symbol is placed. Each character used in theDB symbol is counted in determining the size of the data item. The symbols are mutually exclusive in one character-string.

* A check protect symbol-a leading numeric character position into which an asterisk is placed when that position contains a zero. Each asterisk (*) is counted in the size of the item.

cs Currency symbol, representing a character position into which a currency sign value is placed. The default currency symbol is the dollar sign ($). The first occurrence of a currency symbol adds the number of characters in the currency sign value to the size of the data item. Each subsequent occurrence adds one character to the size of the data item.

EXAMPLE :

01 PART-1 PIC AAA99X VALUE ‘ABC12M’. 01 PART-2 PIC AAA99X VALUE ‘ 09/’. 01 PART-3 PIC AAA99X VALUE ‘XYZ 13’.

01 COUNT-1 PIC 9(3) VALUE ZEROS. Internal Use Only

Page 13: Mapping_PL1_to_COBOL-0[1].3.doc

characters are underscored):‘A23’‘1b2’

Picture Repetition FactorsA picture repetition factor specifies the number of repetitions of the immediately following picture character. A picture repetition factor is an integer, n, enclosed in parentheses. No blanks are allowed within the parentheses. If n is 0, the picture character is ignored.

EXAMPLE :

The following picture specification results in the same description:DCL NUM-1 PICTURE '999V99';DCL NUM-2 PICTURE '(3)9V(2)9';

01 COUNT-2 PIC 9(3) VALUE 123.

EXAMPLE :

01 NUM-2 PIC 9(3)V9(2).

Logical and Relational Operators

Comparison operators which are used in IF condition and other expressions are as follows :

Relational Operator Meaning

< less than ¬< not less than> greater than ¬> not greater than= equal to¬= not equal to<= less than or equal to >= greater than or equal to

Bit string operators are as follows :

Logical Operator

Relational Operator Can Be Written Meaning

IS GREATER THAN IS > Greater thanIS NOT GREATER THAN IS NOT > Not greater thanIS LESS THAN IS < Less thanIS NOT LESS THAN IS NOT < Not less thanIS EQUAL TO IS = Equal toIS NOT EQUAL TO IS NOT = Not equal toIS GREATER THAN OREQUAL TO IS >= Is greater than or equal toIS LESS THAN OR EQUAL TO IS <= Is less than or equal to

Logical Operator Name Meaning

Internal Use Only

Page 14: Mapping_PL1_to_COBOL-0[1].3.doc

¬ (alt-170) NOT

& AND

| OR

A concatenation operation is specified by combining operands with the concatenation infix operator:

Concatenation character is ||

If an operand requires conversion for concatenation, the result depends upon the length of the string to which the operand is converted. For example:

The value of operand A is '010111'BThe value of operand B is '101'BThe value of operand C is 'XY,Z'The value of operand D is 'AA/BB'

Combinations of operations

A||B yields '010111101'BA||A||B yields '010111010111101'BC||D yields 'XY,ZAA/BB'D||C yields 'AA/BBXY,Z'B||D yields '101AA/BB'

AND Logical conjunctionThe truth value is true when both conditions are true.

OR Logical Inclusive ORThe truth value is true when either or both conditions are true.

NOT Logical NegationReversal of truth value (the truth value is true if the condition is false).

A concatenation operation is specified by combining operands with the concatenation infix operator: It’s same as PL/1.

Concatenation character is ||

If an operand requires conversion for concatenation, the result depends upon the length of the string to which the operand is converted. For example:

The value of operand A is '010111'BThe value of operand B is '101'BThe value of operand C is 'XY,Z'The value of operand D is 'AA/BB'

Combinations of operations

A||B yields '010111101'BA||A||B yields '010111010111101'BC||D yields 'XY,ZAA/BB'D||C yields 'AA/BBXY,Z'B||D yields '101AA/BB'

Arithmetic Operators

Symbol Operation

** Exponentiation

Symbol Operation

** Exponentiation

Internal Use Only

Page 15: Mapping_PL1_to_COBOL-0[1].3.doc

* Multiplication/ Division+ Addition- Subtraction

UNARY OPERATORS: - Multiplication by –1+ Multiplication by +1.

The plus sign and the minus sign can appear as prefix operators or as infix operators.

RULES FOR ARITHMETIC OPERATIONS:

Rule 1: The order in which arithmetic operations are performed is:Unary operators Exponentiation Multiplication or Division Addition or Subtraction

Rule 2: When parenthesis are specified, the expression with in the parenthesis will be evaluated first, starting with the innermost parenthesis.

Rule 3 : The prefix operators allowed areNot

+ Positive- Negative

Rule 4: Any expression or element, raised to a power may have either a positive or negative value. The exponent itself may be an expression.

Rule 5 : If two or more operators of the highest priority appear in the same expression, the order of priority of those operators is from left to right.

* Multiplication / Division + Addition - Subtraction

UNARY OPERATORS:

- Multiplication by –1+ Multiplication by +1

RULES FOR ARITHMETIC OPERATIONS:

Rule 1:The order in which arithmetic operations are performed is: Unary operators Exponentiation Multiplication or Division Addition or Subtraction

Rule 2: When parenthesis are specified, the expression with in the parenthesis will be evaluated first, starting with the innermost parenthesis.

Rule 3: If the first operator in an arithmetic expression is a unary operator, it must be immediately preceded by a left parenthesis if that arithmetic expression immediately follows an identifier or another arithmetic expression.

Rule 4:Exponents in fixed-point exponential expressions cannot contain more than 9 digits. The compiler will truncate any exponent with more than 9 digits.

Rule 5:When the order of consecutive operations at the same hierarchic level is not completely specified by parentheses, the order is from left to right.

Internal Use Only

Page 16: Mapping_PL1_to_COBOL-0[1].3.doc

EXAMPLE : The order of evaluation of -A ** -Y is

1. Negation (-Y)2. Exponentiation (A**-Y)3. Negation

EXAMPLE: The order of evaluation of -A ** -Y is

1. Negation (-Y)2. Exponentiation (A**-Y)3. Negation

Conditional Statements

A. IF Statements

1.SIMPLE IF2.COMPOUND IF3.NESTED IF

1. SIMPLE IF

Use Simple IF statement when one of the processing choices is no action. Because the ELSE clause is optional,

Syntax : IF expr THEN statement(s);

Example : IF A=B THEN

DO; X=1; Y=2; END;

SIMPLE IF

Use Simple IF statement when one of the processing choices is no action. Because the ELSE clause and END-IF is optional, (The word THEN is optional in a COBOL program.)

Syntax: : IF expr [THEN] Statement(s) [END-IF].

Example : IF A = B THEN MOVE 1 TO X MOVE 2 TO Y END –IF.

2. COMPOUND IF COMPOUND IF

Internal Use Only

Page 17: Mapping_PL1_to_COBOL-0[1].3.doc

Use IF . . . ELSE to code a choice between two processing actionsA Semicolon is given after the END-IF which symbolizes the logical end of the IF– ELSE Statement.END-IF is optional

Syntax: IF expr THEN

Statement(s)-1;ELSE

Statement(s)-2;

Example :IF A=B THEN X = 1;ELSE X = 2;

Use IF . . . ELSE to code a choice between two processing actions. A period is given after the END-IF which symbolizes the logical end of the IF– ELSEStatement. END-IF is optional (The word THEN is optional in a COBOL program.) Syntax: IF expr [THEN] Statement(s)-1 ELSE Statement(s)-2 [END-IF].

Example: IF A = B MOVE 1 TO X ELSE MOVE 2 TO X END-IF.

3. NESTED IF

When an IF statement has another IF statement as one of its possible processing Branches, these IF statements are said to be nested IF’s.Theoretically, there is no limitation on the depth of nested IF statements. However, when the program has to test a variable for more than two values, SELECT is the better choice.END-IF is optional.

Syntax:IF expr-1 THEN IF expr-2 THEN

Statement(s)-1; ELSE

Statement(s)-2;

NESTED IF

When an IF statement has another IF statement as one of its possible processingBranches, these IF statements are said to be nested Ifs.Theoretically, there is no limitation on the depth of nested IF statements. However, when the program has to test a variable for more than two values, EVALUATE is the better choice.END-IF is optional

Syntax: IF expr-1 IF expr-2 Statement(s)-1 ELSE Statement(s)-2

Internal Use Only

Page 18: Mapping_PL1_to_COBOL-0[1].3.doc

ELSE Statement(s)-3;

Example:IF A = B THEN

IF A = C THEN X = 1; ELSE X = 2;ELSE X = 3;

3. 1 NULL THEN/ELSE IN NESTED IF

Example-1 :IF A=B THEN IF A=C THEN; /* Null Then */ ELSE

X = 1; ELSE

X=2;Example-2:

IF A=B THEN IF A=C THEN X=1; ELSE; /* Null Else */ELSE

X=2;

END-IF Statement(s)-3 ELSE Statement(s)-4 END-IF.

Example: IF A = B IF A = C MOVE 1 TO X ELSE MOVE 2 TO X END-IF ELSE MOVE 3 to X END-IF.

Example-1:IF A=B THEN IF A=C THEN CONTINUE /* Null Then */ ELSE

MOVE 1 TO X END-IF

ELSE MOVE 2 TO X END-IF.

Example-2: For Null else CONTINUE statement can be used IF A=B THEN

IF A=C THEN MOVE 1 TO X ELSE CONTINUE /* Null Else */

END-IFELSE

Internal Use Only

Page 19: Mapping_PL1_to_COBOL-0[1].3.doc

MOVE 2 TO X END-IF.

Internal Use Only

Page 20: Mapping_PL1_to_COBOL-0[1].3.doc

B. SELECT AND END Statement

A select-group provides a multi-way conditional branch. A select-group contains a SELECT statement, optionally one or more WHEN statements, optionally an OTHERWISE statement, and an END statement.

WHEN Specifies an expression or expressions that are evaluated and compared with the saved value from the SELECT statement. If an expression is found that is equal to the saved value, the evaluation of expressions in WHEN statements is terminated, and the unit of the associated WHEN Statement is executed. If no such expression is found, the unit of the OTHERWISE statement is executed.

The WHEN statement must not have a label prefix.

Syntax : SELECT [optional expr];

WHEN expr-1 action-1; WHEN expr-2 action-2;

- - WHEN expr-n action-n;

[OTHERWISE action-m;] END;

Example :

SELECT (LANG_CODE); WHEN(‘P’) CALL PL1_FUN; WHEN(‘C’) CALL COBOL_FUN; OTHERWISE CALL ERROR_FUN; END;

EVALUATE STATEMENT

The EVALUATE statement provides a shorthand notation for a series of nested IF Statements. It can evaluate multiple conditions. That is, the IF statements can be Made up of compound conditions.

Example:

The following example shows how you can assign a value for a field in an output Record based on the transaction code of an input record.-

Syntax :

EVALUATE [(TRUE/FALSE)]/[EXPR]WHEN expr-1 Action-1WHEN expr-2 Action-2-WHEN expr-n Action-nWHEN OTHER Action-m END-EVALUATE.

Example :

01 Program-Input Record 05 LANG-CODE Pic X. 88 PL1-program Value "P". 88 COBOL-Program Value "C".

Internal Use Only

Page 21: Mapping_PL1_to_COBOL-0[1].3.doc

Evaluate LANG-CODEWhen ‘P’ Perform PL1_FUNWhen ‘C’ Perform COBOL_FUNWhen OTHER Perform ERROR_FUNEnd-Evaluate.

C. DO STATEMENTS1.DO ... WHILE 2. DO ... UNTIL3.DO-LOOP 4. Nested DO loops

Internal Use Only

Page 22: Mapping_PL1_to_COBOL-0[1].3.doc

1. DO-WHILE

Often do groups have to be executed until a certain condition is met, these cases can be handled with while statement. This condition terminates when the expression becomes false

Syntax :DO WHILE expr;

Statement-1; - - Statement-n;

END;

Example: I = 1;

DO WHILE I < 10; Call Function-1; Call Function -2; Call Function-3 I = I + 1;

END;

PERFORM – UNTIL WITH TEST BEFORE STATEMENT

Syntax : PERFORM [ proc-1 [{ THROUGH/THRU} proc-n]] [WITH TEST BEFORE] UNTIL condition-1 Statement-1 - - Statement-n [END-PERFORM].

NOTE : The WITH TEST BEFORE phrase is the default and so is rarely explicitly stated

Example:

MOVE 1 TO I.PERFORM Procedure-1 THROUGH Procedure-3 WITH TEST BEFORE UNTIL I > 10 I = I + 1 END-PERFORM.

OR

MOVE 1 TO I.PERFORM Procedure-1 THROUGH Procedure-3 WITH TEST BEFORE VARYING I FROM 1 BY 1 UNTIL I > 10

END-PERFORM.

2. DO-UNTIL PERFORM –UNTIL –STATEMENT

Internal Use Only

Page 23: Mapping_PL1_to_COBOL-0[1].3.doc

Syntax:DO UNTIL expr;

Statement-1; - - Statement-n;

END;

Example : I = 1; DO UNTIL I > 10; Call Function-1; Call Function -2; Call Function-3 I = I + 1;

END;

Syntax: PERFORM [ proc-1 [{ THROUGH/THRU} proc-n] [WITH TEST AFTER] VARYING iden1 FROM{ iden2/literal1} BY {inden3/literal2} UNTIL condition-1 [END-PERFORM]Where, Iden1, iden2, iden3 = identifiers. Proc-1, proc-n =procedures.

Note : WITH TEST { BEFORE/AFTER}Options are available only in 1985 Cobol standards which can be omitted.

Example:

PERFORM proc-1 THROUGH proc-n VARYING I FROM 1 BY 1 UNTIL I > 10

3. DO Expressions

Iterative do group used in an IF statement is also used to put several PL/1 statements together, but in this type of do group these statements are as a rule executed several times over a group.

Syntax: DO control-variable = exp1 [TO exp2 [BY exp3]]; Statement-1; - Statement-n; END; BY statement: if the control variable is to be increased by a step

PERFORM---TIMES –STATEMENT PERFORM-VARYING-UNTIL can also be used for the Do Expression.

Syntax : PERFROM [proc1] {integer/identifier}TIMES [imperative statement] END-PERFORM.

Internal Use Only

Page 24: Mapping_PL1_to_COBOL-0[1].3.doc

other than 1, then you use by statement. In do groups you can also count downwards.

Example : DO COUNT = 1 TO 20 BY 1;

A = A + B; END;

Note: Nesting of do groups to a maximum of 49 is allowed by PL/1 optimizing compiler.

Example : PERFORM 20 TIMES A = A + B END-PERFORM.

OR

PERFORM A = A + BVARYING I FROM 1 BY 1 UNTIL I > 20.

4. Nested DO loops

Example : DO I=1 TO 50;

DO J=1 TO 100; ......

END;........END;

PERFORM---TIMES –STATEMENT Syntax : PERFORM [proc1] {integer/identifier}TIMES [imperative statement] END-PERFORM.Imperative statement – may/may not be another PERFORM statement.

Example : PERFORM 50 TIMES

PERFORM 100 TIMES …. END PERFORM

…… END PERFORM.

Internal Use Only

Page 25: Mapping_PL1_to_COBOL-0[1].3.doc

ASSIGNMENT STATEMENT

The assignment statement evaluates an expression and assigns its value to one or more target variables. The target variables can be element, array, or sructure variables, or pseudovariables.

SYNTAX: Reference-list = Expression [ , BY NAME];

For array assignments, each target variable must be an array. The right-hand side can be a structure, array, or element expression. If the right-hand side contains arrays of structures, all target variables must be arrays of structures. The BY NAME option can be given only when the right-hand side contains at least one structure.For structure assignments, each target variable must be a structure. The right-hand side can be a structure or element expression.

In structure assignments where the BY NAME option is not specified:1. None of the operands can be arrays, although they can be structures that contain arrays.2.All of the structure operands must have the same number, k, of immediately contained items. 3.The assignment statement is replaced by k generated assignment statements. The ith generated assignment statement is derived from the original assignment statement by replacing each structure operand by its ith contained item; such generated assignment statements can require further expansion. All generated assignment statements are given the condition prefix of the original statement.

In structure assignments where the BY NAME option is given, the structure assignment is expanded according to steps 1 through 3 below. Steps 1 through 3 can generate further array and structure assignments. None of the operands can be arrays.1. The first item immediately contained in the master variable is considered.

MOVE Statement

The MOVE statement transfers data from one area of storage to one or more other areas.

SYNTAX: MOVE [CORRESPONDING] identifier-1 TO [identifier-list-2]

Identifier-1, literal-1 = Sending areaIdentifier-list—2 = Receiving area(s)

Note: Do not specify a data item defined with USAGE IS POINTER, USAGE IS PROCEDURE-POINTER, or USAGE IS OBJECT REFERENCE in a MOVE statement.

A data item defined with USAGE IS POINTER, USAGE IS PROCEDURE-POINTER, or USAGE IS OBJECT REFERENCE can be part of a group that is referred to in a MOVECORRESPONDING statement; however, no movement of the data item will take place.

An index data item cannot be specified in a MOVE statement.The evaluation of the length of the sending or receiving area can be affected by the DEPENDING ON phrase of the OCCURS clause

If the sending field (identifier-1) is reference-modified, subscripted, or is an alphanumeric or alphabetic function-identifier, the reference-modifier, subscript, or function isEvaluated only once, immediately before data is moved to the first of the receiving operands.

Any length evaluation, subscripting, or reference-modification associated with a receiving field (identifier-2) is evaluated immediately before the data is moved into that receiving field.

Internal Use Only

Page 26: Mapping_PL1_to_COBOL-0[1].3.doc

2. If each structure operand and target variable has an immediately contained item with the same name, an assignment statement is generated as follows:the statement is derived by replacing each structure operand and target variable with its immediately contained item that has this name. If any structure contains no such name, no statement is generated. If the generated assignment is a structure or array-of-structures assignment, BY NAME is appended. All generated assignment statements are given the condition prefix of the original assignment statement.3. Step 2 is repeated for each of the items immediately contained in the master variable. The assignments are generated in the order of the items contained in the master variable.

EXAMPLE:

The following two examples illustrate structure assignment using the BY NAME option:DECLARE DECLARE DECLARE1 ONE, 1 TWO, 1 THREE, 2 PART1, 2 PART1, 2 PART1, 3 RED, 3 BLUE, 3 RED, 3 ORANGE, 3 GREEN, 3 BLUE, 2 PART2, 3 RED, 3 BROWN, 3 YELLOW, 2 PART2, 2 PART2, 3 BLUE, 3 BROWN, 3 YELLOW, 3 GREEN; 3 YELLOW; 3 GREEN;

ONE = TWO, BY NAME;ONE.PART1 = THREE.PART1, BY NAME;ONE = TWO + THREE, BY NAME;

The first assignment statement is the same as the following:ONE.PART1.RED = TWO.PART1.RED;ONE.PART2.YELLOW = TWO.PART2.YELLOW;

CORRESPONDING PhraseThe CORRESPONDING phrase (CORR) allows ADD, SUBTRACT, and MOVE operations to be performed on elementary data items of the same name if the group items to which they belong are specified.

When CORRESPONDING is specified, selected items in identifier-1 are moved to identifie-list-2, according to the rules for the CORRESPONDING phrase. The results are the same as if each pair of CORRESPONDING identifiers were referenced in a separate MOVE statement. CORR is an abbreviation for, and is equivalent to, CORRESPONDING.

Both identifiers following the key word CORRESPONDING must name group items.

EXAMPLE:

If two data hierarchies are defined as follows:

05 ITEM-1 OCCURS 6. 10 ITEM-A PIC S9(3). 10 ITEM-B PIC +99.9. 10 ITEM-C PIC X(4). 10 ITEM-D REDEFINES ITEM-C PIC 9(4). 10 ITEM-E USAGE COMP-1. 10 ITEM-F USAGE INDEX.

05 ITEM-2. 10 ITEM-A PIC 99. 10 ITEM-B PIC +9V9. 10 ITEM-C PIC A(4). 10 ITEM-D PIC 9(4). 10 ITEM-E PIC 9(9) USAGE COMP. 10 ITEM-F USAGE INDEX.

MOVE CORR ITEM-1 TO ITEM-2.

Internal Use Only

Page 27: Mapping_PL1_to_COBOL-0[1].3.doc

The second assignment statement is the same as the following:ONE.PART1.RED = THREE.PART1.RED;

The third assignment statement is the same as the following:ONE.PART1.RED = TWO.PART1.RED + THREE.PART1.RED;ONE.PART2.YELLOW = TWO.PART2.YELLOW + THREE.PART2.YELLOW;

Multiple Assignments

The values of the expression in an assignment statement can be assigned to more than one variable or pseudovariable.

EXAMPLE: A,X = B + C;

Group Moves

A group move is one in which one or both of the sending and receiving fields are group items. A group move is treated exactly as though it were an alphanumeric elementary move, except that there is no conversion of data from one form of internal representation to another.

In a group move, the receiving area is filled without consideration for the individual elementary items contained within either the sending area or the receiving area, except as noted in the OCCURS clause All group moves are valid.

BUILT-IN Functions

Internal Use Only

Page 28: Mapping_PL1_to_COBOL-0[1].3.doc

TYPES :

I . ARITHEMATIC FUNCTIONSII . MATHEMATICAL FUNCTIONSIII. ARRAY HANDLINGIV. DATE & TIME FUNCTIONSV . STRING HANDLINGVI. MISCELLANEOUS FUNCTIONSVII . BUILT-IN SUBROUTINESVIII. PREPROCESSOR STATEMENTS

I . ARITHEMATIC FUNCTIONS I . ARITHEMATIC FUNCTIONS

ABS

Description: Abs finds the absolute value of a given quantity

SyntaxABS (x), x = expression

Return Type: ABS returns the positive value of x, if x is real. If x is complex, ABS returns the positive square root of the sum of the squares of the real and imaginary parts.

Example:

ABS(-3.54) => 3.54ABS(3.54) => 3.54

CEIL

Description: Ceil finds smallest integer greater than or equal to argument

Internal Use Only

Page 29: Mapping_PL1_to_COBOL-0[1].3.doc

Syntax: CEIL(X); X=Real expression

Return Type: Ceil returns an integer value

Example:CEIL(3.32) => 4

Internal Use Only

Page 30: Mapping_PL1_to_COBOL-0[1].3.doc

FLOOR

Description: Floor finds largest integer that does not exceed the argument

Syntax: FLOOR(X);X=Real expression

Return Type: Floor returns an integer value

Example:

FLOOR(3.32) => 3

MAX

Description: Max finds the largest value from two or more arguments

Syntax: MAX(arg1,arg2,arg3………,argn);ARGn= Nth real expression

Return Type: Max returns a real value

Example: MAX(100,32.76,-8.8) => 100

MAX

Description: Max function finds the content of the argument that contains the minimum value.

Syntax: FUNCTION MAX(arg1,arg2,arg3………,argn);ARGn= Nth numeric, alphanumeric, or alphabetic expression.

Return Type: Max returns a numeric, alphanumeric, or alphabetic expression.

Example: FUNCTION MAX(100,32.76,-8.8) => 100NOTE : If more than one argument has the same greatest value, the leftmost argument having that value is returned.

Internal Use Only

Page 31: Mapping_PL1_to_COBOL-0[1].3.doc

MIN

Description: Min finds the smallest value from two or more arguments

Syntax: MIN(arg1,arg2,arg3………,argn);ARGn= Nth real expression

Return Type: Max returns a real value

Example:

MIN(100,32.76,-8.8) => -8.8

MIN

Description: Min function finds the content of the argument that contains the minimum value.

Syntax: FUNCTION MIN(arg1,arg2,arg3………,argn);ARGn= Nth numeric, alphanumeric, or alphabetic expression.

Return Type: Min returns a numeric, alphanumeric, or alphabetic expression.

Example:

FUNCTION MIN(100,32.76,-8.8) => -8.8

NOTE : If more than one argument-1 has the same least value, the leftmost argument-1 having that value is returned.

MOD

Description: Mod extracts the remainder resulting from the division of the first argument by second argument

Syntax: MOD(X,Y);X=Real expression, (Dividend)Y=Real expression, (Divisor)

Return Type: Mod returns a smallest non-negative number that must be subtracted from the X(i.e. dividend) in order to make it exactly divisible by Y(i.e. divisor)

Example:MOD(29,6) => 5

MOD

Description: Mod divides the first argument by second argument and returns the integer remainder

Syntax: FUNCTION MOD(X,Y);X= Integer,(Dividend)Y= Integer, (Divisor)

Return Type: Mod returns an integer value

Example:FUNCTION MOD(16,5) => 1 , MOD(-16,-5) => -1FUNCTION MOD(-16,5) => 4 , MOD(16,-5) => -4

Internal Use Only

Page 32: Mapping_PL1_to_COBOL-0[1].3.doc

ROUND

Description: Rounds a given value at a specified digit and pads spare digit positions with zeros

SyntaxRound(X,Y);X=Expression to be roundedY=Optionally signed integer, specifying the digit at which rounding is to occur

Return Type: Round returns a floating-point number. If y isgreater than 0, it is the (y)th digit to the right of the point; if zero or negative, it is the (1-y)th digit to the left of the point. The valid range of Y is: 127>= y >= -128.

Example:DCL X FIXED DECIMAL(7,4);X=123.7261;ROUND(X,3) => 123.7260ROUND(X,2) => 123.7300ROUND(X,-1) => 120.0000

INTEGER

Description: Integer function returns the greatest integer value that is less than or equal to the argument specified.

Syntax: FUNCTION INTEGER(X)X = Numeric value

Return Type: Integer returns an integer value

Example:

FUNCTION INTEGER(5.1) => 5FUNCTION INTEGER(-5.1) => -6

NOTE : Integer function in COBOL is similar to Round(X,0) function in PL/1

SIGN

Description: Sign determines the sign of a value

Syntax: SIGN(X);X=Real expression

Return Type: SIGN returns a FIXED BINARY (15,0) valueof 1 for positive, 0 for zero, -1 for negative

Example:SIGN(123) => 1SIGN(-123) => -1SIGN(0) => 0

EQUIVALENT CODE FOR SIGN

-01 SIGN-FLAG PIC S9 VALUE ZEROS.-IF X < 0 SIGN-FLAG = -1ELSE-IF X = 0 SIGN-FLAG = 0ELSE SIGN-FLAG = 1END-IF.

Internal Use Only

Page 33: Mapping_PL1_to_COBOL-0[1].3.doc

TRUNC

Description: Trunc changes fractional part of an argument to zero

Syntax: TRUNC(X);X=Real Expression

Return Type: TRUNC returns an integer value. If x is positive or 0, this is the largest integer value less than or equal to x. If x is negative, this is the smallest integer value greater than or equal to x.

Example:TRUNC(3.32) => 3TRUNC(-3.32) => -3

INTEGER-PART

Description: Integer-Part function returns an integer that is the integer portion of the argument specified.

Syntax: FUNCTION INTEGER-PART(X)X = Numeric value

Return Type: Integer-part returns an integer value X = zero, the returned value is zero. X= positive, the returned value is the greatest integer less equal to the value X.

X = negative, the returned value is the least integer greater than or equal to the value of X.

Example:FUNCTION INTEGER-PART(5.1) => 5FUNCTION INTEGER-PART(-5.1) => -5

I . MATHEMATICAL FUNCTIONS II . MATHEMATICAL FUNCTIONS

ACOS

Description : ACOS returns value that is approximate of inverse(arc) cosine in radian.

Syntax : ACOS (X) where X is real expression and ABS(X)<=1.The result is in the range: 0<=ACOS(X)<=piand has the base and precision of X.

Return Type : ACOS returns real floating point value.

ACOS

Description : ACOS returns a numeric value in radians that approximates the (arc) cosine of the argument specified.The function type is numeric.

Syntax: 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.

Return Type : The returned value is the approximation of the (arc) cosine of the argument and is greater than or equal to zero and less than or equal to Pi.

Internal Use Only

Page 34: Mapping_PL1_to_COBOL-0[1].3.doc

ASIN

Description : ASBN returns a value that is approximate of inverse (arc) sine in radians of X.

Syntax : ASIN(X)X = Real expression and ABS(X)<=1.

The result is in the range: -pi/2<-ASIN(X)<-pi/2and has the base and precision of X.

Return Type : ASIN returns a real floating point value.

ASIN

Description : ASIN returns a numeric value in radians that approximates the (arc)sine ofthe argument specified.The function type is numeric.

Syntax : FUNCTION ASIN(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.

Return type : 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.

Internal Use Only

Page 35: Mapping_PL1_to_COBOL-0[1].3.doc

ATAN

Description : ATAN returns value that is approximate of inverse (arc) Tangent in radians of X or of a ratio X/Y.

Syntax : ATAN (X,Y) X and Y = Real expression.If X alone is specified and is real, the result is real, has the base and precision of X, and is in the range: -pi/2<ATAN(X)<pi/2If X alone is specified and is complex, it must not be +1i or –1i. The result is Complex, has the base and precision of X, and a value given by: -1i*ATANH(1i*X)If X and Y are specified, each must be real. It is an error if X and Y are both zero.The result for all other values of X and Y is real, and has the precision of the longerArgument, a base determined by the rules for expressions, and a value given by:ATAN(X/Y) for Y>0Pi/2 for Y=0 and X>0-pi/2 for Y=0 and X<0pi+ATAN(X/Y) for Y<0 and X>=0-pi+ATAN(X/Y) for Y<0 and X<0

Return Type : ATAN returns a real floating point value.

ATAN

Description : ATAN returns a numeric value in radians that approximates the (arc)tangent of the argument specified.The function type is numeric.

Syntax : FUNCTION ATAN(argument-1). Aargument-1 must be class numeric.

Return type : The returned value is the approximation of the arctangent of argument-1 and is greater than -Pi/2 and less than +Pi/2.

Internal Use Only

Page 36: Mapping_PL1_to_COBOL-0[1].3.doc

ATAND

Description : ATAND returns a value that is an approximation of the inverse (arc) tangent in degrees of X or of a ratio X/Y.

Syntax : ATAND(X,Y)X and Y = Expressions.If X alone is specified it must be real. The result has the base and precision of X, and is in the range: -90ATAND(X)<90 If X and Y are specified, each must be real. The value of the result is given by: (180/pi)*ATAN(X,Y)

Return Type : ATAND returns a real floating point value.

ATANH

Description : ATANH returns a value that has the base, mode, and precision of X, and is an approximation of the inverse (arc) hyperbolic tangent of X.

Syntax : ATANH(X)X = is an expression. If X is real, ABS(X)<1. If x is complex, it must not be equal to +1 or -1. The result has a value given by: LOG((1+X)/(1-X))/2

Return Value : ATANH returns a real floating point value

Internal Use Only

Page 37: Mapping_PL1_to_COBOL-0[1].3.doc

COS

Description : COS returns a value that has the base, precision, and mode of X, and is an approximation of the cosine of X.

Syntax: COS(X) X = Expression whose value is in radians.If X = COMPLEX(A,B), the value of the result is given by:COMPLEX(COS(A) * COSH(B), - SIN(A) * SINH(B))

Return Value: COS returns a real floating point value.

COS

Description : COS returns a numeric value that approximates the cosine of the angle orarc specified by the argument in radians.The function type is numeric.

Syntax : FUNCTION COS(argument-1) argument-1 must be class numeric.

Return type : 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.

COSD

Description : COSD returns a value that has the base and precision of X, and is an approximation of the cosine of X.

Syntax: COSD(X)X = Real expression whose value is in degrees.

Return Value: COSD returns a real floating point value.

Internal Use Only

Page 38: Mapping_PL1_to_COBOL-0[1].3.doc

COSH

Description : COSH returns a value that has the base, precision, and mode of X, and is an approximation of the hyperbolic cosine of X.

Syntax: COSH(XX = Expression.If X = COMPLEX(A,B), the value of the result is given by:COMPLEX(COSH(A) * COS(B), - SINH(A) * SIN(B))

Return Value: COSH returns a real floating point value.

ERF

Description : ERF returns a value that is an approximation of the error function of X.

Syntax: ERF(X), X = Real expression.The result has the base and precision of x, and a value given by:(2 / S Q R T ( p i ) )E X P ( - ( t * * 2 ) ), t from 0 to X.

Return Value: ERF returns a real floating point value.

ERFC

Description : ERFC returns a value that is an approximation of the complement of the error function of X.

Syntax: ERFC(X)X = Real expression.The result has the base and precision of X, and a value given by: 1-ERF(X)

Return Value: ERFC returns a real floating-point value.

Internal Use Only

Page 39: Mapping_PL1_to_COBOL-0[1].3.doc

EXP

Description : EXP returns a value that is an approximation of the base, e, of the natural logarithm system raised to the power X.

Syntax: EXP(X)X = Real Expression.The result has the base, mode, and precision of X. If X=COMPLEX(A,B), the value of the result is given by:(e**A) * COMPLEX(COS(B), SIN(B))

Return Value: EXP returns a real floating-point value.

LOG

Description : LOG returns a ating-point value that has the base, mode, and precision of X, and is an approximation of the natural logarithm (that is, the logarithm to the base e) of X.

Syntax LOG(XX = Real Expression.If X is real, it must be greater than zero. If X is complex, it Must not be equal to 0+0i.The function is multiple-valued if X is complex; hence, only the principal value can be returned. The principal value has the form: COMPLEX(A,B) Where A is nonnegative, and B is within the range: -pi<B<=pi

Return Value: LOG returns a real floating-point value.

LOG

Description : 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.

Syntax : FUNCTION LOG(argument-1) argument-1 must be class numeric. The value of argument-1 must be greater than zero.

Return Type : The returned value is the approximation of the logarithm to the base e of argument-1.

Internal Use Only

Page 40: Mapping_PL1_to_COBOL-0[1].3.doc

LOG2

Description : LOG2 returns a value that has the base and precision of X, and is an approximation of the binary logarithm (that is, the logarithm to the base 2) of X.

Syntax: LOG2(X)X = Real expression that must be greater than zero.

Return Value: LOG2 returns a real floating point value.

LOG10

Description : LOG10 returns a value that has the base and precision of X, and is an approximation of the common logarithm (that is, the logarithm to the base 10) of X.

Syntax LOG10(X)X = Real expression that must be greater than zero.

Return Value: LOG10 returns a real floating point value

LOG10

Description : The LOG10 function returns a numeric value that approximates the logarithm to the base 10 of the argument specified. The function type is numeric.

Syntax : FUNCTION LOG(argument-1) argument-1 must be class numeric. The value of argument-1 must be greater than zero.

Return Type : The returned value is the approximation of the logarithm to the base 10 of argument-1.

Internal Use Only

Page 41: Mapping_PL1_to_COBOL-0[1].3.doc

SIN

Description : SIN returns a value that has the base, mode, and precision of X, and is an approximation of the sine of X.

Syntax : SIN(X)X = Expression whose value is in radians.If X=COMPLEXA,B), the value of the result is given by:COMPLEX(SIN(A)*COSH(B),COS(A)*SINH(B))

ReturnValue: SIN returns a floating-point value.

SIN

Description : The SIN function returns a value that approximates the sine of the angle or arc specified by the argument in radians. The function type is numeric.

Syntax : 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.

ReturnValue: SIN returns a numeric value.

SIND

Description : SIND returns a value that has the base and precision of X, and is an approximation of the sine of X.

Syntax : SIND(X)X = Real expression whose value is in degrees.

ReturnValue: SIN returns a floating point value.

Internal Use Only

Page 42: Mapping_PL1_to_COBOL-0[1].3.doc

SINH

Description : SINH returns a value that has the base, mode, and precision of X, and represents an approximation of the hyperbolic sine of X.

Syntax: SINH(x)X = Expresion whose value is in radians.If X=COMPLEX(A,B), the value of the result is given by:COMPLEX(SINH(A)*COS(B),COSH(A)*SIN(B))

Return value: SINH returns a floating point value.

SQRT

Description : SQRT returns a value that has the base, mode, and precision of X, and is an approximation of the positive square root of X.

Syntax: SQRT(X) X = Real , it must not be less than zero.If X=COMPLEX(A,B), the value of the result is given by:If X is complex, the function is multiple-valued; hence, only the principal value can be returned. The principal value has the form COMPLEX(A,B),

Return value: SQRT returns a floating point value

SQRT

Description : The SQRT function returns a value that approximates the square root of the argument specified. The function type is numeric.

Syntax : FUNCTION SQRT(argument-1)argument-1 must be class numeric.

Return Value : 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.

Internal Use Only

Page 43: Mapping_PL1_to_COBOL-0[1].3.doc

TAN

Description: TAN returns a value that has the base, mode, and precision of X, and is an approximation of the tangent of X.

Syntax: TAN(X) X = Expression whose value is in radians.If X=COMPLEX(A,B), the value of the result is given by:REAL(TAN(X)) = SIN(2*A)/(COS(2*A)+COSH(2*B))IMAG(TAN(X)) = SINH(2*B)/(COS(2*A)+COSH(2*B))

Return Value: TANH returns a floating point value.

TAN

Description : The TAN function returns a numeric value that approximates the tangent of the angle or arc that is specified by the argument in radians. The function type is numeric.

Syntax : FUNCTION TAN(argument-1) argument-1 must be class numeric.

Return Type : The returned value is the approximation of the tangent of argument-1.

TAND

Description: TAND returns a value that has the base, mode, and precision of X, and is an approximation of the tangent of X.

Syntax: TAND(X) X = Expression whose value is in Degrees

Return Value: TANH returns a floating point value

Internal Use Only

Page 44: Mapping_PL1_to_COBOL-0[1].3.doc

TANH

Description: TANH returns a value that has the base, mode, and precision of X,and is an approximation of the hyperbolic tangent of X.

SyntaxTANH(X) X = Expression whose value is in radians.If X is complex, the value of the result is given by:-1I*TAN(1I*X)

ReturnValue: TANH returns a floating point value

III . ARRAY-HANDLING FUNCTIONS

DIMDescription: Provides the current extent for a specified dimension in a given array

SyntaxDIM(X,Y);X=Array expression. x must not have less than y dimensions, and x must not be an array of structures.Y=Expression specifying a particular dimension of x. If necessary, y is converted to a FIXED BINARY (31,0) value. y must be greater than or equal to 1.

Return Type: DIM returns a FIXED BINARY (31,0) value specifying the current extent of dimension y of x.

Example:DCL GRAPH(-5:+5) FLOAT DEC(6);DIM(GRAPH,1) => 11DCL AXIS(-3:3,-4:4) FLOAT DEC(6);DIM(AXIS,2) => 9

Internal Use Only

Page 45: Mapping_PL1_to_COBOL-0[1].3.doc

Internal Use Only

Page 46: Mapping_PL1_to_COBOL-0[1].3.doc

LBOUND

Description: Finds the current lower boundary

Syntax: LBOUND(X,Y)X=Array expression. x must not have less than y dimensions, and x must not be an array of structures.Y=Expression specifying the particular dimension of x. If necessary, y is converted to a FIXED BINARY (15,0) value. y must be greater than or equal to 1.

Return Type: LBOUND returns a FIXED BINARY (31,0) value specifying the current lower bound of dimension y of x.

Example:DCL AXIS(-3:3,-4:4) FLOAT DEC(6);LBOUND(AXIS,2) => -4 ( in binary)

HBOUND

Description: Finds the current higher boundary

Syntax: HBOUND(X,Y)X=Array expression. x must not have less than y dimensions, and x must not be an array of structures.Y=Expression specifying the particular dimension of x. If necessary, y is converted to a FIXED BINARY (15,0) value. y must be greater than or equal to 1.

Return Type: HBOUND returns a FIXED BINARY (31,0) value specifying the current upper bound of dimension y of x.

Example:DCL AXIS(-3:3,-4:4) FLOAT DEC(6);HBOUND(AXIS,2) => 4 ( in binary)

Internal Use Only

Page 47: Mapping_PL1_to_COBOL-0[1].3.doc

Internal Use Only

Page 48: Mapping_PL1_to_COBOL-0[1].3.doc

SUM

Description: Sum finds the sum of all elements in a given array

Syntax: SUM(X)X= Array expression. If the elements of x are strings, they are converted to fixed-point integer values.

Return Type: SUM returns a fixed-point or a floating-point number depending on the contents of the array

Example:DCL GRADE(3) FIXED (3) INIT(1,2,3);SUM(AXIS) => 6

PROD

Description: Prod finds the product of all elements in a given array

Syntax: PROD(X)X=Array expression. If the elements of x are strings, they are converted to fixed-point integer values.

Return Type: PROD returns a floating-point number.

Example:DCL GRADE(3) FIXED (3) INIT(1,2,3);PROD(AXIS) => 6

POLY

Description: Used to form a polynomial expansion from two arguments

Syntax: POLY(X,Y)Internal Use Only

Page 49: Mapping_PL1_to_COBOL-0[1].3.doc

X=An array expression defined as x(m:n), where (m:n) represents the lower and upper bounds.Y=An array expression defined as y(a:b), where (a:b) represents the lower and upper bounds; or, an element-expression.

Return Type: POLY returns a floating-point value that is an approximation of a polynomial formed from two one-dimensional array expressions x and y.

Example:DCL GRADE(3) FIXED (3) INIT(1,2,3);POLY(AXIS,2) => 1+ 2*2**1+3*2**2

Internal Use Only

Page 50: Mapping_PL1_to_COBOL-0[1].3.doc

ANY

Description: Used to test the bits of a given bit-string array

SyntaxANY(X), x Array expression.If x is not a bit-string array, it is converted to bit string.

Return Type: ANY returns a bit string in which each bit is 1 if the corresponding bit in any element of x exists and is 1. The length of the result is equal to that of the longest element.

Example:DCL TEMP(4) BIT(6);DCL STATUS BIT(6);Assume that the array elements of TEMP have been initialized to the following bit-string configurations: (1) 1 0 1 1 0 1 (2) 1 1 1 1 0 0 (3) 1 0 0 1 0 0 (4) 1 1 0 1 0 0 STATUS=ANY(TEMP); STATUS => 1 1 1 1 0 1

ALL

Description: Used to test all bits of a given bit-string array

Syntax: ALL(X), x=Array expression.If x is not a bit-string array, it is converted to bit string.

Return Type: ALL returns a bit string in which each bit is 1 if the corresponding bit in each element of x exists and is 1. The length of the result is equal to that of the longest element.

Example:DCL TEMP(4) BIT(6);DCL STATUS BIT(6);

Internal Use Only

Page 51: Mapping_PL1_to_COBOL-0[1].3.doc

Assume that the array elements of TEMP have been initialized to the following bit-string configurations: (1) 1 0 1 1 0 1 (2) 1 1 1 1 0 0 (3) 1 0 0 1 0 0 (4) 1 1 0 1 0 0 STATUS=ALL(TEMP); STATUS => 1 0 0 1 0 0

Internal Use Only

Page 52: Mapping_PL1_to_COBOL-0[1].3.doc

IV. DATE & TIME FUNCTIONS

DATE & TIME FUNCTION

Description : Datetime function is used to get the current date and time.

DECLARATION : DCL (DATE , TIME) BUILTIN;

FUNCTIONS : DATE & TIME

FORMAT : DATE YYMMDD TIME HHMMSSIII

USAGE : dcl Gregorian char(6); dcl ist char(6);

Gregorian = date; ist = time;

DATETIME

Description: DATETIME returns a character string, length 17, in the format of yyyymmddhhmmssttt.

The returned character string represents:Yyyy Current year mm Current month dd Current day hh Current hour mm Current minute ss Current second ttt Current millisecond

The time zone and accuracy are system dependent

CURRENT-DATE

Description: Current-Date is used to get the current date, time and differential from Greenwich Mean Time

Syntax: Function Current-Date

Return Type: 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.

First 8 characters represent the date in format yyyymmddNext 8 characters represent the time in format hhmmsstt.

Example:

If the date is 21th April 2003 and the time is 1:20:32: 07 PM,Function Current-Date => ‘2003042113203207…’ Note: The above function CURRENT-DATE can be used in place of all the different types of date and time functions of PL/I

Internal Use Only

Page 53: Mapping_PL1_to_COBOL-0[1].3.doc

Example : If the date is 21st April 2003 and time is 1:20:32: 007 PM, Datetime () => ‘20030421132032007’

TIME

Description : Time function is used to get the current time.

Syntax : Time()

Return value : Time returns a character string of length 9, in the format of hhmmssttt.The returned character string represents:hh Current hourmm Current minutess Current secondttt Current millisecond

Example : If the date is 21st April 2003 and time is 4:20:32: 007 AM, Time() => ‘042032007’

Note: The time zone and accuracy are system dependent.

V. STRING HANDLING FUNCTIONS

SUBSTR

Description: Substr is used to access a part of a string.

Syntax: SUBSTR (String-var., Start-pos., Length-of-extract)

Referencing Substrings of Data Items (Reference Modifiers)

Reference a substring of character-string data item items (including EBCDIC data items) with reference modifiers. Intrinsic functions that return character-string values are also considered alphanumeric data items, and can include a reference modifier.

Internal Use Only

Page 54: Mapping_PL1_to_COBOL-0[1].3.doc

Example : dcl data char(50); Dcl field char(10); ...... Data = 'INTERNATIONAL BUSINESS MACHINES'; Field = substr(data,6,8);

Field will be 'NATIONAL'

In substr parameter 2 and 3 can be expression, resulting to be an integer.

Note: If the parameters represent a value which lies outside the string the result is unpredictable.

The following example shows how to use a reference modifier to reference a substring of a data item:

Move Customer-Record(1:20) to Orig-Customer-Name

As this shows, in parentheses immediately following the data item you code the ordinal position (from the left) of the character you want the substring to start with and the length of the desired substring, separated by a colon.

The length is optional. If you omit the length, the substring created will automatically extend to the end of the item. Omitting the length, when possible, is recommended as a simpler, less error-prone coding technique. These values can be variables or expressions.

INDEX

Description: Index function is used to look for a certain character or a string of chars in a given string.

Syntax : INDEX(String, Search String);

Index function returns a binary number (15,0). if string to be looked for is not found, the return value

is zero. only first occurrence is shown.

Example: dcl town_country char(25); ...... town_country = 'WEYBRIDGE,SURVEY'; icomma=index(town_country,',');

icomma will be 10.

Usage of INSPECT Statement

VERIFY

Description: Verify will see that a string will have only certain

In COBOL there is no direct in-built function that does job like VERIFY in PLI but we can use certain other function to obtain same result.

Internal Use Only

Page 55: Mapping_PL1_to_COBOL-0[1].3.doc

characters present. Syntax: VERIFY(x,y);

'X' is the string of chars to be checked in Y. 'Y' is the string containing the list of characters which are to be looked for.

A binary fixed point number is returned : -Zero if all characters in 'X' appears also in 'Y'. - A value, which gives the position of the first character in 'X' which does not appear in 'Y'.

Example: dcl test char(3); Test='BIT'; IX=verify(test,'ABCDEDFGHI');

3 would be returned, because the third character is not in the second parameter of verify

Example:

IF VERIFY(RC_SEQ (J),NUM_CONST) ¬= 0 THEN

USE INSPECT ---- TALLYING

The INSPECT statement is useful for: 1. Filling selective portions of a data item with a value. 2. Replacing portions with a corresponding portion of another data item. 3. Counting the number of times a specific character (zero, space, asterisk, for example) occurs in a data item.

e.g.

Example : 77 COUNTR PIC 9 VALUE ZERO. 01 DATA-2 PIC X(9) VALUE ‘ABCDEFGHI’. 01 TEST PIC X(3) VALUE ‘BIT’ . 01 LEN PIC S9(3) VALUE ZEROS. . LEN=LENGTH(TEST) PERFORM VARYING I FROM 1 BY 1 UNTIL I > LEN INSPECT DATA-2 TALLYING COUNTR FOR LEADING TEST(I:1) IF COUNTR = 0 EXIT END-PERFORM.

Use value of I as position of character not present in main string.

OR AS PROGRAM CONVERTED BY ONSITE (DEPENDING ON FUNCIONALITY OF PROGRAM) use

IS NUMERIC.

Example:

Internal Use Only

Page 56: Mapping_PL1_to_COBOL-0[1].3.doc

IF RC-SEQ(J) NOT NUMERIC

TRANSLATE

Syntax: translate(x,y,z)

'X' = character string to be checked 'Y' = string of replacement character 'Z' = chars in 'X' which are to be replaced if found

result is modified character string 'X'.

If a character is found in 'X' which appears in 'Z', then the char in 'X' is replaced by character from 'Y' which is the same position in 'Y' as is the found character in 'Z'.

Example: dcl (old, new) char(10); dcl icharacter char(10) init('FIRTUX'); dcl tcharacter char(10) init('ANUIQT'); ...... old = 'FIXTURES'; new = translate(old,tcharacter,icharacter);

new = translate('FIXTURES','ANUIQT','FIRTUX'); = ANTIQUES

Tallying and Replacing Data Items (INSPECT Statement)

The INSPECT statement is useful for:

Filling selective portions of a data item with a value. Replacing portions with a corresponding portion of another data item. Counting the number of times a specific character (zero, space, asterisk, for example) occurs in a data item.

INSPECT Statement ExamplesThe following examples show some uses of the INSPECT statement. In all instances, the programmer has initialized the COUNTR field to zero before the INSPECT statement is performed.

Example 1:

77 COUNTR PIC 9 VALUE ZERO.01 DATA-2 PIC X(11)...INSPECT DATA-2TALLYING COUNTR FOR LEADING "0"REPLACING FIRST "A" BY "2" AFTER INITIAL "C"

DATA-2 Before COUNTR After DATA-2 After

00ACADEMY00 2 00AC2DEMY000000ALABAMA 4 0000ALABAMACHATHAM0000 0 CH2THAM0000

Example 2:

77 COUNTR PIC 9 VALUE ZERO.01 DATA-3 PIC X(8).

Internal Use Only

Page 57: Mapping_PL1_to_COBOL-0[1].3.doc

.

.INSPECT DATA-3REPLACING CHARACTERS BY ZEROS BEFORE INITIAL QUOTE

DATA-3 Before COUNTR After DATA-3 After

456"ABEL 0 000"ABELANDES"12 0 00000"12"TWAS BR 0 "TWAS BR

Example 3:

The following example shows the use of INSPECT CONVERTING with AFTER and BEFORE phrases. The table shows examples of the contents of DATA-4 before and after the conversion statement is performed.

01 DATA-4 PIC X(11)...INSPECT DATA-4CONVERTING"abcdefghijklmnopqrstuvwxyz" TO"ABCDEFGHIJKLMNOPQRSTUVWXYZ"AFTER INITIAL "/"BEFORE INITIAL"?"

DATA-4 Before DATA-4 After

a/five/?six a/FIVE/?sixr/Rexx/RRRr r/REXX/RRRRzfour?inspe zfour?inspe

Converting Data Items (Intrinsic Functions)

Internal Use Only

Page 58: Mapping_PL1_to_COBOL-0[1].3.doc

Intrinsic functions are available to convert character-string data items to the following:

Upper or lower case Reverse order Numbers

Besides using intrinsic functions to convert characters, you can also use the INSPECT statement. See the examples under Tallying and Replacing Data Items (INSPECT Statement).

Converting to Uppercase or Lowercase (UPPER-CASE, LOWER-CASE)

This code:

01 Item-1 Pic x(30) Value "Hello World!".01 Item-2 Pic x(30)...Display Item-1Display Function Upper-case(Item-1)Display Function Lower-case(Item-1)Move Function Upper-case(Item-1) to Item-2

Display Item-2would display the following messages on the terminal:Hello World!HELLO WORLD!Hello world!HELLO WORLD!

The DISPLAY statements do not change the actual contents of Item-1 and only affect how the letters are displayed. However, the MOVE statement causes uppercase letters to be moved to the actual contents of Item-2.

Converting to Reverse Order (REVERSE)Internal Use Only

Page 59: Mapping_PL1_to_COBOL-0[1].3.doc

The following code:

Move Function Reverse(Orig-cust-name) To Orig-cust-name would reverse the order of the characters in Orig-cust-name.

For example, if the starting value was 'JOHNSON ', the value after the statement is performed would be ' NOSNHOJ'.

LENGTH

This determines the length of the string.

value returned is binary fixed point number (15,0).

Syntax: length(x)

Example: dcl field char(90) varying; Field = 'GOOD LUCK !'; ilength = length(field);

ilength receives the value 11.

LENGTHDescription: Length gets the length of the argument

Syntax: Function Length(X)

X= Can be a nonnumeric literal or a data item of any class or category.

Return Type: Length returns an integer equal to the length of the argument in bytes.

Example:

FUNCTION LENGTH(‘ABCD’) => 4

Internal Use Only

Page 60: Mapping_PL1_to_COBOL-0[1].3.doc

STRING

Description: String concatenates all the elements in an array or a structure into a single character- or bit-string element

Syntax: String(X), X=Structure/Array name

Return Type: String returns an element bit or character string that is the concatenation of all the elements of x

Example:DCL 1 STRUCTURE,

2 ELEMENT1 CHAR(4) INIT(‘ABCD’);2 ELEMENT2 CHAR(3) INIT(‘123’);2 ELEMENT1 CHAR(3) INIT(‘XYZ’);

STRING(STRUCTURE) => ‘ABCD123XYZ’

STRING

Description : String statement joins all or parts of several data items into one data item in the order you indicate.

Syntax : String str1,str2,…strN into strR.strN = nth string to be concatenated strR = Resultant string variable

Return Type : String returns a concatination of string into the result variable.

Example: WORKING-STORAGE SECTION.-X PIC X(3) VALUE ‘ABC’.Y PIC X(3) VALUE ‘MNO’.-PROCEDURE DIVISION.-STRING X SPACE Y INTO R => ‘ABC MNO’.

Internal Use Only

Page 61: Mapping_PL1_to_COBOL-0[1].3.doc

REPEAT

Description: Repeat takes a given string value and forms a new string consisting of the string value concatenated with itself, a specified number of times

Syntax: Repeat(X,Y);X=Bit or character expression to be repeated. If x is arithmetic, it is converted to bit string if it is binary, character string if it is decimalY=Expression. If necessary, y is converted to a FIXED BINARY (15,0) value

Return Type: REPEAT returns a bit or character string consisting of x concatenated to itself the number of times specified by y; that is, there are (y+1) occurrences of x.

Example:REPEAT(‘HELLO’,2) => ‘HELLOHELLO’

Usage of VALUE ALL Clause

UNSPEC

Desc: UNSPEC returns a bit string that is the internal coded form of x.

Syntax : UNSPEC(x)

CHAR

Description: Char converts a given value to a character-string

Syntax: Char(X[,N]);X=Element to be converted to a character stringN=A decimal integer constant indicating the length of the result. N cannot be negative.

Internal Use Only

Page 62: Mapping_PL1_to_COBOL-0[1].3.doc

Return Type: CHAR returns a character-string. If N=0, the result is the null character string

Example:DCL A FIXED DEC(5) INIT(175);CHAR(A) => ‘ 175’CHAR(A,3) => ‘175’

BOOL

Description: Bool performs boolean operations on operands

Syntax: Bool(X,Y,Z);X&Y= Expressions. x and y are converted to bit strings, if necessary. If x and y are of different lengths, the shorter is padded on the right with zeros to match the longer.

BIT

Description: BIT converts a coded arithmetic data item or character-string to a bit string

Syntax: BIT(X[,Y]);X=Expression/Array NameY=Expression. If necessary, y is converted to a FIXED BINARY (15,0) value. y must not be negative.

Return Type: BIT returns the bit value of x, with a length specified by y. If y is omitted, the length is determined by the rules for type conversion. If y = 0, the result is the null bit string

HIGH

Description: HIGH returns a character string of length x, where each character is the highest character in the collating sequence (hexadecimal FF).

Refer to the HIGH-VALUE/HIGH-VALUES figurative constant of the VALUE clause

Internal Use Only

Page 63: Mapping_PL1_to_COBOL-0[1].3.doc

Syntax: High(X);X=Expression.If necessary, x is converted to a FIXED BINARY (15,0) valueWhich must be positive. If x=0, the result is the null character string.

Return Type: High returns a Character-string of length X, where each character is the highest character in the collating sequence

GRAPHIC

Description: GRAPHIC can be used to explicitly convert character (or mixed character) data to GRAPHIC data. All other data first converts to character, and then to GRAPHICdata type.

Syntax: Graphic(X[,Y])

Return Type: GRAPHIC returns the graphic value of x, with a length in graphic characters specified by y.

LOW

Description: LOW returns a character string of length x, where each character is the lowest character in the collating sequence (hexadecimal 00).

Syntax: Low(X), X=Expression

Return Type: If necessary, X is converted to a FIXED BINARY (15,0) value, which must be positive. If X=0, the result is the null character string

Refer to the LOW-VALUE/LOW-VALUES figurative constant of the VALUE clause

ADDR N/AInternal Use Only

Page 64: Mapping_PL1_to_COBOL-0[1].3.doc

Description: ADDR returns the pointer value that identifies the generation of x. The syntax for ADDR is:

Syntax: ADDR ( X )X = Reference to a variable of any data type, data organization, alignment, and storage class except:

EXAMPLE:

DCL P POINTER; DCL VALUE1 BIT (32) BASED (P); DCL VALUE2 FLOAT (6); P = ADDR ( VALUE2 );

(Indirection by the use of Pointers is not required after using the REDEFINES clause )

ALLOCATE STATEMENT

The ALLOCATE statement allocates storage for based variables and sets a locator variable that can be used to identify the location, independent of procedure block boundaries.

SYNTAX:

ALLOCATE Based-Variable IN Area-Reference SET Locator-Reference;

Based –Variable

Can be any data type. It can be an element variable, an array, or a major structure. When it is a major structure, only the major structure name is specified.

IN Specifies the area variable in which the storage is allocated.

SET Specifies a locator variable that is set to the location of the

Equivalent Function available in COBOL

Internal Use Only

Page 65: Mapping_PL1_to_COBOL-0[1].3.doc

storage allocated. If the SET option is not specified, the declaration of the based variable must specify a locator variable.

EXAMPLE:

DCL (P,Q) POINTER;DCL AREA CHAR (100) BASED (P);ALLOCATE (AREA);ALLOCATE (AREA) SET (Q);

FREE

The FREE statement frees the storage allocated for based and controlled variables.

SYNTAX: FREE Based-Variable ;

EXAMPLE: FREE AREA;

Equivalent Function available in COBOL

VI. MISCELLANEOUS FUNCTIONS

LINENO

LINENO returns a FIXED BINARY (15,0) value specifying the current line number of x.

SYNTAX: LINENO(X);X = File-reference.The file must be open and have the PRINT attribute.

Internal Use Only

Page 66: Mapping_PL1_to_COBOL-0[1].3.doc

NULL

NULL returns the null pointer value. The null pointer value does not identify any generation of a variable. The null pointer value can be converted to OFFSET by assignment of the built-in function value to an offset variable.

SYNTAX: NULL [ ( ) ];

Note: NULL and SYSNULL do not compare equal. However, you should not write code that depends on them being unequal.

VALUE IS NULL

VALUE IS NULLS

This format assigns an invalid address as the initial value of an item defined as USAGE IS POINTER or USAGE IS PROCEDURE-POINTER. It also assigns an invalid object reference as the initial value of an item defined as USAGE IS OBJECT REFERENCE.VALUE IS NULL can only be specified for elementary items described implicitly or explicitly as USAGE IS POINTER, USAGE IS PROCEDURE-POINTER, or USAGE IS OBJECT REFERENCE

ONCODE

ONCODE returns a FIXED BINARY (15,0) value that is the condition code. It is in context in any ON-unit, or any dynamic descendant of an ON-unit.

SYNTAX: ONCODE [ ( ) ];

Note: If ONCODE is used out of context, zero is returned..

Internal Use Only

Page 67: Mapping_PL1_to_COBOL-0[1].3.doc

VII. BUILT-IN SUBROUTINES

PLIRETC

This built-in subroutine allows you to set a return code that can be examined by the program or (sub)system that invoked this PL/I program or by another PL/I procedure via the PLIRETV built-in function.

SYNTAX: PLIRETC(return-code);

e.g. RETURN_CODE = 510; CALL PLIRETC(RETURN_CODE); SIGNAL ERROR;

PLIDUMP

This built-in subroutine allows you to obtain a formatted dump of selected parts of storage used by your program.

SYNTAX: PLIDUMP(argument-list);

PLIXOPT

In COBOL there is no as such direct mapping subroutine for PLIRETC but it can be handled as example shown below.

e.g.

MOVE 510 TO RETURN-CODE DISPLAY 'DATE CARD MISSING' CALL 'CANCEL'.

DECLARE "RETURN-CODE" IN WORKING-STORAGE SECTION.

In COBOL there is no equivalent built in subroutine/ function so this functionality has to be handled in JCL using SYSDUMP

Internal Use Only

Page 68: Mapping_PL1_to_COBOL-0[1].3.doc

VIII. PREPROCESSOR STATEMENTS

%PAGE Statement

The statement following a %PAGE statement in the program listing is printed on the first line (after the page headings) of the next page.

SYNTAX: %PAGE ;

Note: For paging to take place, the %PAGE statement must be on a line with no other statements. When paging takes place, %PAGE does not appear in the formatted listing.

%SKIP Statement

The specified number of lines following a %SKIP statement in the program listing are left blank.

SYNTAX: %SKIP [ (n) ];n = number of lines to be skipped. It must be an integer in the range 1 through 999. If n is omitted, the default is 1. If n is greater than the number of lines remaining on the page, the equivalent of a %PAGE statement is executed in place of the %SKIP statement.

EJECT

The EJECT statement specifies that the next source statement is to be printed at the top of the next page.

SYNTAX:-

EJECT.

The EJECT statement must be the only statement on the line. It can be written in either Area A or Area B, and can be terminated with a separator period. The EJECT statement must be embedded in a program source. For example, in the case of batch applications, the EJECT statement must be placed between the CBL (PROCESS) statement and the end of the program (or the END PROGRAM header, if specified).

The EJECT statement has no effect on the compilation of the source program itself.

SKIP

SKIP1Specifies a single blank line to be inserted in the source listing.

SKIP2Specifies two blank lines to be inserted in the source listing.

SKIP3Specifies three blank lines to be inserted in the source listing.

Internal Use Only

Page 69: Mapping_PL1_to_COBOL-0[1].3.doc

Syntax:

SKIP1.SKIP2.SKIP3.

SKIP1, SKIP2, or SKIP3 can be written anywhere in either Area A or Area B, and can be terminated with a separator period. It must be the only statement on the line. The SKIP1/2/3 statement must be embedded in a program source. For example, in the case of batch applications, the SKIP1/2/3 statement must be placed between the CBL (PROCESS) statement and the end of the program (or the END PROGRAM header, if specified).

ARRAYS/Data Aggregates

An array is an n-dimensional collection of elements that have identical attributes. Only the array itself is given a name. An individual item of an array is referred to by giving its position within the array.

The parenthesized number or numbers following the array name in a DECLARE statement is the dimension attribute specification.

SINGLE DIMENSION

DECLARE LIST (8) FIXED DECIMAL (3); LIST is declared as a one-dimensional array of eight elements,

A table is a collection of data items that have the same description. It is the COBOL equivalent to an array of elements.

Single Dimension

To create a one-dimensional table, use one OCCURS clause. For example:

01 SAMPLE-TABLE-ONE. 05 TABLE-COLUMN OCCURS 3 TIMES. 10 TABLE-ITEM-1 PIC X(2).

Internal Use Only

Page 70: Mapping_PL1_to_COBOL-0[1].3.doc

each one a fixed-point decimal element of three digits. The one dimension of LIST has bounds of 1 and 8; its extent is 8.

DOUBLE DIMENSION

DECLARE TABLE (4,2) FIXED DEC (3);

TABLE is declared as a two-dimensional array of eight fixed-point decimal elements. The two dimensions of TABLE have bounds of 1 and 4 and 1 and 2;the extents are 4 and 2.

Other examples are:

DECLARE LIST_A (4:11); DECLARE LIST_B (-4:3);

In the first example, the bounds are 4 and 11; in the second they are -4 and 3. The extents are the same; in each case, there are 8 integers from the lower bound through the upper bound.

10 TABLE-ITEM-2 PIC X(1).

SAMPLE-TABLE-ONE is the group item that contains the table. TABLE-COLUMN names the table element of a one-dimensional table that occurs three times.

Double Dimensions

To create a two-dimensional table, define a one-dimensional table in each occurrenceof another one-dimensional table. For example:

01 SAMPLE-TABLE-TWO. 05 TABLE-ROW OCCURS 2 TIMES. 10 TABLE-COLUMN OCCURS 3 TIMES. 15 TABLE-ITEM-1 PIC X(2). 15 TABLE-ITEM-2 PIC X(1).

SAMPLE-TABLE-TWO is the name of a two-dimensional table. TABLE-ROW is anElement of a one-dimensional table that occurs two times. TABLE-COLUMN is anElement of a two-dimensional table that occurs three times in each occurrence ofTABLE-ROW.

Similarly for 3 Dimentional tables we can add a 03 TABLE-DEPTH OCCURS 3 TIMES .Similarly we can go upto SEVEN Dimensions of tables.

Structures

The items of a payroll can be declared as follows:

DECLARE 1 PAYROLL, 2 NAME,

The items of a payroll can be declared as follows:

01 PAYROLL 02 NAME.

Internal Use Only

Page 71: Mapping_PL1_to_COBOL-0[1].3.doc

3 LAST CHAR(20), 3 FIRST CHAR(15), 2 HOURS, 3 REGULAR FIXED DEC(5,2), 3 OVERTIME FIXED DEC(5,2), 2 RATE, 3 REGULAR FIXED DEC(3,2), 3 OVERTIME FIXED DEC(3,2);

The description of a major structure name is terminated by one of the following: The declaration of another item with a level number 1 The declaration of another item with no level number A semicolon terminating the DECLARE statement A delimiter (usually a blank) must separate the level number and its associated name

03 LAST PIC X(20). 03 FIRST PIC X(15). 02 HOURS. 03 REGULAR PIC X(20). 03 OVERTIME PIC X(15). 02 RATE. 03 REGULAR PIC X(20). 03 OVERTIME PIC X(15). The description of a major structure name is terminated by The declaration of another item with a level number 01 ,66,77 OR 88A delimiter (usually a blank) must separate the level number and its associated name Here Level No 01,66,77 & 88 starts at Column 8 and others after 12th column

Internal Use Only

Page 72: Mapping_PL1_to_COBOL-0[1].3.doc

Arrays of Structures

A structure name, either major or minor, can be given a dimension attribute in a DECLARE statement to declare an array of structures--an array whose elements are structures having identical names, levels and elements. For example, if a structure, WEATHER, is used to process meteorological information for each month of a year, it might be declared as follows:

DECLARE 1 WEATHER(12), 2 TEMPERATURE, 3 HIGH DECIMAL FIXED(4,1), 3 LOW DECIMAL FIXED(3,1), 2 WIND_VELOCITY, 3 HIGH DECIMAL FIXED(3), 3 LOW DECIMAL FIXED(2), 2 PRECIPITATION, 3 TOTAL DECIMAL FIXED(3,1), 3 AVERAGE DECIMAL FIXED(3,1);

Arrays of Structures

A structure name, either major or minor, can be given a dimension Level . To declare an array of structures—an array whose elements are structures having identical names, levels and elements. For example, if a structure, WEATHER, is used to process meteorological information for each month of a year, it might be declared as follows:

01 WEATHER-TABLE.05 WEATHER OCCURS 12 TIMES. 10 TEMPERATURE.. 15 HIGH OCCURS 4 TIMES.

20 HIGH-VAL PIC 9(4). 15 LOW OCCURS 3 TIMES.

20 LOW-VAL PIC 9(4). 10 WIND_VELOCITY. 15 HIGH OCCURS 4 TIMES.

20 HIGH-VAL PIC 9(4). 15 LOW OCCURS 3 TIMES.

20 LOW-VAL PIC 9(4). 10 PRECIPITATION.

15 TOTAL OCCURS 3 TIMES . 20 TOTAL-VAL PIC 9(4).15 AVERAGE OCCURS 3 TIMES. 20 AVG-VAL PIC 9(5).

Storage Classes

Using storage class attributes, the programmer defines, when storage space is to be allocated to a variable and when this storage space is freed.

There are 4 different storage class :

N/A

Internal Use Only

Page 73: Mapping_PL1_to_COBOL-0[1].3.doc

- Automatic (default)- Static- Based- Controlled

Storage class attributes can be declared explicitly for element, array, and major structure variables. For array and major structure variables, the storage class declared for the variable applies to all of the elements in the array or structure. Storage class attributes cannot be specified for entry constants, file constants, members of structures, or defined data items.

The default storage class is AUTOMATIC for internal variables and STATIC for external variables.

Automatic (Default Variables)

AUTOMATIC specifies that storage is allocated upon each entry to the block that contains the storage declaration. The storage is released when the block is exited. If the block is a procedure that is invoked recursively, the previously allocated storage is pushed down upon entry; the latest allocation of storage is popped up in a recursive procedure when each generation terminates.

EXAMPLE : x:proc options(main); ......

begin; <------------------------- ...... :

dcl tab(100,100,10,2) char(25); : activated

...... : end; <------------------------- freed ......

end x;

StaticInternal Use Only

Page 74: Mapping_PL1_to_COBOL-0[1].3.doc

STATIC specifies that storage is allocated when the program is loaded. The storage is not freed until program execution is completed. For fetched procedures, the storage is not freed until the procedure is released.

EXAMPLE:

dcl tab(10,10) fixed decimal(7,2) static;

Controlled

CONTROLLED specifies that you maintain full control over the allocation and freeing of storage with the ALLOCATE and FREE statements. Multiple allocations of the same controlled variable in the same task, without intervening freeing, stack generations of the variable.

EXAMPLE : dcl fieldx char(12) controlled;

allocate fieldx; /* storage space is assigned */ fieldx = 'all clear ?'; put file(printer) edit(fieldx) (x(5),A); free fieldx; /* storage space is freed *

Based

BASED, like CONTROLLED, specifies that you maintain full control over storage allocation and freeing. Multiple allocations are not stacked but are available at any time. Each allocation can be identified by the value of a locator variable.

In the following example, the arrays A and C refer to the same storage. The elements B and C(2,1) also refer to the same storage.

EXAMPLE:

Internal Use Only

Page 75: Mapping_PL1_to_COBOL-0[1].3.doc

DCL A(3,2) CHARACTER(5) BASED(P),B CHAR(5) BASED(Q),C(3,2) CHARACTER(5);P = ADDR(C);Q = ADDR(A(2,1));

Note: When a based variable is overlaid in this way, no new storage is allocated. The based variable uses the same storage as the variable on which it is overlaid (A(2,1) in the example).

Subroutines/Procedures & Functions

Subroutine:

A subroutine is a procedure that is invoked by a CALL statement or CALL option of an INITIAL attribute. It can be either an external or an internal procedure.

SYNTAX: CALL name [(argument-list)];

Whenever a subroutine is invoked, the arguments of the invoking statement are associated with the parameters of the entry point, then control is passed to that entry point. The subroutine is activated, and execution of the procedure can begin.

Upon normal termination of a subroutine, by a RETURN statement or by control reaching the END statement for the procedure, control is returned to the invoking Subroutines block.

Function procedures can return value (like C functions)

Subroutine procedures return value(s) through modification of argument(s) passed.

SUBROUTINE EXAMPLE:

Paragraph

Paragraph Header or Paragraph Name

Paragraph-name assigns a name to a paragraph in the Procedure Division. A paragraph-name is always local.

A paragraph header or paragraph name indicates the beginning of a paragraph. In the Environment Division, a paragraph consists of a paragraph header followed by one or more entries. For example:

OBJECT-COMPUTER. computer-nameIn the Procedure Division, a paragraph consists of a paragraph-name followed by one or more sentences.

Sentences

A sentence is a sequence of one or more statements, ending with a separator period. Sentences are constructed in the Procedure Division.

EXAMPLE:

PERFORM 100000-INITIALIZATION THRU 100000-EXIT.

Internal Use Only

Page 76: Mapping_PL1_to_COBOL-0[1].3.doc

MAINPR : PROC OPTIONS(MAIN); DCL X ,Y FIXED DEC(7,2); DCL Z FIXED DEC(8,2); DCL SUBRT ENTRY; /* DECLARES SUBRT AS A PROCEDURE */ GET LIST (X,Y); CALL SUBRT ( X, Y, Z); PUT LIST(‘ THE SUM IS = ‘,Z );END MAINPR;

SUBRT : PROC(A,B,C); DCL A FIXED DEC(7,2); DCL B FIXED DEC(7,2); DCL C FIXED DEC( 8,2); C = A + B;END SUBRT;

Function:

A function is a procedure that is invoked by a function reference in an expression. A function reference is an entry reference that represents an entry name (a particular entry point of a procedure) invoked as a function. A function returns a value, and control, to replace the function reference in the evaluation of the expression in which the function reference appears. This single value can be of any data type except entry.

Whenever a function is invoked, the arguments of the invoking statement are associated with the parameters of the entry point, and control is then passed to that entry point. The function is activated, and execution of the procedure can begin.

The RETURN statement terminates a function and returns control to the invoking procedure. Its use in a function differs somewhat from its use in a subroutine; in a function, not only does it return control but it also returns a value to the point of invocation.

PERFORM 900000-TERMINATION THRU 900000-EXIT.

Internal Use Only

Page 77: Mapping_PL1_to_COBOL-0[1].3.doc

FUNCTION EXAMPLE:

Return statement is used to terminate a function RETURN(element-expression);

Ex : W = CALC(A,B);

MAINPR : PROC OPTIONS(MAIN); DCL CALC ENTRY RETURNS (FIXED DEC(7)); DCL SUM FIXED DECIMAL(7); DCL A FIXED DECIMAL (7);

DCL B FIXED DECIMAL(7); DCL C FIXED DECIMAL(7);

GET LIST(A,B,C); SUM = CALC(A,B,C); PUT LIST (‘SUM IS’,SUM);END MAINPR

INPUT/OUTPUT STREAMS

STREAM I/OTypes

EDIT-DIRECTED I/O DATA-DIRECTED I/O LIST DIRECTED I/O

The variables or pseudovariables to which data values are assigned, and the expressions from which they are transmitted, are generally specified in a data-specification with each GET or PUT statement. The statements can also include options that specify the origin or destination of the data values or indicate where they appear in the stream relative to the preceding data values. Only sequential files can be processed with the GET and PUT statements.

GET Statement

ACCEPT Statements

The ACCEPT statement transfers data into the specified identifier. There is no editing or error checking of the incoming data.

ACCEPT <variable name>.

EXAMPLE:

ACCEPT NAME.

DISPLAY Statements

DISPLAY Statement

Internal Use Only

Page 78: Mapping_PL1_to_COBOL-0[1].3.doc

The GET statement is a STREAM input data transmission statement that can either:

Assign data values from a data set to one or more variables Assign data values from a string to one or more variables

PUT Statement

The PUT statement is a STREAM output data transmission statement that can:

Transmit values to a stream output file Assign values to a character variable

SKIP Option

The SKIP option specifies a new current line (or record) within the data set.The expression is evaluated and converted to an integer value, n. The data set is positioned to the start of the nth line (record) relative to the current line (record). If expression is not specified, the default is SKIP(1).The SKIP option takes effect before the transmission of values defined by the data specification (if any). For example:

PUT LIST(X,Y,Z) SKIP(3);

Prints the values of the variables X, Y, and Z on the output file SYSPRINT commencing on the third line after the current line.

PAGE Option

The PAGE option can be specified only for output PRINT files. It defines a new current page within the data set. If PAGE and LINE appear in the same PUT statement, the PAGE option is applied first. The PAGE option takes effect before the transmission of any values defined by the data specification (if any). When a PAGE format item is encountered, a new page is defined.

The DISPLAY statement transfers the contents of each operand to the output device. The contents are displayed on the output device in the order, left to right, in which the operands are listed.

DISPLAY <variable name>

EXAMPLE:

DISPLAY ‘Your name is ‘ NAME.

In addition to assigning a variable a value read in from the terminal or a file, you can also display the value of a variable on the terminal or write it to a file. For example, if the contents of the variable Customer-Name is JOHNSON, then the following statement:

Display "No entry for surname '" Customer-Name "' found in the file.".

Will display this message on the terminal:

No entry for surname 'JOHNSON' found in the file.

To write data to a destination other than the system logical output unit, the UPON clause must be used on the DISPLAY statement. For example:

Display "Hello" UPON SYSOUT

Writes to the system logical output device.

Internal Use Only

Page 79: Mapping_PL1_to_COBOL-0[1].3.doc

The page remains current until the execution of a PUT statement with the PAGE option, until a PAGE format item is encountered, or until the ENDPAGE condition is raised, which can result in the definition of a new page. A new current page implies line one.

For displays at a terminal in interactive mode, the PAGE option skips three lines.

LINE Option

The LINE option can be specified only for output PRINT files. The LINE option defines a new current line for the data set.

The expression is evaluated and converted to an integer value, n. The new current line is the nth line of the current page. If at least n lines have already been written on the current page or if n exceeds the limits set by the PAGESIZE option of the OPEN statement, the ENDPAGE condition is raised. If n is less than or equal to zero, a value of 1 is used. If n specifies the current line, ENDPAGE is raised except when the file is positioned on column 1. In this case, the effect is as for a SKIP(0) option.

The LINE option takes effect before the transmission of any values defined by the data specification (if any). If both the PAGE option and the LINE option appear in the same statement, the PAGE option is applied first. For example:

PUT FILE(LIST) DATA(P,Q,R) LINE(34) PAGE;

prints the values of the variables P, Q, and R in data-directed format on a new page, commencing at line 34.

FILE Option

The FILE option specifies the file upon which the operation takes place. It must be a STREAM file.

Internal Use Only

Page 80: Mapping_PL1_to_COBOL-0[1].3.doc

If neither the FILE option nor the STRING option appears in a GET statement, the input file SYSIN is the default; if neither option appears in a PUT statement, the output file SYSPRINT is the default.

Edit-Directed Data Transmission

Edit-directed data transmission transmits the values of data list items and requires that you specify the format of the values in the stream. The values are recorded externally as a string of characters or graphics to be treated character by character (or graphic by graphic) according to a format list.

Format items

Data format itemsControl format items (line, page, space control)Remote format items

DATA FORMAT ITEMSA(w)AB(w)BCE(w,d)E(w,d,s)F(w)F(w,d)F(w,d,p)X(w)P’picture specification’

W total no of chars/digitsd no.of fractional decimal placess no.of significant digits ( d + 1)p scaling factorA character notation

Internal Use Only

Page 81: Mapping_PL1_to_COBOL-0[1].3.doc

B bit string notationC complex variablesE floating point notationF fixed point notationP picture definition

CONTROL FORMAT ITEMSCOLUMN(n)LINE(n)PAGESKIP

some options which can be stated in open statement are :

option meaning default

linesize(nn) line length 120 chars per linepagesize(nn) page length 60 lines per page

e.g. :- open file(list) output stream print linesize(100) pagesize(50);

EDIT-DIRECTED I/O

Syntax GET EDIT (data list) (format list);PUT EDIT (data list) (format list);

e.g. GET EDIT(EMP#,NAME,RATE,HOURS,DEDUCTIONS)

(COLUMN (1),A(6),A(20),F(4,2),F(3,1),F(5,2));

Data-Directed Data Transmission

Data-directed data transmission transmits the names of the data list items, as well as their values, without your having to specify the format of the values in the stream. Data-directed output is

Internal Use Only

Page 82: Mapping_PL1_to_COBOL-0[1].3.doc

useful for producing annotated output.

DATA DIRECTED I/O

Syntax GET DATA (datalist)PUT DATA (datalist)

e.g. GET DATA (A,B,C,D,E)PUT DATA (A,B,C,D,E)

Input should be given with variable names .e.g. A=12,B=12,C=13,D=14,E=15Output will be printed like thise.g. A=12 B=12 C=13 D=14 E=15

List-Directed Data Transmission

Transmits the values of data list items without your having to specify the format of the values in the stream. The values are recorded externally as a list of constants, separated by blanks or commas.

it is simplest form of stream I/O, and is ideal for testing input at the terminal. e.g. :- get list(c1,c2,c3);

put list(gross,net,gross-net);

e.g. :- dcl temps(7,2) fixed decimal(3); ..... get list(temps);

14 elements would be read by the get statement.

input in list directed i/o is in character form. the data items are separated by comma and/or blanks.

Internal Use Only

Page 83: Mapping_PL1_to_COBOL-0[1].3.doc

FILES INPUT/OUTPUT

Files

To allow a source program to deal primarily with the logical aspects of data rather than with its physical organization in a data set, PL/I employs models of data sets, called files. These models determine how input and output statements access and process the associated data set. Unlike a data set, a file has significance only within the source program and does not exist as a physical entity external to the program. A name that represents a file has the FILE attribute.

TYPE OF TRANSMISSION

STREAM I/O :

stream I/O with get & put : data item is transmitted singly. advisable for small quantities i.e. screen & card readers.

RECORD I/O :

record I/O with read & write : complete record of data items is transmitted and copy of the record is usually kept in internal storage. it is preferable for larger qty of data.

COMPARISON BETWEEN 2 FORMS OF I/O

In Stream I/O conversions takes place in the process of reading the data from character to coded from or vice-versa . No such conversions takes place with record I/O

In Stream I/O less than or more than one physical record may be needed to satisfy a GET OR a PUT. In record I/O only one record is output or input at a time for a READ or WRITE statement

Files

To allow a source program to deal primarily with the logical aspects of data rather than with its physical organization in a data set, COBOL employs models of data sets, called files. These models determine how input and output statements access and process the associated data set. Unlike a data set, a file has significance only within the source program and does not exist as a physical entity external to the program. A name that represents a file has the FILE attribute.

TYPE OF TRANSMISSION

CONSOLE I/O :

Console I/O with Accept & Display : data item is transmitted singly. Advisable for small quantities i.e. screen & card readers.

RECORD I/O :

record I/O with read & write : complete record of data items is transmitted and copy of the record is usually kept in internal storage. it is preferable for larger qty of data.

DIFFERENT MODES OF OPENING A FILE: INPUT OUTPUT I-O EXTEND To READ a file you open it in INPUT Mode

To WRITE into a file you open it in OUTPUT Mode.

Internal Use Only

Page 84: Mapping_PL1_to_COBOL-0[1].3.doc

In Stream I/O the programmer knows in advance the format of the data.in record I/O programmer needs to know only RECSIZE / BLKSIZE. Data format need not be known.

In record I/O data in any form may be stored. In Stream I/O form data has to be character form only.

Record mode I/O may be used with any type of data set. Stream I/O can be used only on sequential data sets

The following lists show the attributes that apply to each type of data transmission:

Stream-Oriented Data Transmission

ENVIRONMENTINPUTOUTPUTPRINTSTREAM

Record-Oriented Data Transmission

BACKWARDS INPUT SEQUENTIALBUFFERED KEYED TRANSIENTDIRECT OUTPUT UNBUFFEREDENVIRONMENT RECORD UPDATEEXCLUSIVE

Group type Alternative attributes Default attribute

Usage STREAM|RECORD STREAMFunction INPUT|OUTPUT|UPDATE INPUTAccess SEQUENTIAL|DIRECT|TRANSIENT SEQUENTIALBuffering BUFFERED|UNBUFFERED BUFFERED (for SEQUENTIAL & TRANSIENT files);

UNBUFFERED (for DIRECT files)

To update i.e REWRITE a Record u open it in I-O Mode.

To append records into a file open it in EXTEND Mode.

DIFFERENT ACCESS METHODS OF A FILE : SEQUENTIAL : RANDOM DYNAMIC -- It includes both ! and !!

DIFFERENT TYPES OF FILE ORGANIZATION :For VSAM Files.

SEQUENTIAL,INDEXED,RELATIVE.

This clause is optional for QSAM files and FLAT Files.

Internal Use Only

Page 85: Mapping_PL1_to_COBOL-0[1].3.doc

Scope EXTERNAL|INTERNAL EXTERNAL

RECORD and STREAM Attributes

The RECORD and STREAM attributes specify the kind of data transmission used for the file. STREAM indicates that the data of the file is a continuous stream of data items, in character form, assigned from the stream to variables, or from expressions into the stream. RECORD indicates that the file consists of a collection of physically separate records, each of which consists of one or more data items in any form. Each record is transmitted as an entity to or from a variable. The syntax for the RECORD and STREAM attributes is:

A file with the STREAM attribute can be specified only in the OPEN, CLOSE, GET, and PUT input/output statements.

A file with the RECORD attribute can be specified only in the OPEN, CLOSE, READ, WRITE, REWRITE, LOCATE, UNLOCK, and DELETE input/output statements.

READ Statement

The READ statement can be used with any INPUT or UPDATE file. It transmits a record from the data set to the program, either directly to a variable or to a buffer. In blocked records, a READ statement with the appropriate option transfers a record from a buffer to the variable or sets a pointer to the record in a buffer. Consequently, not every READ statement transmits data from an input device.

SYNTAX: READ FILE(filename) INTO(area);

READ Statement

The READ statement can be used with any file opened in INPUT or I-O mode.

SYNTAX:

1) Sequential Retrieval :READ file-name-1 NEXT RECORD INTO Identifier-1

AT END Imperative-Statement-1.

2) Random Retrieval : READ file-name-1 RECORD INTO Identifier-1

KEY IS data-Name-1 INVALID KEY Imperative-Statement-1.

Internal Use Only

Page 86: Mapping_PL1_to_COBOL-0[1].3.doc

Here File-name-1 Must be defined in a Data Division FD entry.

NEXT RECORD Reads the next record in the logical Sequence of records. NEXT is optional when ACCESS MODE IS SEQUENTIAL; it has no effect on READ statement execution. Under OS/390 and VM, you must specify the NEXT RECORD phrase for files in dynamic access mode, which are retrieved sequentially.

AT END Its Optional but helps in checking the End of FileFor random access, the INVALID KEY phrase must be Specified

Internal Use Only

Page 87: Mapping_PL1_to_COBOL-0[1].3.doc

WRITE Statement

The WRITE statement can be used with any OUTPUT file or DIRECT UPDATE file, and also with SEQUENTIAL UPDATE files associated with VSAM data sets. It transmits a record from the program and adds it to the data set. For unlocked records, transmission can be directly from a variable or from a buffer. For blocked records, the WRITE statement places a logical record into a buffer; only when the blocking of the records is complete is there actual transmission of data to an output device.

SYNTAX: WRITE FILE(filename) FROM(area);

WRITE Statement

The WRITE statement releases a logical record for an output or input/output file.When the WRITE statement is executed:. The associated sequential file must be open in OUTPUT or EXTEND mode.. The associated indexed or relative file must be open in OUTPUT, I-O, or EXTEND mode.

SYNTAX: 1) Sequential file WRITE Record- Name-1 FROM Identifier-1 AFTER / BEFORE ADVANCING PAGE / n LINE / LINES.

2) Indexed and Relative files

WRITE Record-name-1 FROM Identifier-1 INVALID KEY Imperative-Statement-1.

Here the FROM and AFTER / BEFORE clauses are Optional Under OS/390, the BEFORE and AFTER phrases are not supported for VSAM files. QSAM files are sequentially organized. The ADVANCING and END-OF-PAGE phrases control the vertical Positioning of each line on a printed page.

Internal Use Only

Page 88: Mapping_PL1_to_COBOL-0[1].3.doc

REWRITE Statement

The REWRITE statement replaces a record in an UPDATE file. For SEQUENTIAL UPDATE files, the REWRITE statement specifies that the last record read from the file is to be rewritten; consequently a record must be read before it can be rewritten. For DIRECT UPDATE files, and for KEYED SEQUENTIAL UPDATE files associated with VSAM data sets, any record can be rewritten whether or not it has first been read. The syntax for the REWRITE statement is:

SYNTAX: REWRITE FILE(file-reference) FROM(reference);

REWRITE Statement

The REWRITE statement logically replaces an existing record in a direct-access file open in I-O mode.

SYNTAX: REWRITE Record-Name-1 FROM Identifier-1 INVALID KEY Imperative-Statement-1. Here the FROM clause is Optional & INVALID KEY is used with Indexed file

LOCATE Statement

The LOCATE statement can be used only with an OUTPUT SEQUENTIAL BUFFERED file for locate mode processing. It allocates storage within an output buffer for a based variable and sets a pointer to the location in the buffer. The syntax for the LOCATE statement is:

LOCATE based-variable FILE (file-reference) SET(pointer-reference) KEYFROM(expression))

Internal Use Only

Page 89: Mapping_PL1_to_COBOL-0[1].3.doc

DELETE Statement

The DELETE statement deletes a record from an UPDATE file.

SYNTAX: DELETE FILE(file-reference)

DELETE Statement

The DELETE statement removes a record from an indexed or relative file. For indexed files, the key can then be reused for record addition. For relative files, the space is then available for a new record with the same RELATIVE KEY value.When the DELETE statement is executed, the associated file must be open in I-O mode.

SYNTAX:

DELETE File-Name-1 RECORD INVALID KEY Imperative-Statement-1

For a file in sequential access mode, the INVALID KEY and NOT INVALID KEY phrases must not be specified.

UNLOCK Statement

The UNLOCK statement makes the specified locked record available to other MVS tasks.

SYNTAX: UNLOCK FILE(file-reference)KEY(expression);

INPUT/OUTPUT VERBS

INTO Data area into which logical record is read

FROM Data area from which record is written

SET specifies a pointer variable that is set to point to the location in the

Buffer into which the record has been moved during the READ

INPUT/OUTPUT VERBS

INTO Data area into which logical record is read

FROM Data area from which record is written

KEY [Specifies character key that identifies a record for a INDEXED, VASM KSDS data set. Can be used in a READ Statement for INPUT or EXTEND and With REWRITE Statement

Internal Use Only

Page 90: Mapping_PL1_to_COBOL-0[1].3.doc

Operation

KEY [Specifies character key that identifies a record for a INDEXED,

REGIONAL, VASM KSDS data set. Can be used in a READ

Statement for INPUT or UPDATE field or in a REWRITE for a

DIRECT UPDATE file example: READ FILE (STOCK)

INTO(ITEM) KEY(STKEY);]

KEYFROM The KEYFROM option specifies a character or graphic key

That identifies the record on the data set, or (for TRANSIENT files) the terminal to which the

message orRecord is transmitted. It can be used in a WRITE Statement for a SEQUENTIAL OUTPUT or

DIRECT UPDATE File or a DIRECT OUTPUT file that has

REGIONAL organization,Or in a LOCATE statement. It can also be used in a

WRITE statement for a KEYED SEQUENTIAL UPDATE

file associated with a VSAM data set.

The KEYFROM option applies only to KEYED files

associated with data sets of INDEXED, REGIONAL, or VSAM

organization, or to TRANSIENT files. The expression is

evaluated and, if not character or graphic, isconverted to a character string and is used as the

key of the record when it is written.

Internal Use Only

Page 91: Mapping_PL1_to_COBOL-0[1].3.doc

DIRECT OUPTUT or DIRECT UPDATE in a REGIONAL FILE

example: WRITE FILE (LOANS) FROM (LOANREC) KEYFROM(LOANNO)

KEYTO Specifies the character variable to which the key of a

record is assigned.Variables with PIC and STRING cannot

be used. Applies only to KEYED files of INDEXED, VSAM

or REGIONAL organization.

The Process PL/I statement

Define the file DECLARE filename FILE.

Open the file OPEN FILE(filename)

Process the file READ/WRITE/REWRITE for access by record GET/PUT for stream access

Closing the File CLOSE FILE(filename)

EXAMPLE :

DCL STOCK FILE STREAM INPUT;

create a DD statement with a data definition name(DDNAME)

//GO.STOCK DD DSN=PARTS.INSTOCK,.

The Process COBOL statement

Define the file 1) ENVIRONMENT DIVISION

A) FLAT FILE SELECT File-Name-1 ASSIGN TO Identifier-1.

B) SEQUENTIAL FILE SELECT File-Name -1 ASSIGN TO Identifier-1 ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS File-identifier-1.

C) INDEXED FILE SELECT File-Name -1 ASSIGN TO Identifier-1 ORGANIZATION IS INDEXED ACCESS MODE IS SEQUENTIAL / RANDOM / DYNAMIC FILE STATUS IS File-identifier-1.

D) RELATIVE FILE SELECT File-Name -1 ASSIGN TO Identifier-1 ORGANIZATION IS RELATIVE

Internal Use Only

Page 92: Mapping_PL1_to_COBOL-0[1].3.doc

ACCESS MODE IS SEQUENTIAL / RANDOM / DYNAMIC RELATIVE KEY IS Data-Name-1 FILE STATUS IS File-identifier-1.

Here Identifier-1 for VSAM file is used for JCL And can be :

---- S- / AS- Name ---

S- For QSAM files, the S- (organization) field can be omitted.

AS- For VSAM sequential files, the AS- (organization) field must be specified. For VSAM indexed and relative files, the organization field must be omitted. 2) DATA DIVISION Here we declare the file with file descriptor FD File-Name-1. 01 File-Record.

Open the file : OPEN Input-Mode File-Name-1. Here Input-Mode are : ! INPUT !! OUTPUT !!! I-O !V EXTEND

Closing the File : CLOSE File-Name-1.

Process the File : READ/WRITE/REWRITE for access by

Internal Use Only

Page 93: Mapping_PL1_to_COBOL-0[1].3.doc

record

I/O UNITS

CONDITION HANDLING

When a PL/I program is executed, a number of conditions are detected if they are raised. These conditions can be errors, such as overflow or an input/output transmission error, or they can be conditions that are expected, such as the end of an input file or the end of a page when output is being printed. A condition is also raised when a SIGNAL statement for that condition is executed.

A condition is enabled when its raising executes an action. An action specified to be executed when an enabled condition is raised is established. You use the enabling of conditions and the specifying of the action required when a condition is raised to control the handling of conditions.

Classification of Conditions

COMPUTATIONAL CONDITIONS

INPUT OR OUTPUT CONDITIONS

PROGRAM CHECK OUT CONDITIONS

MISCELLANEOUS CONDITIONS

Computational conditions—those associated with data handling, expression evaluation, and computation. The conditions are:

CONVERSION SIZE FIXEDOVERFLOW UNDERFLOW OVERFLOW ZERODIVIDE

Internal Use Only

Page 94: Mapping_PL1_to_COBOL-0[1].3.doc

If a computational condition (except UNDERFLOW) is raised and the condition is disabled, the program is in error.

Input/output conditions—those conditions associated with input and output. They are:

ENDFILE PENDING ENDPAGE RECORD KEY TRANSMIT NAME UNDEFINEDFILE

Program-checkout conditions--those conditions that facilitate the debugging of a program. They are:

STRINGSIZE STRINGRANGE SUBSCRIPTRANGE

If SUBSCRIPTRANGE is raised and is disabled, the program is in error. Because this checking involves a substantial overhead in both storage space and run time, it usually is used only in program testing--it is removed for production programs, because the above are normally disabled conditions.

Miscellaneous conditions, which are: AREA ERROR ATTENTION FINISH CONDITION

Some conditions are always enabled unless they are explicitly disabled by condition prefixes; others are always disabled unless they are explicitly enabled by condition prefixes; and still others are always enabled and cannot be disabled.

Internal Use Only

Page 95: Mapping_PL1_to_COBOL-0[1].3.doc

The conditions that are always enabled unless they are explicitly disabled by condition prefixes are:

CONVERSIONFIXEDOVERFLOWOVERFLOWUNDERFLOWZERODIVIDE

Each of the preceding conditions can be disabled by a condition prefix specifying the condition name preceded by NO without intervening blanks. Thus, one of the following in a condition prefix disables the respective condition:

NOCONVERSIONNOFIXEDOVERFLOWNOOVERFLOWNOUNDERFLOWNOZERODIVIDE

Such a condition prefix renders the corresponding condition disabled throughout the scope of the prefix. The condition remains enabled outside this scope.

The conditions that are always disabled unless they are enabled by a condition prefix are:

SIZESUBSCRIPTRANGESTRINGRANGESTRINGSIZE

The appearance of one of these in a condition prefix renders the condition enabled throughout the scope of the prefix. The condition remains disabled outside this scope.One of the following in a condition prefix disables the corresponding condition throughout the scope of that prefix:

Internal Use Only

Page 96: Mapping_PL1_to_COBOL-0[1].3.doc

NOSIZENOSUBSCRIPTRANGENOSTRINGRANGENOSTRINGSIZE

AREA Condition

The AREA condition is raised in either of the following circumstances:

When an attempt is made to allocate a based variable within an area that contains insufficient free storage for the allocation to be made.

When an attempt is made to perform an area assignment, and the target area contains insufficient storage to accommodate the allocations in the source area.

ATTENTION Condition

The ATTENTION condition is raised when the user signals attention at the terminal during interactive processing. Raising the condition causes an ATTENTION ON-unit to be entered.

The condition can also be raised by a SIGNAL ATTENTION statement in batch or conversational processing.

Internal Use Only

Page 97: Mapping_PL1_to_COBOL-0[1].3.doc

CONVERSION Condition

The CONVERSION computational condition is raised whenever an invalid conversion is attempted on character data. This attempt can be made internally or during an input/output operation. For example, the condition is raised when:

A character other than 0 or 1 exists in character data being converted to bit data.

A character value being converted to a numeric character field, or to coded arithmetic, contains characters, which are not the representation of an optionally signed arithmetic constant, or an expression to represent a complex constant.

A value being converted to a character pictured item contains characters not allowed by the picture specification.

Following is an example of how the CONDITION condition might be included in a program:

ON CONDITION (TEST)

BEGIN;...END;

The begin-block is executed whenever the following statement is executed:

SIGNAL CONDITION (TEST);

ENDFILE Condition AT END Phrase

Internal Use Only

Page 98: Mapping_PL1_to_COBOL-0[1].3.doc

The ENDFILE input/output condition can be raised during a GET, READ, or WAIT operation by an attempt to read past the end of the file specified in the GET or READ statement. It applies only to SEQUENTIAL INPUT, SEQUENTIAL UPDATE, and STREAM INPUT files.

ON ENDFILE (GIB100P) MORE_P = '0'B;

End-of-File Phrase (AT END)An end-of-file condition might or might not represent an error. In many designs, reading sequentially to the end of a file is done intentionally, and the AT END condition is expected.For example, suppose you are processing a file containing transactions in order to update a master file:

PERFORM UNTIL TRANSACTION-EOF = "TRUE"READ UPDATE-TRANSACTION-FILE INTO WS-TRANSACTION-RECORDAT ENDDISPLAY "END OF TRANSACTION UPDATE FILE REACHED"MOVE "TRUE" TO TRANSACTION-EOFEND READ..END-PERFORM

Sometimes, however, the condition will reflect an error. You code the AT END phrase of the READ statement to handle either case, according to your program design.If you code an AT END phrase, on end-of-file the phrase is performed. If you do not code an AT END phrase, the associated ERROR declarative is performed. Any NOT AT END phrase you code is performed only if the READ statement completes successfully. If the READ operation fails because of any condition other than end-of-file, neither the AT END nor the NOT AT END phrase is performed. Instead, control passes to the end of the READ statement after performing any associated declarative procedure.If you have coded neither an AT END phrase nor an EXCEPTION declarative procedure, but have coded a status key clause for the file, control passes to the next sequential instruction after the input/output statement that detected the end-of-file (where presumably you have some coding to take appropriate action).

Internal Use Only

Page 99: Mapping_PL1_to_COBOL-0[1].3.doc

ENDPAGE Condition

The ENDPAGE input/output condition is raised when a PUT statement results in an attempt to start a new line beyond the limit specified for the current page. This limit can be specified by the PAGESIZE option in an OPEN statement; if PAGESIZE has not been specified, a default limit of 60 is applied. The attempt to exceed the limit can be made during data transmission (including associated format items, if the PUT statement is edit-directed), by the LINE option, or by the SKIP option. ENDPAGE can also be raised by a LINE option or LINE format item that specified a line number less than the current line number.

ERROR Condition

The ERROR condition is raised under the following circumstances:

As a result of the implicit action for a condition for which that action is to print an error message and raise the ERROR condition. As a result of an error (for which there is no other condition) during program execution. As a result of an abend. As a result of a SIGNAL ERROR statement.

Internal Use Only

Page 100: Mapping_PL1_to_COBOL-0[1].3.doc

FIXEDOVERFLOW Condition

The FIXEDOVERFLOW computational condition is raised when the length of the result of a fixed-point arithmetic operation exceeds the maximum length allowed by the implementation.The FIXEDOVERFLOW condition differs from the SIZE condition in that SIZE is raised when a result exceeds the declared size of a variable, while FIXEDOVERFLOW is raised when a result exceeds the maximum allowed by the computer.

KEY Condition

The KEY input/output condition can be raised only during operations on keyed records. It is raised in the cases mentioned in the list of condition codes, below.

When a LOCATE statement is used for a VSAM key-sequenced data set, the KEY condition for this LOCATE statement is not raised until transmission of the record is attempted; that is, at the next WRITE or LOCATE statement for the file, or when the file is closed.

The KEY condition for a data transmission statement using the EVENT option is | raised when the WAIT statement for that event is encountered in the same task. When a LOCATE statement is used for a REGIONAL(3) data set with V format or U format records, and there is not enough room in the specified region, the KEY condition is not raised until transmission of the record is attempted. Neither the record for which the condition is raised nor the current record is transmitted.

OVERFLOW Condition

Internal Use Only

Page 101: Mapping_PL1_to_COBOL-0[1].3.doc

The OVERFLOW computational condition is raised when the magnitude of a floating-point number exceeds the maximum allowed. The magnitude of a floating-point number or intermediate result must not be greater than 1075 or 2252.The OVERFLOW condition differs from the SIZE condition in that SIZE is raised when a result exceeds the declared size of a variable, while OVERFLOW is raised when a result exceeds the maximum allowed by the computer.

RECORD Condition

The RECORD input/output condition can be raised only during a READ, WRITE, LOCATE, or REWRITE operation. It is raised in the cases mentioned under Condition Codes” on page 320 below.

If the SCALARVARYING option is applied to the file (it must be applied to a file using locate mode to transmit varying-length strings), a 2-byte length prefix is transmitted with an element varying-length string. The length prefix is not reset if the RECORD condition is raised. If the SCALARVARYING option is not applied to the file, the length prefix is not transmitted; on input, the current length of a varying-length string is set to the shorter of the record length and the maximum length of the string.The RECORD condition for a data transmission statement using the EVENT option | is raised when the WAIT statement for that event is encountered in the same task.

The RECORD condition is not raised for undefined-length records read from: A CONSECUTIVE data set through a SEQUENTIAL UNBUFFERED file A REGIONAL(3) data set through a DIRECT file

SIZE Condition SIZE ERRORInternal Use Only

Page 102: Mapping_PL1_to_COBOL-0[1].3.doc

The SIZE computational condition is raised only when high-order (that is, leftmost) significant binary or decimal digits are lost in an attempted assignment to a variable or an intermediate result or in an input/output operation. This loss can result from a conversion involving different data types, different bases, different scales, or different precisions. The size condition is not enabled unless it appears in a condition prefix.

The SIZE condition differs from the FIXEDOVERFLOW condition in that, whereas FIXEDOVERFLOW is raised when the size of a calculated fixed-point value exceeds the maximum allowed by the implementation, SIZE is raised when the size of the value being assigned to a data item exceeds the declared (or default) size of the data item. SIZE can be raised on assignment of a value regardless of whether or not FIXEDOVERFLOW was raised in the calculation of that value.

The declared size is not necessarily the actual precision with which the item is held in storage; however, the limit for SIZE is the declared or default size, not the actual size in storage. For example, a fixed binary item of precision (20) occupies a fullword in storage, but SIZE is raised if a value whose size exceeds FIXED BINARY(20) is assigned to it. Because this checking involves a substantial overhead in both storage space and run time, it usually is used only in program testing. You should remove it for production programs.If the SIZE condition is raised and it is disabled, the program is in error.

When your program performs arithmetic operations, the results might be larger than the fixed-point field that is to hold them, or you might have tried a division by 0. In either case, the ON SIZE ERROR clause after the ADD, SUBTRACT, MULTIPLY, DIVIDE, or COMPUTE statement can handle the situation. For ON SIZE ERROR to work correctly for fixed-point overflow and decimal overflow, you must specify the TRAP(ON) run-time option.

If you code the ON SIZE ERROR clause, the imperative statement of your clause will be performed and your result field will not be changed in the following five cases: Fixed-point overflow. Division by 0. Zero raised to the zero power. Zero raised to a negative number. A negative number raised to a fractional power.Overflow Note: Be aware that floating-point exponent overflow, which occurs when the value of a floating-point arithmetic computation cannot be represented in the System/390 floating-point operand format, does not cause SIZE ERROR; an abend occurs instead. You could code a user-written condition handler to intercept the abend and provide your own error recovery logic.

Example of Checking for Division by ZeroCode your ON SIZE ERROR imperative statement so that it issues an informative message. For example:

DIVIDE-TOTAL-COST.DIVIDE TOTAL-COST BY NUMBER-PURCHASEDGIVING ANSWERON SIZE ERRORDISPLAY "ERROR IN DIVIDE-TOTAL-COST PARAGRAPH"DISPLAY "SPENT " TOTAL-COST, " FOR " NUMBER-PURCHASEDPERFORM FINISHEND-DIVIDE

Internal Use Only

Page 103: Mapping_PL1_to_COBOL-0[1].3.doc

.

.

.FINISH.STOP RUN.

In this example, if division by 0 occurs, the program will write out a message identifying the trouble and halt program execution.

STRINGRANGE Condition

The STRINGRANGE program-checkout condition is raised whenever the values of the arguments to a SUBSTR reference fail to comply with the rules described for the SUBSTR built-in function. It is raised for each such reference.

Assuming that the length of the source string (after execution of the ON-unit, if specified) is k, the starting point is i, and the length of the substring is j;

If i is greater than k, the value is the null string. If i is less than or equal to k, the value is that substring beginning at the mth character, bit, or graphic of the source string and extending n characters, bits, or graphics, where m and n are defined by:

m=MAX(i,1)n=MAX(0,MIN(j+MIN(i,1)-1,k-m+1))-if j is specifiedn=k-m+1

-if j is not specified-

This means that the new arguments are forced within the limits.The values of i and j are established before entry to the ON-unit. They are not reevaluated on return from the ON-unit.The value of k might change in the ON-unit if the first argument of SUBSTR is a varying-length string. The value n is computed on return from the ON-unit using any new value of k.

Internal Use Only

Page 104: Mapping_PL1_to_COBOL-0[1].3.doc

STRINGSIZE Condition

The STRINGSIZE program-checkout condition is raised when you attempt to assign a string to a target with a shorter maximum length.

SUBSCRIPTRANGE Condition

The SUBSCRIPTRANGE program-checkout condition is raised whenever a subscript is evaluated and found to lie outside its specified bounds. The condition is also raised when an iSUB subscript is outside the range given in the declaration of the iSUB defined array. The order of raising SUBSCRIPTRANGE relative to evaluation of other subscripts is undefined.

TRANSMIT Condition

The TRANSMIT input/output condition can be raised during any input/output operation. It is raised by an uncorrectable transmission error of a record (or of a block, if records are blocked) and, therefore, signifies that any data transmitted is potentially incorrect. Uncorrectable transmission error means an input/output error that could not be corrected during this execution. It can be caused by a damaged recording medium, or by incorrect specification or setup.

During input, TRANSMIT is raised after transmission of the potentially incorrect record. If records are blocked, TRANSMIT is raised for each subsequent record in the block.During output, TRANSMIT is raised after transmission. If records are blocked, transmission occurs when the block is complete rather than after each output statement. When a spanned record is being updated, the TRANSMIT condition is raised on the last segment of a record only. It is not raised for any subsequent records in the same block, although the integrity of

Internal Use Only

Page 105: Mapping_PL1_to_COBOL-0[1].3.doc

these records cannot be assumed. The TRANSMIT condition for a data transmission statement using the EVENT option is raised when the WAIT statement for that event is encountered in the same process.

UNDEFINEDFILE Condition

The UNDEFINEDFILE input/output condition is raised whenever a nonzero return code is received from the OPEN SVC. If the attempt is made by means of an OPEN statement that specifies more than one file, the condition is raised after attempts to open all files specified.

If UNDEFINEDFILE is raised for more than one file in the same OPEN statement, ON-units are executed according to the order of appearance (taken from left to right) of the file names in that OPEN statement. If UNDEFINEDFILE is raised by an implicit file opening in a data transmission statement without the EVENT option, upon normal return from the ON-unit, processing continues with the remainder of the data transmission statement. If the file was not opened in the ON-unit, the statement cannot continue and the ERROR condition is raised.

If UNDEFINEDFILE is raised by an implicit file opening in a data transmission statement having an EVENT option, the event variable retains its previous value and remains inactive. On normal return from the ON-unit, the event variable is initialized, that is, it is made active and its completion value is set to '0'B (provided the file has been opened in the ON-unit). Processing then continues with the remainder of the statement. However, if the file has not been opened in the ON-unit, the event variable remains uninitialized, the statement cannot be continued, and the ERROR condition is raised.

UNDEFINEDFILE is raised when the TOTAL option of the ENVIRONMENT attribute is specified and either attributes have been added on an OPEN statement or attributes implied by a data

FILE STATUS KEY

The system updates the FILE STATUS key after each input/output statement is performed on a file, placing values in the two digits of the file status key. In general, a zero in the first digit indicates a successful operation, and a zero in both digits means there is nothing abnormal to report. Possible file status codes are listed in the IBM COBOL Language Reference. Establish a FILE STATUS key using the FILE STATUS clause in the FILE-CONTROL paragraph and data definitions in the DATA DIVISION.

FILE STATUS IS data-name-1 data-name-1Specifies the 2-character COBOL FILE STATUS key that should be defined in the WORKING-STORAGE SECTION.Restriction: The data-name in the FILE STATUS clause cannot be variably located.

File Status Key ExampleFigure 68 shows an example of the COBOL coding that performs a simple check on the status key after opening a file.

IDENTIFICATION DIVISION.PROGRAM-ID. SIMCHK.ENVIRONMENT DIVISION.INPUT-OUTPUT SECTION.FILE-CONTROL.SELECT MASTERFILE ASSIGN TO AS-MASTERAFILE STATUS IS MASTER-CHECK-KEY..DATA DIVISION.

Internal Use Only

Page 106: Mapping_PL1_to_COBOL-0[1].3.doc

transmission statement conflict with default attributes. The UNDEFINEDFILE condition is raised not only by conflicting attributes (such as DIRECT with PRINT), but also by:

Block size smaller than record size (except when records are spanned) LINESIZE exceeding the maximum allowed KEYLENGTH zero or not specified for creation of INDEXED , REGIONAL(2), or REGIONAL(3) data sets Specifying a KEYLOC option, for an INDEXED data set, with a value resulting in KEYLENGTH + KEYLOC exceeding the record length Specifying a V format logical record length of less than 18 bytes for STREAM data sets Specifying, for FB format records, a block size that is not an integral multiple of the record size Specifying, for VB format records, a logical record length that is not at least 4 bytes smaller than the specified block size

.

.WORKING-STORAGE SECTION.ð1 MASTER-CHECK-KEY PIC X(2)...PROCEDURE DIVISION...OPEN INPUT MASTERFILEIF MASTER-CHECK-KEY NOT = "00"DISPLAY "Non-zero file status returned from OPEN " MASTER-CHECK-KEY

UNDERFLOW Condition

The UNDERFLOW computational condition is raised when the magnitude of a floating-point number is smaller than the minimum allowed. The magnitude of a nonzero floating-point value cannot be less than 10-78 or 2-260.

UNDERFLOW is not raised when equal numbers are subtracted (often called significance error).

The expression X**(-Y) (where Y>0) can be evaluated by taking the reciprocal of X**Y; hence, the OVERFLOW condition might be raised instead of the UNDERFLOW condition.

ZERODIVIDE Condition Example of Checking for Division by Zero

Internal Use Only

Page 107: Mapping_PL1_to_COBOL-0[1].3.doc

The ZERODIVIDE computational condition is raised when an attempt is made to divide by zero. This condition is raised for fixed-point and floating-point division.The compiler can also raise this condition, instead of FIXEDOVERFLOW, when: The results of a conversion from decimal to binary exceeds the maximum length allowed by the implementation. A fixed, floating-point, or decimal divide exception is detected by the hardware, as, for example, when using the DIVIDE built-in function and the quotient exceeds the size specified for the result.

Code your ON SIZE ERROR imperative statement so that it issues an informative message. For example:

DIVIDE-TOTAL-COST.DIVIDE TOTAL-COST BY NUMBER-PURCHASEDGIVING ANSWERON SIZE ERRORDISPLAY "ERROR IN DIVIDE-TOTAL-COST PARAGRAPH"DISPLAY "SPENT " TOTAL-COST, " FOR " NUMBER-PURCHASEDPERFORM FINISHEND-DIVIDE...FINISH.STOP RUN.

In this example, if division by 0 occurs, the program will write out a message identifying the trouble and halt program execution.

SIGNAL STATEMENT :

You can raise a condition by means of the SIGNAL statement. This statement can be used in program testing to verify the action of an ON-unit and to determine whether the correct action is associated with the condition. The established actionis taken unless the condition is disabled.If the specified condition is disabled, the SIGNAL statement becomes equivalent to a null statement.

SYNTAX: SIGNAL Condition ;

EXAMPLE: For ENDPAGE Condition

Internal Use Only

Page 108: Mapping_PL1_to_COBOL-0[1].3.doc

ON ENDFILE(SYSIN) MORE_DATA=NO; ON ENDPAGE (PRINTR) BEGIN; PUT PAGE LIST (‘ ‘ , ‘ WEEKLY STATUS REPORT’, SUBSTR(TODAY,3,2)|| ‘ / ‘ || SUBSTR(TODAY,5,2)|| ‘ / ‘ || SUBSTR(TODAY,1,2),’PAGE ‘ || PAGE_NUMBER); PAGE_NUMBER = PAGE_NUMBER + 1; END; TODAY = DATE; PAGE_NUMBER =1; OPEN FILE(PRINTR) PAGESIZE(45);

SIGNAL ENDPAGE(PRINTR);

MORE_DATA =YES; GET LIST (DATA); DO WHILE(MORE_DATA); …. END;

Here the SIGNAL Causes a heading to be printed on the first page of the output. Though we didn’t reach the 46tth Page.

COPY BOOK STATEMENTS

% INCLUDE

The %INCLUDE statement is used to incorporate source code from an external library into the source program. Do not put other statements on the same line as the %INCLUDE statement.

The syntax is :

%INCLUDE [ Dataset-Name ( ] member-name [ ) ] ;

COPY

The COPY statement is a library statement that places prewritten text in a COBOL compilation unit.

The Syntax is :

COPY Text-Name OF Library-Name.

Internal Use Only

Page 109: Mapping_PL1_to_COBOL-0[1].3.doc

DatasetSpecifies the ddname used in the FILEDEF command for the VM library , Or in the ddname of the appropriate DD statement for MVS. The default Ddname is SYSLIB. The ddname must refer to a partitioned data set. Dataset is optional.

MemberSpecifies the name of the library member to be incorporated in VM or the Name of the data set member to be incorporated in MVS.

EXAMPLE :If the source program contains the following statement:

% INCLUDE PAYRL;

Where PAYRL is :

DECLARE 1 PAYROLL, 2 NAME, 3 LAST CHARACTER(30) VARYING, 3 FIRST CHARACTER(15) VARYING, 3 MIDDLE CHARACTER(3) VARYING, 2 HOURS, 3 REGULAR FIXED DECIMAL(8,2), 3 OVERTIME FIXED DECIMAL(8,2), 2 RATE LIKE HOURS;

the structure declaration for PAYROLL is inserted into the source program. I

Text-Name, Library-Name :

Text-name identifies the copy text. Library-name identifies where the copy text exists.Text-name and library-name can be the same as a user-defined word.Text-name need not be qualified. If text-name is not qualified, a library-name of SYSLIB is assumed.

EXAMPLE : COPY PAYRL.

Here PAYRL contains the copybook .

ERROR STATUS CODES IN PL/I

Internal Use Only

Page 110: Mapping_PL1_to_COBOL-0[1].3.doc

The following is a summary of all condition codes in numerical sequence.

3 This condition is raised if, in a SELECT group, no WHEN clause is selected and no OTHERWISE clause is present.

4 SIGNAL FINISH, STOP, or EXIT statement executed.

9 SIGNAL ERROR statement executed.

10 SIGNAL NAME statement executed or NAME condition occurred.

20 SIGNAL RECORD statement executed.

21 Record variable smaller than record size. Either:. The record is larger than the variable in a READ INTO statement; theremainder of the record is lost.. The record length specified for a file with fixed-length records is largerthan the variable in a WRITE, REWRITE, or LOCATE statement; theremainder of the record is undefined. If the variable is a varying-lengthstring, RECORD is not raised if the SCALARVARYING option is appliedto the file.

22 Record variable larger than record size. Either:. The record length specified for a file with fixed-length records is smallerthan the variable in a READ INTO statement; the remainder of thevariable is undefined. If the variable is a varying-length string,RECORD is not raised if the SCALARVARYING option is applied to thefile.. The maximum record length is smaller than the variable in a WRITE,REWRITE, or LOCATE statement. For WRITE or REWRITE, theremainder of the variable is lost; for LOCATE, the variable is nottransmitted.. The variable in a WRITE or REWRITE statement indicates a zerolength; no transmission occurs. If the variable is a varying-length string,RECORD is not raised if the SCALARVARYING option is applied to thefile.

23 Record variable length is either zero or too short to contain the embeddedInternal Use Only

Page 111: Mapping_PL1_to_COBOL-0[1].3.doc

key.The variable in a WRITE or REWRITE statement is too short to contain thedata set embedded key; no transmission occurs. (This case currentlyapplies only to VSAM key-sequenced data sets).

24 Zero length record was read from a REGIONAL data set.

40 SIGNAL TRANSMIT statement executed.

41 Uncorrectable transmission error in output data set.

42 Uncorrectable transmission error in input data set.

43 Uncorrectable transmission error on output to index set (VSAM).

44 Uncorrectable transmission error on input from index set (VSAM).

45 Uncorrectable transmission error on output to sequence set (VSAM).

46 Uncorrectable transmission error on input from sequence set (VSAM).

50 SIGNAL KEY statement executed.

51 Key specified cannot be found.

52 Attempt to add keyed record that has same key as a record already presentin data set; or, in a REGIONAL(1) data set, attempt to write into a regionalready containing a record.

53 Value of expression specified in KEYFROM option during sequentialcreation of INDEXED or REGIONAL data set is less than value ofpreviously specified key or region number.

54 Key conversion error, possibly due to region number not being numericcharacter.

55 Key specification is null string or begins (8)'1'B or a change of embeddedkey has occurred on a sequential REWRITE[FROM] for an INDEXED or

Internal Use Only

Page 112: Mapping_PL1_to_COBOL-0[1].3.doc

key-sequenced VSAM data set.

56 Attempt to access a record using a key that is outside the data set limits.

57 No space available to add a keyed record on ISAM insert.

58 Key of record to be added lies outside the range(s) specified for the data set.

70 SIGNAL ENDFILE statement executed or ENDFILE condition occurred.

80 SIGNAL UNDEFINEDFILE statement executed.

81 Conflict in file attributes exists at open time between attributes in DECLAREstatement and those in explicit or implicit OPEN statement.

82 Conflict between file attributes and physical organization of data set (forexample, between file organization and device type), or VSAM data set hasnot been loaded.

83 After merging ENVIRONMENT options with DD statement and data setlabel, data set specification is incomplete; for example, block size or recordformat has not been specified.

84 No DD statement associating file with a data set.

85 During initialization of a DIRECT OUTPUT file associated with aREGIONAL data set, an input/output error occurred.

86 LINESIZE greater than implementation-defined maximum, or invalid value inan ENVIRONMENT option.

87 After merging ENVIRONMENT options with DD statement and data setlabel, conflicts exist in data set specification; the value of LRECL, BLKSIZEor RECSIZE are incompatible with one another or the DCB FUNCTIONspecified.

88 After merging ENVIRONMENT options with DD statement and data setlabel, conflicts exist in data set specification; the resulting combination of

Internal Use Only

Page 113: Mapping_PL1_to_COBOL-0[1].3.doc

MODE/FUNCTION and record format are invalid.

89 Password invalid or not specified.

90 SIGNAL ENDPAGE statement executed or ENDPAGE condition occurred.

91 ENVIRONMENT option invalid for file accessing VSAM data set.

92 Error detected by VSAM while opening a VSAM data set; or during openingof a VSAM data set with the BKWD option, the attempt to position the dataset at the last record failed.

93 Unidentified error detected by the operating system while opening a data set.

94 REUSE specified for a nonreusable data set.

95 Alternate index specified for a VSAM data set is empty.

96 Attempt to OPEN the MSGFILE(SYSPRINT) file after a subtask has been created.

100 SIGNAL PENDING statement executed or PENDING condition occurred.

150 SIGNAL STRINGSIZE statement executed or STRINGSIZE conditionoccurred.

151 Truncation occurred during assignment of a mixed-character string.

300 SIGNAL OVERFLOW statement executed or OVERFLOW conditionoccurred.

310 SIGNAL FIXEDOVERFLOW statement executed or FIXEDOVERFLOWcondition occurred.

320 SIGNAL ZERODIVIDE statement executed or ZERODIVIDE conditionoccurred.

330 SIGNAL UNDERFLOW statement executed or UNDERFLOW conditionInternal Use Only

Page 114: Mapping_PL1_to_COBOL-0[1].3.doc

occurred.

340 SIGNAL SIZE statement executed; or high-order nonzero digits have beenlost in an assignment to a variable or temporary, or significant digits havebeen lost in an input/output operation.

341 High order nonzero digits have been lost in an input/output operation.

350 SIGNAL STRINGRANGE statement executed or STRINGRANGE conditionoccurred.

360 Attempt to allocate a based variable within an area that contains insufficientfree storage for allocation to be made.

361 Insufficient space in target area for assignment of source area.

362 SIGNAL AREA statement executed.

400 SIGNAL ATTENTION statement executed or ATTENTION conditionoccurred.

500 SIGNAL CONDITION (name) statement executed.

510 SIGNAL CHECK statement executed.

520 SIGNAL SUBSCRIPTRANGE statement executed, or subscript has beenevaluated and found to lie outside its specified bounds.

521 Subscript of iSUB-defined variable lies outside bounds of correspondingdimension of base variable.

600 SIGNAL CONVERSION statement executed.

601 Invalid conversion attempted during input/output of a character string.

602 CONVERSION condition raised following TRANSMIT condition.

603 Error during processing of an F format item for a GET STRING statement.Internal Use Only

Page 115: Mapping_PL1_to_COBOL-0[1].3.doc

604 Error during processing of an F format item for a GET FILE statement.

605 Error during processing of an F format item for a GET FILE statementfollowing a TRANSMIT condition.

606 Error during processing of an E format item for a GET STRING statement.

607 Error during processing of an E format item for a GET FILE statement.

608 Error during processing of an E format item for a GET FILE statementfollowing a TRANSMIT condition.

609 Error during processing of a B format item for a GET STRING statement.

610 Error during processing of a B format item for a GET FILE statement.

611 Error during processing of a B format item for a GET FILE statementfollowing TRANSMIT condition.

612 Error during character value to arithmetic conversion.

613 Error during character value to arithmetic conversion for a GET or PUTFILE statement.

614 Error during character value to arithmetic conversion for a GET or PUTFILE statement following a TRANSMIT condition.

615 Error during character value to bit value conversion.

616 Error during character value to bit value conversion for a GET or PUT FILEstatement.

617 Error during character value to bit value conversion for a GET or PUT FILEstatement following a TRANSMIT condition.

618 Error during character value to picture conversion.

Internal Use Only

Page 116: Mapping_PL1_to_COBOL-0[1].3.doc

619 Error during character value to picture conversion for a GET or PUT FILEstatement.

620 Error during character value to picture conversion for a GET or PUT FILEstatement following a TRANSMIT condition.

621 Error in decimal P format item for a GET STRING statement.

622 Error in decimal P format input for a GET FILE statement.

623 Error in decimal P format input for a GET FILE statement following aTRANSMIT condition.

624 Error in character P format input for a GET FILE statement.

625 Error exists in character P format input for a GET FILE statement.

626 Error exists in character P format input for a GET FILE statement followinga TRANSMIT condition.

627 A graphic or mixed-character string encountered in a nongraphicenvironment.

628 A graphic or mixed-character string encountered in a nongraphicenvironment on input.

629 A graphic or mixed-character string encountered in a nongraphicenvironment on input after TRANSMIT was detected.

633 An invalid character detected in a X, BX, or GX string constant.

634 An invalid character detected in a X, BX, or GX string constant on input.

635 An invalid character detected in a X, BX, or GX string constant on inputafter TRANSMIT was detected.

636 A shift character detected in a graphic string.

Internal Use Only

Page 117: Mapping_PL1_to_COBOL-0[1].3.doc

639 During processing of a mixed-character string, one of the followingoccurred:. A shift-in present in the SBCS portion.. A shift-out present in the graphic (double-byte) portion. (A shift-outcannot appear in either byte of a graphic character).. A shift-in present in the second byte of a graphic character.

1002 GET or PUT STRING specifies data exceeding size of string.

1003 Further output prevented by TRANSMIT or KEY conditions previouslyraised for the data set.

1004 Attempt to use PAGE, LINE, or SKIP <= 0 for nonprint file.

1005 In a DISPLAY(expression) REPLY (character reference) statement,expression or character reference is zero length.

1007 A REWRITE or a DELETE statement not preceded by a READ.

1008 Unrecognized field preceding the assignment symbol in a string specified ina GET STRING DATA statement.

1009 An input/output statement specifies an operation or an option whichconflicts with the file attributes.

1011 Data management detected an input/output error but is unable to provideany information about its cause.

1012 A READ SET or READ INTO statement not preceded by a REWRITE.

1013 Previous input operation incomplete; REWRITE or DELETE statementspecifies data which has been previously read in by a READ statement withan EVENT option, and no corresponding WAIT has been executed.

1014 Attempt to initiate further input/output operation when number of incompleteoperations equals number specified by ENVIRONMENT option NCP(n) orby default.

Internal Use Only

Page 118: Mapping_PL1_to_COBOL-0[1].3.doc

1015 Event variable specified for an input/output operation when already in use.

1016 After UNDEFINEDFILE condition raised as a result of an unsuccessfulattempt to implicitly open a file, the file was found unopened on normalreturn from the ON-unit.

1018 End of file or string encountered in data before end of data-list or (inedit-directed transmission) format list.

1019 Attempt to close file not opened in current task.

1020 Further input/output attempted before WAIT statement executed to ensurecompletion of previous READ.

1021 Attempt to access a record locked by another file in this task.

1022 Unable to extend VSAM data set.

1023 Exclusive file closed while records still locked in a subtask

1024 Incorrect sequence of I/O operations on device-associated file.

1025 Insufficient virtual storage available for VSAM to complete request.

1026 No position established in VSAM data set.

1027 Record or VSAM control interval already held in exclusive control.

1028 Requested record lies on nonmounted volume.1029 Attempt to reposition in VSAM data set failed.

1030 An error occurred during index upgrade on a VSAM data set.

1031 Invalid sequential write attempted on VSAM data set.

1040 A data set open for output used all available space.

1500 Computational error; short floating point argument of SQRT built-in functionInternal Use Only

Page 119: Mapping_PL1_to_COBOL-0[1].3.doc

is negative.

1501 Computational error; long floating point argument of SQRT built-in functionis < 0.

1502 Computational error; extended floating point argument of SQRT built-infunction is negative.

1503 Computational error in LOG, LOG2, or LOG10 built-in function; extendedfloating point argument is <= 0.

1504 Computational error in LOG, LOG2, or LOG10 built-in function; shortfloating point argument is <= 0.

1505 Computational error in LOG, LOG2 or LOG10 built-in function; long floatingpoint argument is <= 0.

1506 Computational error in SIN, COS, SIND, or COSD built-in function; absolutevalue of short floating point argument exceeds (2**18)*pi (SIN and COS) or(2**18)*180 (SIND and COSD).

1507 Computational error in SIN, COS, SIND, or COSD built-in function; absolutevalue of long floating point argument exceeds (2**50)*pi (SIN and COS) or(2**50)*180 (SIND and COSD).

1508 Computational error; absolute value of short floating point argument of TANor TAND built-in function exceeds, respectively, (2**18)*pi or (2**18)*180.

1509 Computational error; absolute value of long floating point argument of TANor TAND built-in function exceeds, respectively, (2**50)*pi or (2**50)*180.

1510 Computational error; short floating point arguments of ATAN or ATANDbuilt-in function both zero.

1511 Computational error; long floating point arguments of ATAN or ATANDbuilt-in function both zero.

1514 Computational error; absolute value of short floating point argument ofInternal Use Only

Page 120: Mapping_PL1_to_COBOL-0[1].3.doc

ATANH built-in function >= 1.

1515 Computational error; absolute value of long floating point argument ofATANH built-in function >= 1.

1516 Computational error; absolute value of extended floating point argument ofATANH built-in function >= 1.

1517 Computational error in SIN, COS, SIND, or COSD built-in function; absolutevalue of extended floating point argument exceeds (2**106)*pi (SIN andCOS) or (2**106)*180 (SIND and COSD).

1518 Computational error; absolute value of short floating point argument of ASINor ACOS built-in function exceeds 1.

1519 Computational error; absolute value of long floating point argument of ASINor ACOS built-in function exceeds 1.

1520 Computational error; absolute value of extended floating point argument ofASIN, ACOS built-in function exceeds 1.

1521 Computational error; extended floating point arguments of ATAN or ATANDbuilt-in function both zero.

1522 Computational error; absolute value of extended floating point argument ofTAN or TAND built-in function >= (2**106)*pi or (2**106)*180, respectively.

1550 Computational error; during exponentiation, real short floating-point base iszero and integer value exponent is not positive.

1551 Computational error; during exponentiation, real long floating-point base iszero and integer value exponent is not positive.

1552 Computational error; during exponentiation, real short floating point base iszero and the floating-point or noninteger exponent is not positive.

1553 Computational error; during exponentiation, real long floating point base iszero and the floating-point or noninteger exponent is not positive.

Internal Use Only

Page 121: Mapping_PL1_to_COBOL-0[1].3.doc

1554 Computational error; during exponentiation, complex short floating pointbase is zero and integer value exponent is not positive.

1555 Computational error; during exponentiation, complex long floating pointbase is zero and integer value exponent is not positive.

1556 Computational error; during exponentiation, complex short floating pointbase is zero and floating-point or noninteger exponent is not positive andreal.

1557 Computational error; during exponentiation, complex long floating pointbase is zero and floating-point or noninteger exponent is not positive andreal.

1558 Computational error; complex short floating point argument of ATAN orATANH built-in function has value, respectively, of ±1I or ±1.

1559 Computational error; complex long floating point argument of ATAN orATANH built-in function has value, respectively, of ±1I or ±1.

1560 Computational error; during exponentiation, real extended floating-pointbase is zero and integer value exponent not positive.

1561 Computational error; during exponentiation, real extended floating pointbase is zero and floating-point or noninteger exponent is not positive.

1562 Computational error; during exponentiation, complex extended floating pointbase is zero and integer value exponent is not positive.

1563 Computational error; complex extended floating point base is zero andfloating-point or nonintegral exponent is not positive.

1564 Computational error; complex extended floating point argument of ATAN orATANH built-in function has value, respectively, of ±1I or ±1.

2002 WAIT statement cannot be executed because of restricted system facility.

Internal Use Only

Page 122: Mapping_PL1_to_COBOL-0[1].3.doc

2050 A WAIT statement would cause a permanent wait.

3000 Field width, number of fractional digits, and number of significant digits (w,d,and s) specified for E format item in edit-directed input/output statement donot allow transmission without loss of significant digits or sign.

3001 Value of W field in F format specification too small.

3006 Picture description of target does not match noncharacter-string source.

3009 A mixed-character string contained a shift-out, then ended before a shift-inwas found.

3010 During processing of a mixed-character constant, one of the followingoccurred:. A shift-in present in the SBCS portion.. A shift-out present in the graphic (double-byte) portion. (A shift-outcannot appear in either byte of a graphic character).. A shift-in present in the second byte of a graphic character.

3011 MPSTR built-in function contains an invalid character (or a null functionstring, or only blanks) in the expression that specifies processing rules.(Only V, v, S, s, and blank are valid characters).

3012 Retry for graphic conversion error not allowed.

3013 An assignment attempted to a graphic target with a length greater than16,383 characters (32,766 bytes).

3014 A graphic or mixed string did not conform to the continuation rules.

3015 A X or GX constant has an invalid number of digits.

3016 Improper use of graphic data in Stream I/O. Graphic data can only be usedas part of a variable name or string.

3017 Invalid graphic, mixed, or DBCS continuation when writing Stream I/O to afile containing fixed-length records.

Internal Use Only

Page 123: Mapping_PL1_to_COBOL-0[1].3.doc

3797 Attempt to convert to or from graphic data.

3798 ONCHAR or ONSOURCE pseudovariable used out of context.

3799 In an ON-unit entered as a result of the CONVERSION condition beingraised by an invalid character in the string being converted, the characterhas not been corrected by use of the ONSOURCE or ONCHARpseudovariables.

3800 Length of data aggregate exceeds system limit of 2**24 bytes.

3801 Array structure element not mapped.

3808 Aggregate cannot be mapped in COBOL or FORTRAN.

3809 A data aggregate exceeded the maximum length.

3810 An array has an extent that exceeds the allowable maximum.

3901 Attempt to invoke a task using a tasl variable that is already associated with another active task.

3904 COMPLETION pseudovariable specifies an event variable that is alreadyactive.

3906 Assignment to an event variable that is already active.

3907 DISPLAY statement specifies an event variable that is already active.

3909 Attempt to create a subtask (using CALL statement) when insufficient mainstorage available.

3910 Attempt to attach a task (using CALL statement) when number of activetasks is already at limit defined by PLITASKCOUNT run-time option orinstallation default.

3911 WAIT statement in ON-unit references an event variable already beingInternal Use Only

Page 124: Mapping_PL1_to_COBOL-0[1].3.doc

waited for in task from which ON-unit was entered.

3912 Attempt to execute CALL with TASK option in block invoked while executingPUT FILE(SYSPRINT) statement.

3913 CALL statement with TASK option specifies an unknown entry point.

3914 Attempt to invoke a COBOL or FORTRAN program from a task while someother task is still active which has also invoked COBOL or FORTRAN.

3915 Attempt to call a task when the multitasking library was not selected in thelink-edit step.

3920 An out-of-storage abend occurred.

3951 OpenEdition callable service BPX1MPI was unsuccessful.

3952 OpenEdition callable service BPX1MP was unsuccessful.

3953 OpenEdition callable service BPX1PTB was unsuccessful.

4001 Attempt to assign data to an unallocated CONTROLLED variable duringGET DATA.

8091 Operation exception.

8092 Privileged operation exception.

8093 EXECUTE exception.

8094 Protection exception.

8095 Addressing exception.

8096 Specification exception.

8097 Data exception.

Internal Use Only

Page 125: Mapping_PL1_to_COBOL-0[1].3.doc

9002 Attempt to execute GO TO statement referencing label in an inactive block.

9050 Program terminated by an abend.

9200 Program check in SORT/MERGE program.

9201 SORT not supported in VM.

9250 Procedure to be fetched cannot be found.

9251 Permanent transmission error when fetching a procedure.

9252 FETCH/RELEASE not supported in VM.

9253 Debugging tool unavailable.

9254 Attempt under CICS to FETCH a MAIN procedure from a PL/I routine.

9255 Attempt to release load module containing non-PL/I high-level languageprograms.

9257 Attempt to fetch a subroutine using the PLICALLA entry point.

9999 A failure occurred during an invocation of an Language Environment forMVS & VM service.

FILE STATUS CODES IN COBOL

00 Operation completed successfully02 Duplicate Key was found04 Invalid fixed length record05 The file was created when opened - Successful Completion07 CLOSE with REEL or NO REWIND executed for non tape dataset.10 End of File encountered14 Attempted to READ a relative record outside file boundary

Internal Use Only

Page 126: Mapping_PL1_to_COBOL-0[1].3.doc

21 Invalid Key - Sequence error22 Invalid Key - Duplicate Key found23 Invalid key - No record found24 Invalid Key - key outside boundary of file.30 Permanent I/O Error34 Permanent I/O Error - Record outside file boundary35 OPEN, but file not found37 OPEN with wrong mode38 Tried to OPEN a LOCKed file39 OPEN failed, conflicting file attributes41 Tried to OPEN a file that is already open42 Tried to CLOSE a file that is not OPEN43 Tried to REWRITE without READing a record first44 Tried to REWRITE a record of a different length46 Tried to READ beyond End-of-file47 Tried to READ from a file that was not opened I-O or INPUT48 Tried to WRITE to a file that was not opened I-O or OUTPUT49 Tried to DELETE or REWRITE to a file that was not opened I-O91 Password or authorization failed92 Logic Error93 Resource was not available (may be allocated to CICS or another user)94 Sequential record unavailable or concurrent OPEN error95 File Information invalid or incomplete96 No DD statement for the file97 OPEN successful and file integrity verified98 File is Locked - OPEN failed99 Record Locked - record access failed.

Internal Use Only


Recommended