0% found this document useful (0 votes)
598 views

Mapping PL1 To COBOL-0 (1) .3

This document provides information on mapping data declarations between PL/I and COBOL programming languages. It discusses data types, attributes, and declarations in both languages. Examples are given of equivalent declarations in PL/I and COBOL for different data types including integer, decimal, floating point, character strings, and pointers. Comments and divisions in COBOL programs are also described.

Uploaded by

Deepak Dada
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
598 views

Mapping PL1 To COBOL-0 (1) .3

This document provides information on mapping data declarations between PL/I and COBOL programming languages. It discusses data types, attributes, and declarations in both languages. Examples are given of equivalent declarations in PL/I and COBOL for different data types including integer, decimal, floating point, character strings, and pointers. Comments and divisions in COBOL programs are also described.

Uploaded by

Deepak Dada
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 117

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 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 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
Internal Use Only

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 COBOL provides: Variables, Structures, Literals, and Constants Assignment and Terminal Interaction Built-In (Intrinsic) Functions Tables and Pointers

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 Area Columns 1 through 6

Indicator Area Column 7 Positions 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 A Columns 8 through 11 Area B Columns 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 label PROCEDURE: 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 program Comments 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

Declarations Data Types Halfword Integer PL/I Attributes REAL FIXED BIN (15,0) COBOL Data Description 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 Short Floating Long Floating Character String Bit REAL FIXED DEC (m,n) REAL FLOAT DEC (6) or REAL FLOAT BIN (21) REAL FLOAT DEC (16) or REAL FLOAT BIN (53) CHARACTER(n) BIT(1) PIC S9(m-n).9(n) USAGE IS COMP-3 USAGE IS COMP-1 USAGE IS COMP-2 PIC X(n) BYTE Examples of PL/1 to COBOL Declarations Note: Underscores should not be used in COBOL declarations. PL/I Declarations DCL REVFLGDB_PCB_PTR POINTER; DCL 1 READ_AREA STATIC CHAR(250); 5 TP_10_RA_BILL_PROV_LOB PIC '999', 5 TP_10_RA_CLAIM_NO PIC '(9)9', 5 WRK1_LINE_AMT_CHG PIC '(5)9V99', 10 IO_TIME FIXED DEC(7,1), 5 IO_MSG_COUNT FIXED BIN(31,0),
Internal Use Only

COBOL Declarations 01 REVFLGDB-PCB-PTR USAGE IS POINTER 01 READ-AREA PIC X (250). 05 TP-10-RA-BILL-PROV-LOB PIC 9(3). 05 TP-10-RA-CLAIM-NO PIC 9(9). 05 WKR1_LINE_AMT_CHG PIC 9(5)v99. 10 IO-TIME PIC S9(7)v9 COMP-3. 05 IO-MSG-COUNT PIC S9(9) USAGE COMP.

5 COV_FILL CHAR(2) INIT(' '); DCL PARMCNT5 FIXED BIN(31,0) INIT(5); 5 END_OF_TABLE BIT(1) INIT('0'B), 5 START_OF_TABLE BIT(1) INIT('1'B), 5 SELCARD1_CLMNO FIXED DECIMAL (09) INIT(0) 5 W_COUNT_STATUS FIXED BIN (31,0) INIT(0) 10 PCDH7_FIL16 CHAR(29) INIT((29)'-') 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', PIC '(5)9' STATIC INIT((10) DCL JUL_DATE(10) '00000');

05 COV-FILL PIC X(2) VALUE SPACES. 01 PARMCNT5 PIC S9(9) USAGE COMP VALUE 5. 05 END-OF-TABLE PIC X(5) VALUE FALSE 05 START-OF-TABLE PIC X(4) VALUE TRUE 05 SELCARD1-CLMNO PIC S9(9) COMP-3 VALUE 0. 05 W-COUNT-STATUS PIC S9(9) BINARY VALUE 0. 10 PCDH7_FIL16 PIC X(29) VALUE - ALL.

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

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 DECIMAL FIXED DECIMAL FLOAT BINARY FIXED BINARY FLOAT DECIMAL BINARY FIXED FLOAT None-initial I-N None-other than I-N

Default Attributes (5,0) (6) (15,0) (21) FLOAT(6) FLOAT(21) DECIMAL(5,0) DECIMAL(6) BINARY FIXED(15) DECIMAL FLOAT(6) Declare Statements & Attribute Types

N/A

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 :
Internal Use Only

N/A

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. Multiple redefinitions 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

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 WorkingStorage 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 specified as VALUE "+012.34". SYNTAX 2: 88 condition-name-1 VALUE[S] [IS/ARE] literal-1 [THRU] [literal-2]. Figurative Constants Figurative 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

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 item for edit-directed input and output. Picture edit characters must be enclosed in quotation marks.

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. Minus and decimal point use storage spaces. If the number is nonnegative, it is replaced by a blank. Symbol Meaning A character pictured item can consist of alphabetic characters, A decimal digits, blanks, and any other EBCDIC codes. A numeric character pictured item can consist only of decimal B digits, an optional decimal point, an optional letter E, and, optionally, one or two plus or minus signs. Picture Characters for Character Data Symbol X A 9 Meaning E G A character position that can contain only a letter Of the alphabet or a space. Occupies 1 byte For Non-DBCS dataa character position into which the space character is inserted. Occupies 1 byte Marks the start of the exponent in an external floating point item. Occupies 1 byte A DBCS character position Occupies 2 bytes A DBCS character position Occupies 2 bytes 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.

Any character of the 256 possible bit combinations N represented by the 8-bit byte. Any alphabetic character, #, @, $, or blank. 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). P

Picture Characters for Numeric Character Data Symbol Meaning


Internal Use Only

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 Relational Operator IS GREATER THAN IS NOT GREATER THAN IS LESS THAN IS NOT LESS THAN IS EQUAL TO IS NOT EQUAL TO IS GREATER THAN OR EQUAL TO IS LESS THAN OR EQUAL TO Logical Operator NOT AND OR OR Logical Inclusive OR The truth value is true when either or both conditions are true. NOT Logical Negation Reversal 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: 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:
Internal Use Only

Can Be Written IS > IS NOT > IS < IS NOT < IS = IS NOT = IS >= IS <= Name Meaning

Meaning Greater than Not greater than Less than Not less than Equal to Not equal to Is greater than or equal to Is less than or equal to

Bit string operators are as follows : Logical Operator (alt-170) & |

AND Logical conjunction The truth value is true when both conditions are true.

A concatenation operation is specified by combining operands with the concatenation infix operator: Its 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'B The value of operand B is '101'B The value of operand C is 'XY,Z' The value of operand D is 'AA/BB' Combinations of operations A||B yields '010111101'B A||A||B yields '010111010111101'B C||D yields 'XY,ZAA/BB' D||C yields 'AA/BBXY,Z' B||D yields '101AA/BB'

The value of operand A is '010111'B The value of operand B is '101'B The value of operand C is 'XY,Z' The value of operand D is 'AA/BB' Combinations of operations A||B yields '010111101'B A||A||B yields '010111010111101'B C||D yields 'XY,ZAA/BB' D||C yields 'AA/BBXY,Z' B||D yields '101AA/BB'

Arithmetic Operators Symbol ** * / + Operation Exponentiation Multiplication Division Addition Subtraction Symbol ** * / + Operation Exponentiation 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
Internal Use Only

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 : The prefix operators allowed are Not + 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.

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 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 hierarchic level is not completely specified by parentheses, the order is from left to right. left to right. 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 IF 2.COMPOUND IF 3.NESTED IF 1. SIMPLE IF
Internal Use Only

SIMPLE IF

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

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); Example : IF A=B THEN DO; X=1; Y=2; END;

Syntax: : IF expr [THEN] Statement(s) [END-IF]. Example : IF A = B THEN MOVE 1 TO X MOVE 2 TO Y END IF. COMPOUND IF 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 ELSE Statement. 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

2. COMPOUND IF Use IF . . . ELSE to code a choice between two processing actions A 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
Internal Use Only

X = 2;

ELSE MOVE 2 TO X END-IF. 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 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 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.
Internal Use Only

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 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, 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; 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; ELSE X = 1; ELSE X=2; Example-2: IF A=B THEN IF A=C THEN X=1; ELSE; /* Null Else */ ELSE X=2; 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-IF ELSE MOVE 2 TO X END-IF. /* Null Then */ 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.

Internal Use Only

B. SELECT AND END Statement A select-group provides a multi-way conditional branch. A selectgroup 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; Syntax :

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

Example : SELECT (LANG_CODE); WHEN(P) CALL PL1_FUN; WHEN(C) CALL COBOL_FUN; OTHERWISE CALL ERROR_FUN; END;
Internal Use Only

EVALUATE [(TRUE/FALSE)]/[EXPR] WHEN expr-1 Action-1 WHEN expr-2 Action-2 WHEN expr-n Action-n WHEN 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".

C. DO STATEMENTS 1.DO ... WHILE 2. DO ... UNTIL 3.DO-LOOP 4. Nested DO loops

Internal Use Only

1. DO-WHILE

PERFORM UNTIL WITH TEST BEFORE STATEMENT

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 : 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 [ 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
Internal Use Only

PERFORM UNTIL STATEMENT

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

PERFORM---TIMES STATEMENT

Iterative do group used in an IF statement is also used to put several PERFORM-VARYING-UNTIL can also be used for the Do PL/1 statements together, but in this type of do group these Expression. 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
Internal Use Only

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

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+B VARYING 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; 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. PERFORM---TIMES STATEMENT

Internal Use Only

ASSIGNMENT STATEMENT

MOVE Statement

The assignment statement evaluates an expression and assigns its The MOVE statement transfers data from one area of storage to value to one or more target variables. The target variables can be one or more other areas. element, array, or sructure variables, or pseudovariables. SYNTAX: SYNTAX: MOVE [CORRESPONDING] identifier-1 TO [identifier-list-2] 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. Identifier-1, literal-1 = Sending area Identifier-list2 = 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 In structure assignments where the BY NAME option is not can be part of a group that is referred to in a MOVE CORRESPONDING statement; however, no movement of the data specified: 1. None of the operands can be arrays, although they can be item will take place. structures that contain arrays. 2.All of the structure operands must have the same number, k, of An index data item cannot be specified in a MOVE statement. The evaluation of the length of the sending or receiving area can immediately contained items. 3.The assignment statement is replaced by k generated assignment be affected by the DEPENDING ON phrase of the OCCURS statements. The ith generated assignment statement is derived clause from the original assignment statement by replacing each structure operand by its ith contained item; such generated assignment If the sending field (identifier-1) is reference-modified, statements can require further expansion. All generated assignment subscripted, or is an alphanumeric or alphabetic functionstatements are given the condition prefix of the original statement. identifier, the reference-modifier, subscript, or function is Evaluated only once, immediately before data is moved to the first In structure assignments where the BY NAME option is given, of the receiving operands. the structure assignment is expanded according to steps 1 through 3 below. Steps 1 through 3 can generate further array and structure Any length evaluation, subscripting, or reference-modification associated with a receiving field (identifier-2) is evaluated assignments. None of the operands can be arrays. 1. The first item immediately contained in the master variable is immediately before the data is moved into that receiving field. considered. CORRESPONDING Phrase 2. If each structure operand and target variable an immediately Internal Usehas Only

BUILT-IN Functions TYPES : I . ARITHEMATIC FUNCTIONS II . MATHEMATICAL FUNCTIONS III. ARRAY HANDLING IV. DATE & TIME FUNCTIONS V . STRING HANDLING VI. MISCELLANEOUS FUNCTIONS VII . BUILT-IN SUBROUTINES VIII. 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.54 ABS(3.54) => 3.54 CEIL
Internal Use Only

Description: Ceil finds smallest integer greater than or equal to argument Syntax: CEIL(X); X=Real expression Return Type: Ceil returns an integer value Example: CEIL(3.32) => 4

Internal Use Only

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 MAX

Description: Max finds the largest value from two or more Description: Max function finds the content of the argument arguments that contains the minimum value. 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 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) => 100 NOTE : If more than one argument has the same greatest value, the leftmost argument having that value is returned.

Internal Use Only

MIN

MIN

Description: Min finds the smallest value from two or more Description: Min function finds the content of the argument that arguments contains the minimum value. Syntax: MIN(arg1,arg2,arg3,argn); ARGn= Nth real expression Return Type: Max returns a real value Example: Example: MIN(100,32.76,-8.8) => -8.8 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 MOD Syntax: FUNCTION MIN(arg1,arg2,arg3,argn); ARGn= Nth numeric, alphanumeric, or alphabetic expression. Return Type: Min returns a numeric, alphanumeric, or alphabetic expression.

Description: Mod extracts the remainder resulting from the division Description: Mod divides the first argument by second of the first argument by second argument argument and returns the integer remainder 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 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) => -1 FUNCTION MOD(-16,5) => 4 , MOD(16,-5) => -4

Internal Use Only

ROUND Description: Rounds a given value at a specified digit and pads spare digit positions with zeros SyntaxRound(X,Y); X=Expression to be rounded Y=Optionally signed integer, specifying the digit at which rounding is to occur Return Type: Round returns a floating-point number. If y is greater 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.7260 ROUND(X,2) => 123.7300 ROUND(X,-1) => 120.0000 SIGN Description: Sign determines the sign of a value Syntax: SIGN(X); X=Real expression Return Type: SIGN returns a FIXED BINARY (15,0) value of 1 for positive, 0 for zero, -1 for negative Example: SIGN(123) => 1 SIGN(-123) => -1 SIGN(0) => 0
Internal Use Only

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) => 5 FUNCTION INTEGER(-5.1) => -6 NOTE : Integer function in COBOL is similar to Round(X,0) function in PL/1

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

TRUNC Description: Trunc changes fractional part of an argument to zero Syntax: TRUNC(X); X=Real Expression

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: 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, Return Type: Integer-part returns an integer value this is the smallest integer value greater than or equal to x. X = zero, the returned value is zero. X= positive, the returned value is the greatest integer less Example: equal to the value X. TRUNC(3.32) => 3 X = negative, the returned value is the least integer greater than TRUNC(-3.32) => -3 or equal to the value of X. Example: FUNCTION INTEGER-PART(5.1) => 5 FUNCTION INTEGER-PART(-5.1) => -5 I . MATHEMATICAL FUNCTIONS ACOS II . MATHEMATICAL FUNCTIONS ACOS

Description : ACOS returns value that is approximate of inverse(arc) Description : ACOS returns a numeric value in radians that cosine in radian. approximates the (arc) cosine of the argument specified. The function type is numeric. Syntax : ACOS (X) where X is real expression and ABS(X)<=1. The result is in the range: 0<=ACOS(X)<=pi Syntax: FUNCTION ACOS (argument-1) argument-1 Must be and has the base and precision of X. class numeric. The value of argument-1 must be greater than or equal to -1 and Return Type : ACOS returns real floating point value. 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

ASIN

ASIN

Description : ASBN returns a value that is approximate of inverse Description : ASIN returns a numeric value in radians that (arc) sine in radians of X. approximates the (arc)sine of the argument specified. Syntax : ASIN(X) The function type is numeric. X = Real expression and ABS(X)<=1. Syntax : FUNCTION ASIN(argument-1). Argument-1 must be The result is in the range: -pi/2<-ASIN(X)<-pi/2 class numeric. The value of argument-1 must be greater than or and has the base and precision of X. equal to -1 and less than or equal to +1. Return Type : ASIN returns a real floating point value. 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

ATAN

ATAN

Description : ATAN returns value that is approximate of inverse Description : ATAN returns a numeric value in radians that (arc) Tangent in radians of X or of a ratio X/Y. approximates the (arc)tangent of the argument specified. The function type is numeric. Syntax : ATAN (X,Y) X and Y = Real expression. Syntax : FUNCTION ATAN(argument-1). Aargument-1 must If X alone is specified and is real, the result is real, has the base and be class numeric. precision of X, and is in the range: -pi/2<ATAN(X)<pi/2 If X alone is specified and is complex, it must not be +1i or 1i. The Return type : The returned value is the approximation of the result is Complex, has the base and precision of X, and a value given arctangent of argument-1 and is greater than -Pi/2 and less than by: -1i*ATANH(1i*X) +Pi/2. 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 longer Argument, a base determined by the rules for expressions, and a value given by: ATAN(X/Y) for Y>0 Pi/2 for Y=0 and X>0 -pi/2 for Y=0 and X<0 pi+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.

Internal Use Only

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

COS

COS

Description : COS returns a value that has the base, precision, and Description : COS returns a numeric value that approximates mode of X, and is an approximation of the cosine of X. the cosine of the angle or arc specified by the argument in radians. Syntax: COS(X) The function type is numeric. X = Expression whose value is in radians. If X = COMPLEX(A,B), the value of the result is given by: Syntax : FUNCTION COS(argument-1) COMPLEX(COS(A) * COSH(B), - SIN(A) * SINH(B)) argument-1 must be class numeric. Return Value: COS returns a real floating point value. 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

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(X X = 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

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 LOG

Description : LOG returns a ating-point value that has the base, Description : The LOG function returns a numeric value that mode, and precision of X, and is an approximation of the natural approximates the logarithm to the base e (natural log) of the logarithm (that is, the logarithm to the base e) of X. argument specified. The function type is numeric. Syntax LOG(X X = 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. 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

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 LOG10

Description : LOG10 returns a value that has the base and precision Description : The LOG10 function returns a numeric value that of X, and is an approximation of the common logarithm (that is, the approximates the logarithm to the base 10 of the argument logarithm to the base 10) of X. specified. The function type is numeric. Syntax LOG10(X) X = Real expression that must be greater than zero. Return Value: LOG10 returns a real floating point value Return Type : The returned value is the approximation of the logarithm to the base 10 of argument-1. Syntax : FUNCTION LOG(argument-1) argument-1 must be class numeric. The value of argument-1 must be greater than zero.

Internal Use Only

SIN

SIN

Description : SIN returns a value that has the base, mode, and Description : The SIN function returns a value that precision of X, and is an approximation of the sine of X. approximates the sine of the angle or arc specified by the argument in radians. The function type is numeric. Syntax : SIN(X) X = Expression whose value is in radians. Syntax : FUNCTION SIN(argument-1), If X=COMPLEXA,B), the value of the result is given by: argument-1 must be class numeric. The returned value is the COMPLEX(SIN(A)*COSH(B),COS(A)*SINH(B)) 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 floating-point value. 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

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 SQRT

Description : SQRT returns a value that has the base, mode, and Description : The SQRT function returns a value that precision of X, and is an approximation of the positive square root of approximates the square root of the argument specified. The X. function type is numeric. 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 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

TAN

TAN

Description: TAN returns a value that has the base, mode, and Description : The TAN function returns a numeric value that precision of X, and is an approximation of the tangent of X. approximates the tangent of the angle or arc that is specified by the argument in radians. The function type is numeric. Syntax: TAN(X) X = Expression whose value is in radians. Syntax : FUNCTION TAN(argument-1) If X=COMPLEX(A,B), the value of the result is given by: argument-1 must be class numeric. REAL(TAN(X)) = SIN(2*A)/ (COS(2*A)+COSH(2*B)) Return Type : The returned value is the approximation of the IMAG(TAN(X)) = SINH(2*B)/ tangent of argument-1. (COS(2*A)+COSH(2*B)) Return Value: TANH returns a floating point value. 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

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 DIM Description: 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) => 11 DCL AXIS(-3:3,-4:4) FLOAT DEC(6); DIM(AXIS,2) => 9
Internal Use Only

Internal Use Only

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)

Internal Use Only

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) 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

Internal Use Only

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) 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

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

Internal Use Only

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); 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 IV. DATE & TIME FUNCTIONS

Internal Use Only

DATE & TIME FUNCTION Description : Datetime function is used to get the current date and time. DECLARATION : DCL (DATE , TIME) BUILTIN; FUNCTIONS FORMAT USAGE : DATE & TIME : DATE YYMMDD TIME HHMMSSIII : dcl Gregorian char(6); dcl ist char(6); Gregorian = date; ist = time;

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 yyyymmdd Next 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

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

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

V. STRING HANDLING FUNCTIONS Referencing Substrings of Data Items (Reference Modifiers) SUBSTR Description: Substr is used to access a part of a string. Syntax: SUBSTR (String-var., Start-pos., Length-of-extract) 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. 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. Usage of INSPECT Statement

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.

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
Internal Use Only

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. VERIFY Description: Verify will see that a string will have only certain characters present. Syntax: VERIFY(x,y); USE INSPECT ---- TALLYING '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 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) 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

IF COUNTR = 0 EXIT END-PERFORM. Use value of I as position of character not present in main string. Example: IF VERIFY(RC_SEQ (J),NUM_CONST) = 0 THEN IS NUMERIC. Example: 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
Internal Use Only

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

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 Examples The 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-2

TALLYING COUNTR FOR LEADING "0" REPLACING FIRST "A" BY "2" AFTER INITIAL "C" DATA-2 Before 00ACADEMY00 0000ALABAMA CHATHAM0000 Example 2: 77 COUNTR PIC 9 VALUE ZERO. 01 DATA-3 PIC X(8). . . INSPECT DATA-3 REPLACING CHARACTERS BY ZEROS BEFORE INITIAL QUOTE DATA-3 Before 456"ABEL ANDES"12 "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-4 CONVERTING "abcdefghijklmnopqrstuvwxyz" TO
Internal Use Only

COUNTR After 2 4 0

DATA-2 After 00AC2DEMY00 0000ALABAMA CH2THAM0000

COUNTR 0 0 0

After DATA-3 After 000"ABEL 00000"12 "TWAS BR

"ABCDEFGHIJKLMNOPQRSTUVWXYZ" AFTER INITIAL "/" BEFORE INITIAL"?" DATA-4 Before a/five/?six r/Rexx/RRRr zfour?inspe DATA-4 After a/FIVE/?six r/REXX/RRRR zfour?inspe

Converting Data Items (Intrinsic Functions) 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-1 Display Function Upper-case(Item-1) Display Function Lower-case(Item-1) Move Function Upper-case(Item-1) to Item-2
Internal Use Only

Display Item-2 would 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) 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. Syntax: Function Length(X) 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. FUNCTION LENGTH(ABCD) => 4
Internal Use Only

LENGTH Description: Length gets the length of the argument

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:

STRING

STRING

Description: String concatenates all the elements in an array or a Description : String statement joins all or parts of several data items into one data item in the order you indicate. 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 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

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 decimal Y=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 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 string N=A decimal integer constant indicating the length of the result. N cannot be negative.
Internal Use Only

Usage of VALUE ALL Clause

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 characterstring to a bit string Syntax: BIT(X[,Y]); X=Expression/Array Name Y=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).
Internal Use Only

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

Syntax: High(X); X=Expression. 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. 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 GRAPHIC data 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 ADDR
Internal Use Only

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

N/A

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
Internal Use Only

Equivalent Function available in COBOL

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

NULL

VALUE IS NULL

NULL returns the null pointer value. The null pointer value does not identify any generation of a variable. The null pointer value can VALUE IS NULLS be converted to OFFSET by assignment of the built-in function This format assigns an invalid address as the initial value of an item value to an offset variable. defined as USAGE IS POINTER or USAGE IS PROCEDUREPOINTER. It also assigns an invalid object reference as the initial SYNTAX: value of an item defined as USAGE IS OBJECT NULL [ ( ) ]; REFERENCE.VALUE IS NULL can only be specified for Note: NULL and SYSNULL do not compare equal. However, elementary items described implicitly or explicitly as USAGE IS you should not write code that depends on them being POINTER, USAGE IS PROCEDURE-POINTER, or USAGE IS OBJECT REFERENCE unequal.

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

VII. BUILT-IN SUBROUTINES PLIRETC This built-in subroutine allows you to set a return code that can be In COBOL there is no as such direct mapping subroutine for examined by the program or (sub)system that invoked this PL/I PLIRETC but it can be handled as example shown below. 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;
MOVE 510 TO RETURN-CODE DISPLAY 'DATE CARD MISSING' CALL 'CANCEL'. DECLARE "RETURN-CODE" IN WORKING-STORAGE SECTION.

e.g.

PLIDUMP This built-in subroutine allows you to obtain a formatted dump of In COBOL there is no equivalent built in subroutine/ function so this functionality has to be handled in JCL using SYSDUMP selected parts of storage used by your program. SYNTAX: PLIDUMP(argument-list); PLIXOPT

Internal Use Only

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 ; 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.

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.

SKIP SKIP1 Specifies a single blank line to be inserted in the source listing.

SYNTAX: %SKIP [ (n) ]; SKIP2 n = number of lines to be skipped. It must be an integer in the range Specifies two blank lines to be inserted in the source listing. 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 SKIP3 %PAGE statement is executed in place of the %SKIP statement. Specifies three blank lines to be inserted in the source listing.
Internal Use Only

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,
Internal Use Only

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).

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);

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 onedimensional table that occurs three times. Double Dimensions

TABLE is declared as a two-dimensional array of eight fixedpoint 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.

To create a two-dimensional table, define a one-dimensional table in each occurrence of 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 an Element of a one-dimensional table that occurs two times. TABLE-COLUMN is an Element of a two-dimensional table that occurs three times in each occurrence of TABLE-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,
Internal Use Only

The items of a payroll can be declared as follows: 01 PAYROLL 02 NAME.

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 88 A 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

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 structuresan 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 :
Internal Use Only

N/A

- 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; Static
Internal Use Only

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

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:
Internal Use Only

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-name In the Procedure Division, a paragraph consists of a paragraphname 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.

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.
Internal Use Only

PERFORM 900000-TERMINATION THRU 900000-EXIT.

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/O Types 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.

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

GET Statement

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

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.
Internal Use Only

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.

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

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 items Control format items (line, page, space control) Remote format items DATA FORMAT ITEMS A(w) A B(w) B C E(w,d) E(w,d,s) F(w) F(w,d) F(w,d,p) X(w) Ppicture specification W total no of chars/digits d no.of fractional decimal places s no.of significant digits ( d + 1) p scaling factor A character notation
Internal Use Only

B C E F P

bit string notation complex variables floating point notation fixed point notation picture definition

CONTROL FORMAT ITEMS COLUMN(n) LINE(n) PAGE SKIP some options which can be stated in open statement are : option meaning default

linesize(nn) line length 120 chars per line pagesize(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

useful for producing annotated output. DATA DIRECTED I/O Syntax e.g. GET DATA (datalist) PUT DATA (datalist) 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=15 Output will be printed like this e.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

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
Internal Use Only

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.

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.

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 :

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 ENVIRONMENT INPUT OUTPUT PRINT STREAM Record-Oriented Data Transmission BACKWARDS BUFFERED DIRECT ENVIRONMENT EXCLUSIVE Group type INPUT KEYED OUTPUT RECORD SEQUENTIAL TRANSIENT UNBUFFERED UPDATE Default attribute

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.

Alternative attributes

Usage STREAM|RECORD STREAM Function INPUT|OUTPUT|UPDATE INPUT Access SEQUENTIAL|DIRECT|TRANSIENT SEQUENTIAL Buffering BUFFERED|UNBUFFERED BUFFERED (for SEQUENTIAL & TRANSIENT files); UNBUFFERED (for DIRECT files)
Internal Use Only

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); 2) Random Retrieval : READ file-name-1 RECORD INTO Identifier-1 KEY IS data-Name-1 INVALID KEY Imperative-Statement-1. 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.

Internal Use Only

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 File For random access, the INVALID KEY phrase must be Specified

Internal Use Only

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

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); 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))

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

Internal Use Only

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 FROM Data area into which logical record is read Data area from which record is written INTO FROM INPUT/OUTPUT VERBS Data area into which logical record is read 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
Internal Use Only

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

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 or Record 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, is converted to a character string and is used as the key of the record when it is written.
Internal Use Only

DIRECT FILE (LOANREC)

OUPTUT or DIRECT UPDATE in a REGIONAL example: WRITE FILE (LOANS) FROM KEYFROM(LOANNO)

KEYTO a cannot

Specifies the character variable to which the key of record is assigned.Variables with PIC and STRING

be used. Applies only to KEYED files of INDEXED, VSAM or REGIONAL organization. The Process Define the file Open the file Process the file record Closing the File EXAMPLE : DCL STOCK FILE STREAM INPUT; create a DD statement with a data definition name(DDNAME) //GO.STOCK DD DSN=PARTS.INSTOCK,. PL/I statement DECLARE filename FILE. OPEN FILE(filename) READ/WRITE/REWRITE for access by GET/PUT for stream access CLOSE FILE(filename) 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 The Process Define the file COBOL statement 1) ENVIRONMENT DIVISION

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

Internal Use Only

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 : Process the File :
Internal Use Only

CLOSE File-Name-1. READ/WRITE/REWRITE for access by

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 conditionsthose associated with data handling, expression evaluation, and computation. The conditions are: CONVERSION FIXEDOVERFLOW OVERFLOW SIZE UNDERFLOW ZERODIVIDE
Internal Use Only

If a computational condition (except UNDERFLOW) is raised and the condition is disabled, the program is in error. Input/output conditionsthose conditions associated with input and output. They are: ENDFILE ENDPAGE KEY NAME PENDING RECORD TRANSMIT 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

The conditions that are always enabled unless they are explicitly disabled by condition prefixes are: CONVERSION FIXEDOVERFLOW OVERFLOW UNDERFLOW ZERODIVIDE 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: NOCONVERSION NOFIXEDOVERFLOW NOOVERFLOW NOUNDERFLOW NOZERODIVIDE 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: SIZE SUBSCRIPTRANGE STRINGRANGE STRINGSIZE 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

NOSIZE NOSUBSCRIPTRANGE NOSTRINGRANGE NOSTRINGSIZE 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

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
Internal Use Only

AT END Phrase

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 WSTRANSACTION-RECORD AT END DISPLAY "END OF TRANSACTION UPDATE FILE REACHED" MOVE "TRUE" TO TRANSACTION-EOF END 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

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

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

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
Internal Use Only

SIZE ERROR

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.

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.

The SIZE condition differs from the FIXEDOVERFLOW condition in that, whereas FIXEDOVERFLOW is raised when the If you code the ON SIZE ERROR clause, the imperative size of a calculated fixed-point value exceeds the maximum statement of your clause will be performed and your result field allowed by the implementation, SIZE is raised when the size of will not be changed in the following five cases: the value being assigned to a data item exceeds the declared (or Fixed-point overflow. default) size of the data item. SIZE can be raised on assignment Division by 0. of a value regardless of whether or not FIXEDOVERFLOW was Zero raised to the zero power. raised in the calculation of that value. Zero raised to a negative number. A negative number raised to a fractional power. The declared size is not necessarily the actual precision with Overflow Note: Be aware that floating-point exponent overflow, which the item is held in storage; however, the limit for SIZE is which occurs when the value of a floating-point arithmetic the declared or default size, not the actual size in storage. For computation cannot be represented in the System/390 floatingexample, a fixed binary item of precision (20) occupies a fullword point operand format, does not cause SIZE ERROR; an abend in storage, but SIZE is raised if a value whose size exceeds occurs instead. You could code a user-written condition handler FIXED BINARY(20) is assigned to it. Because this checking to intercept the abend and provide your own error recovery logic. involves a substantial overhead in both storage space and run time, it usually is used only in program testing. You should Example of Checking for Division by Zero remove it for production programs. Code your ON SIZE ERROR imperative statement so that it If the SIZE condition is raised and it is disabled, the program is in issues an informative message. For example: error. DIVIDE-TOTAL-COST. DIVIDE TOTAL-COST BY NUMBER-PURCHASED GIVING ANSWER ON SIZE ERROR DISPLAY "ERROR IN DIVIDE-TOTAL-COST PARAGRAPH" DISPLAY "SPENT " TOTAL-COST, " FOR " NUMBERPURCHASED PERFORM FINISH END-DIVIDE
Internal Use Only

. . . 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 specifiedThis 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

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

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
Internal Use Only

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 FILECONTROL paragraph and data definitions in the DATA DIVISION. FILE STATUS IS data-name-1 data-name-1 Specifies 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 Example Figure 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-MASTERA FILE STATUS IS MASTER-CHECK-KEY . . DATA DIVISION.

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 MASTERFILE IF 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
Internal Use Only

Example of Checking for Division by Zero

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-PURCHASED GIVING ANSWER ON SIZE ERROR DISPLAY "ERROR IN DIVIDE-TOTAL-COST PARAGRAPH" DISPLAY "SPENT " TOTAL-COST, " FOR " NUMBERPURCHASED PERFORM FINISH END-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 action is 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

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 didnt reach the 46tth Page. COPY BOOK STATEMENTS % INCLUDE COPY

The %INCLUDE statement is used to incorporate source code from The COPY statement is a library statement that places prewritten text an external library into the source program. Do not put other in a COBOL compilation unit. statements on the same line as the %INCLUDE statement. The Syntax is : The syntax is : COPY Text-Name OF Library-Name. %INCLUDE [ Dataset-Name ( ] member-name [ ) ] ;
Internal Use Only

Text-Name, Library-Name : Dataset Specifies 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. 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.

Member Specifies the name of the library member to be incorporated in VM or EXAMPLE : the Name of the data set member to be incorporated in MVS. COPY PAYRL. EXAMPLE : If the source program contains the following statement: Here PAYRL contains the copybook . % 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

ERROR STATUS CODES IN PL/I


Internal Use Only

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; the remainder of the record is lost. . The record length specified for a file with fixed-length records is larger than the variable in a WRITE, REWRITE, or LOCATE statement; the remainder of the record is undefined. If the variable is a varying-length string, RECORD is not raised if the SCALARVARYING option is applied to the file. 22 Record variable larger than record size. Either: . The record length specified for a file with fixed-length records is smaller than the variable in a READ INTO statement; the remainder of the variable is undefined. If the variable is a varying-length string, RECORD is not raised if the SCALARVARYING option is applied to the file. . The maximum record length is smaller than the variable in a WRITE, REWRITE, or LOCATE statement. For WRITE or REWRITE, the remainder of the variable is lost; for LOCATE, the variable is not transmitted. . The variable in a WRITE or REWRITE statement indicates a zero length; no transmission occurs. If the variable is a varying-length string, RECORD is not raised if the SCALARVARYING option is applied to the file. 23 Record variable length is either zero or too short to contain the embedded
Internal Use Only

key. The variable in a WRITE or REWRITE statement is too short to contain the data set embedded key; no transmission occurs. (This case currently applies 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 present in data set; or, in a REGIONAL(1) data set, attempt to write into a region already containing a record. 53 Value of expression specified in KEYFROM option during sequential creation of INDEXED or REGIONAL data set is less than value of previously specified key or region number. 54 Key conversion error, possibly due to region number not being numeric character. 55 Key specification is null string or begins (8)'1'B or a change of embedded key has occurred on a sequential REWRITE[FROM] for an INDEXED or
Internal Use Only

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 DECLARE statement and those in explicit or implicit OPEN statement. 82 Conflict between file attributes and physical organization of data set (for example, between file organization and device type), or VSAM data set has not been loaded. 83 After merging ENVIRONMENT options with DD statement and data set label, data set specification is incomplete; for example, block size or record format has not been specified. 84 No DD statement associating file with a data set. 85 During initialization of a DIRECT OUTPUT file associated with a REGIONAL data set, an input/output error occurred. 86 LINESIZE greater than implementation-defined maximum, or invalid value in an ENVIRONMENT option. 87 After merging ENVIRONMENT options with DD statement and data set label, conflicts exist in data set specification; the value of LRECL, BLKSIZE or RECSIZE are incompatible with one another or the DCB FUNCTION specified. 88 After merging ENVIRONMENT options with DD statement and data set label, conflicts exist in data set specification; the resulting combination of
Internal Use Only

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 opening of a VSAM data set with the BKWD option, the attempt to position the data set 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 condition occurred. 151 Truncation occurred during assignment of a mixed-character string. 300 SIGNAL OVERFLOW statement executed or OVERFLOW condition occurred. 310 SIGNAL FIXEDOVERFLOW statement executed or FIXEDOVERFLOW condition occurred. 320 SIGNAL ZERODIVIDE statement executed or ZERODIVIDE condition occurred. 330 SIGNAL UNDERFLOW statement executed or UNDERFLOW condition
Internal Use Only

occurred. 340 SIGNAL SIZE statement executed; or high-order nonzero digits have been lost in an assignment to a variable or temporary, or significant digits have been 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 condition occurred. 360 Attempt to allocate a based variable within an area that contains insufficient free 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 condition occurred. 500 SIGNAL CONDITION (name) statement executed. 510 SIGNAL CHECK statement executed. 520 SIGNAL SUBSCRIPTRANGE statement executed, or subscript has been evaluated and found to lie outside its specified bounds. 521 Subscript of iSUB-defined variable lies outside bounds of corresponding dimension 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

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 statement following 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 statement following 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 statement following TRANSMIT condition. 612 Error during character value to arithmetic conversion. 613 Error during character value to arithmetic conversion for a GET or PUT FILE statement. 614 Error during character value to arithmetic conversion for a GET or PUT FILE 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 FILE statement. 617 Error during character value to bit value conversion for a GET or PUT FILE statement following a TRANSMIT condition. 618 Error during character value to picture conversion.
Internal Use Only

619 Error during character value to picture conversion for a GET or PUT FILE statement. 620 Error during character value to picture conversion for a GET or PUT FILE statement 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 a TRANSMIT 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 following a TRANSMIT condition. 627 A graphic or mixed-character string encountered in a nongraphic environment. 628 A graphic or mixed-character string encountered in a nongraphic environment on input. 629 A graphic or mixed-character string encountered in a nongraphic environment 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 input after TRANSMIT was detected. 636 A shift character detected in a graphic string.
Internal Use Only

639 During processing of a mixed-character string, one of the following occurred: . A shift-in present in the SBCS portion. . A shift-out present in the graphic (double-byte) portion. (A shift-out cannot 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 previously raised 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 in a GET STRING DATA statement. 1009 An input/output statement specifies an operation or an option which conflicts with the file attributes. 1011 Data management detected an input/output error but is unable to provide any 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 statement specifies data which has been previously read in by a READ statement with an EVENT option, and no corresponding WAIT has been executed. 1014 Attempt to initiate further input/output operation when number of incomplete operations equals number specified by ENVIRONMENT option NCP(n) or by default.
Internal Use Only

1015 Event variable specified for an input/output operation when already in use. 1016 After UNDEFINEDFILE condition raised as a result of an unsuccessful attempt to implicitly open a file, the file was found unopened on normal return from the ON-unit. 1018 End of file or string encountered in data before end of data-list or (in edit-directed transmission) format list. 1019 Attempt to close file not opened in current task. 1020 Further input/output attempted before WAIT statement executed to ensure completion 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 function
Internal Use Only

is negative. 1501 Computational error; long floating point argument of SQRT built-in function is < 0. 1502 Computational error; extended floating point argument of SQRT built-in function is negative. 1503 Computational error in LOG, LOG2, or LOG10 built-in function; extended floating point argument is <= 0. 1504 Computational error in LOG, LOG2, or LOG10 built-in function; short floating point argument is <= 0. 1505 Computational error in LOG, LOG2 or LOG10 built-in function; long floating point argument is <= 0. 1506 Computational error in SIN, COS, SIND, or COSD built-in function; absolute value 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; absolute value 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 TAN or TAND built-in function exceeds, respectively, (2**18)*pi or (2**18)*180. 1509 Computational error; absolute value of long floating point argument of TAN or TAND built-in function exceeds, respectively, (2**50)*pi or (2**50)*180. 1510 Computational error; short floating point arguments of ATAN or ATAND built-in function both zero. 1511 Computational error; long floating point arguments of ATAN or ATAND built-in function both zero. 1514 Computational error; absolute value of short floating point argument of
Internal Use Only

ATANH built-in function >= 1. 1515 Computational error; absolute value of long floating point argument of ATANH built-in function >= 1. 1516 Computational error; absolute value of extended floating point argument of ATANH built-in function >= 1. 1517 Computational error in SIN, COS, SIND, or COSD built-in function; absolute value of extended floating point argument exceeds (2**106)*pi (SIN and COS) or (2**106)*180 (SIND and COSD). 1518 Computational error; absolute value of short floating point argument of ASIN or ACOS built-in function exceeds 1. 1519 Computational error; absolute value of long floating point argument of ASIN or ACOS built-in function exceeds 1. 1520 Computational error; absolute value of extended floating point argument of ASIN, ACOS built-in function exceeds 1. 1521 Computational error; extended floating point arguments of ATAN or ATAND built-in function both zero. 1522 Computational error; absolute value of extended floating point argument of TAN or TAND built-in function >= (2**106)*pi or (2**106)*180, respectively. 1550 Computational error; during exponentiation, real short floating-point base is zero and integer value exponent is not positive. 1551 Computational error; during exponentiation, real long floating-point base is zero and integer value exponent is not positive. 1552 Computational error; during exponentiation, real short floating point base is zero and the floating-point or noninteger exponent is not positive. 1553 Computational error; during exponentiation, real long floating point base is zero and the floating-point or noninteger exponent is not positive.
Internal Use Only

1554 Computational error; during exponentiation, complex short floating point base is zero and integer value exponent is not positive. 1555 Computational error; during exponentiation, complex long floating point base is zero and integer value exponent is not positive. 1556 Computational error; during exponentiation, complex short floating point base is zero and floating-point or noninteger exponent is not positive and real. 1557 Computational error; during exponentiation, complex long floating point base is zero and floating-point or noninteger exponent is not positive and real. 1558 Computational error; complex short floating point argument of ATAN or ATANH built-in function has value, respectively, of 1I or 1. 1559 Computational error; complex long floating point argument of ATAN or ATANH built-in function has value, respectively, of 1I or 1. 1560 Computational error; during exponentiation, real extended floating-point base is zero and integer value exponent not positive. 1561 Computational error; during exponentiation, real extended floating point base is zero and floating-point or noninteger exponent is not positive. 1562 Computational error; during exponentiation, complex extended floating point base is zero and integer value exponent is not positive. 1563 Computational error; complex extended floating point base is zero and floating-point or nonintegral exponent is not positive. 1564 Computational error; complex extended floating point argument of ATAN or ATANH built-in function has value, respectively, of 1I or 1. 2002 WAIT statement cannot be executed because of restricted system facility.
Internal Use Only

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 do not 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-in was found. 3010 During processing of a mixed-character constant, one of the following occurred: . A shift-in present in the SBCS portion. . A shift-out present in the graphic (double-byte) portion. (A shift-out cannot 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 function string, 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 than 16,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 used as part of a variable name or string. 3017 Invalid graphic, mixed, or DBCS continuation when writing Stream I/O to a file containing fixed-length records.
Internal Use Only

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 being raised by an invalid character in the string being converted, the character has not been corrected by use of the ONSOURCE or ONCHAR pseudovariables. 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 already active. 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 main storage available. 3910 Attempt to attach a task (using CALL statement) when number of active tasks is already at limit defined by PLITASKCOUNT run-time option or installation default. 3911 WAIT statement in ON-unit references an event variable already being
Internal Use Only

waited for in task from which ON-unit was entered. 3912 Attempt to execute CALL with TASK option in block invoked while executing PUT 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 some other 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 the link-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 during GET 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

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 language programs. 9257 Attempt to fetch a subroutine using the PLICALLA entry point. 9999 A failure occurred during an invocation of an Language Environment for MVS & VM service.

FILE STATUS CODES IN COBOL 00 02 04 05 07 10 14 Operation completed successfully Duplicate Key was found Invalid fixed length record The file was created when opened - Successful Completion CLOSE with REEL or NO REWIND executed for non tape dataset. End of File encountered Attempted to READ a relative record outside file boundary
Internal Use Only

21 22 23 24 30 34 35 37 38 39 41 42 43 44 46 47 48 49 91 92 93 94 95 96 97 98 99

Invalid Key - Sequence error Invalid Key - Duplicate Key found Invalid key - No record found Invalid Key - key outside boundary of file. Permanent I/O Error Permanent I/O Error - Record outside file boundary OPEN, but file not found OPEN with wrong mode Tried to OPEN a LOCKed file OPEN failed, conflicting file attributes Tried to OPEN a file that is already open Tried to CLOSE a file that is not OPEN Tried to REWRITE without READing a record first Tried to REWRITE a record of a different length Tried to READ beyond End-of-file Tried to READ from a file that was not opened I-O or INPUT Tried to WRITE to a file that was not opened I-O or OUTPUT Tried to DELETE or REWRITE to a file that was not opened I-O Password or authorization failed Logic Error Resource was not available (may be allocated to CICS or another user) Sequential record unavailable or concurrent OPEN error File Information invalid or incomplete No DD statement for the file OPEN successful and file integrity verified File is Locked - OPEN failed Record Locked - record access failed.

Internal Use Only

You might also like