Source programs are accepted as a sequence of lines(or records)of 80 characters or less. Each line is divided into five areas, as illustrated below.
The sequence number and identification areas are used for clerical and documentation purposes. They are ignored by the compiler.
The indicator area is used for denoting line continuation, comments and debugging.
Areas A and B contain the actual program according to the following rules:
Continuation of Lines
Any sentence, entry, phrase, or clause may be continued by starting subsequent lines in area B. These subsequent lines are called continuation lines.
The line being continued is called the continued line. Any word, literal, or PICTURE character-string may be broken in such a way that part of it appears on a continuation line, according to the following rules:
However, if the continued line contains a nonnumeric literal without a closing quotation mark, the first nonblank character in area B on the continuation line must be a quotation mark,and the continuation line starts with the character immediately after that quotation mark. All spaces at the end of the continued line are considered part of the literal. Area A of a continuation line must be blank. The quotation mark used to continue a nonnumeric literal must be the same quotation mark(that is,it must be a quotation mark or an apostrophe)that began the nonnumeric literal.
Continuing a nonnumeric literal according to the previous paragraph is a deprecated feature maintained only for compatibility with older programs. Concatenation expressions are the recommended method of continuing nonnumeric literals in all new RM/COBOL programs.
A blank line is one that is blank in the indicator, A and B areas. A blank line can appear anywhere in the source program.
A comment line is any line with an asterisk or a slash in the indicator area of the line. A comment line may appear as any line after the Identification Division header of a source program and as any line in library text referred to by a COPY statement. Any combination of characters from the character set of the computer may be included in area A and area B of a comment line. Comment lines are reproduced on the listing but serve as documentation only.
When a comment line is indicated with an asterisk, the comment is printed on the next available line in the listing. When a comment line is indicated with a slash, page ejection occurs before the comment line is printed.
The character-strings and separators comprising pseudo-text may start in either area A or area B. If there is a hyphen in the indicator area of a line that follows the opening pseudo-text delimiter, area A of the line must be blank and the normal rules for continuation of lines apply to the formation of text words.
An in-line comment begins with the two contiguous characters *>preceded by a separator space, and ends with the last character position of the line. An in-line comment may be placed anywhere a separator space may be placed in a COBOL source program or in library text for a COBOL source program. For the purpose of evaluating library text, pseudo-text, and source text,an in-line comment has the value of a single space character. An in-line comment that is not preceded by any COBOL words or characterstrings on the same line is equivalent to a comment line, except that it may not be placed between a continued line and a continuation line if a word, literal, or PICTURE character-string is broken across the continuation.
Note: An in-line comment is not recognized as such, if it occurs in the sequence area (columns 1 to 6) or the identification area (column 73 through 80) of a source line.An in-line comment that begins in the indicator area is indistinguishable from a comment line.
A debugging line is any line with a D in the indicator area of the line. Any debugging line that consists solely of spaces from margin A to margin R is considered the same as a blank line.
The content of a debugging line must be such that a syntactically correct program is formed with or without the debugging lines being considered as comment lines.
A debugging line will be considered to have all the characteristics of a comment line if the Debug Compile Command Option is not specified and the WITH DEBUGGING MODE clause is not specified in the SOURCE-COMPUTER paragraph.
Successive debugging lines are allowed.
A debugging line is only permitted in the separately compiled program after the OBJECT-COMPUTER paragraph, or, if the OBJECT-COMPUTER paragraph is omitted, after where the OBJECT-COMPUTER paragraph would be permitted if it were present.
Source statements always begin with a keyword called a verb.There are four kinds of statements:
A directive statement specifies action to be taken by the compiler during compilation. The directive statements are the COPY, REPLACE, and USE statements.
A conditional specifies that the truth value of a condition is to be determined and that the subsequent action of the object program is dependent on this truth value.
A conditional statement is one of the following:
A conditional phrase specifies the action to be taken upon determination of the truth value of a condition resulting from execution of a conditional statement.
A conditional phrase is one of the following:
An imperative statement begins with an imperative verb and specifies an unconditional action to be taken by the object program, or is a conditional statement that is delimited by its explicit scope terminator (delimited scope statement). An imperative statement may consist of a sequence of imperative statements,each possibly separated from the next by a separator or the word THEN.
The imperative verbs are listed below
Wherever imperative-statement appears in the general format of statements it refers to that sequence of consecutive imperative statements that must be ended by a period or by any phrase associated with a statement containing imperative-statement.
Delimited Scope Statements
A delimited scope statement is any statement that includes its explicit scope terminator.The explicit scope terminators are the following:
Scope of Statements
Scope terminators delimit the scope of certain Procedure Division statements. Statements that include their explicit scope terminators are called delimited scope statements. The scope of statements that are contained within statements (nested) may also be implicitly terminated.
When statements are nested within other statements, a separator period that ends the sentence implicitly terminates all nested statements.
When any statement is contained within another statement, the next phrase of the containing statement following the contained statement terminates the scope of any unterminated contained statement.
When statements are nested within other statements that allow optional conditional phrases, any optional conditional phrase encountered is considered to be the next phrase of the nearest preceding unterminated statement with which that phrase is permitted to be associated but with which no such phrase has already been associated. An unterminated statement is one that has not been previously terminated either explicitly or implicitly.
When a delimited scope statement is nested within another delimited scope statement with the same verb, each explicit scope terminator terminates the statement started by the most recently preceding, and as yet unterminated, occurrence of that verb.
A sentence is a sequence of one or more statements terminated by the period separator. There are three kinds of sentences:
Clauses and Entries
An entry is an item of descriptive or declaratory nature made up of consecutive clauses. Each clause specifies an attribute of the entry. Clauses are separated by space, comma, or semicolon separators. The entry is terminated by a period separator.
A paragraph is a sequence of zero, one, or more sentences or entries.In the Identification and Environment Divisions, each paragraph begins with a reserved word called a paragraph header. In the Procedure Division, each paragraph begins with a userdefined paragraph-name.
A section is a sequence of zero, one, or more paragraphs in the Environment and Procedure Divisions and a sequence of zero, one, or more entries in the Data Division. In the Environment and Data Divisions, each section begins with a section header that is made up of reserved words.In the Procedure Division, each section begins with a user-defined section-name.
With the exception of COPY and REPLACE statements and the end program header, the statements, entries, paragraphs, and sections of a source program are grouped into four divisions which are sequenced in the following order:
The end of a source program is indicated either by the end program header,if specified,or by the absence of additional source program lines.
Source Program General Format
The following gives the general format and order of presentation of the entries and statements that constitute a source program. The generic terms identification-division, environment-division, data-division, procedure-division, nested-source-program, and end-program-header represent an Identification Division, an Environment Division,a Data Division, a Procedure Division, a nested source program, and an end program header.
end-program-header must be present if either of the following circumstances exists:
COBOL Related Interview Questions
|VSAM Interview Questions||IBM - VSAM Interview Questions|
|IBM-CICS Interview Questions||JCL Interview Questions|
|IBM DB2 Interview Questions||IBM-JCL Interview Questions|
|DB2 Using SQL Interview Questions||IBM-JCL&VSAM Interview Questions|
|IBM Mainframe Interview Questions||COBOL, CICS, JCL, VSAM, DB2 Interview Questions|
|DB2 SQL Programming Interview Questions||IMS/DB Interview Questions|
|Mainframe DB2 Interview Questions|
Procedure Division Statements
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.