A character-string is a sequence of one or more characters that forms a COBOL word, literal, PICTURE character-string, or comment-entry. A character-string is delimited by separators.
A COBOL word is a character-string of not more than 30 characters which forms a user-defined word, a system-name, a context-sensitive word,or a reserved word. Each character of a COBOL word is selected from the set of letters, digits and the hyphen. The hyphen may not appear as the first or last character. Lowercase letters are considered equivalent to the corresponding uppercase letters. Within a source program, reserved words and user-defined words form disjoint sets; reserved words and systemnames form disjoint sets, system-names and user-defined words form intersecting sets.
The same COBOL word may be used as a system-name and as a user-defined word within a source program; the class of a specific occurrence of this COBOL word is determined by the context of the clause or phrase in which it occurs.
User-defined words comprise alphabetic and numeric characters,and the hyphen. A user-defined word can neither begin nor end with a hyphen. With the exception of paragraph-names, section-names, level-numbers and segment-numbers, all user-defined words must contain at least one alphabetic character.
Here are the types of user-defined words:
Within a given source program,but excluding any contained program,the user-defined words are grouped into the following disjoint sets:
All user-defined words, except segment-numbers and level-numbers,can belong to only one of these disjoint sets. Further, all user-defined words within a given disjoint set must be unique, except as specified in the rules for uniqueness of reference. Segment-numbers and level-numbers need not be unique;a given specification of a segment-number or level-number may be identical to any other segment-number or level-number.
The types of user-defined words are defined as follows:
System-names identify certain hardware or software system components. System-names consist of code-names,device-names, feature-names, label-names, low-volume-I-O-names, record delimiting techniques,and switch-names. Most system-names are not reserved words, but certain reserved words may be used as system-names.
Reserved words are those words reserved for use by the RM/COBOL compiler. A reserved word must not appear as a user-defined word within a program. Appendix A, Reserved Words, contains a complete list of reserved words.
Five kinds of reserved words are recognized by the compiler:
The ADDRESS special register returns the address of identifier-1 as a pointer data item. It may only be used in certain contexts of the Procedure Division where a pointer is allowed, which are a relation condition with another pointer data item, a CALL statement USING phrase, or a Format 5 or 6 SET statement.The ADDRESS special register is not allowed in the GIVING phrase of a CALL statement even though a pointer data item is allowed there. When specified in the USING phrase of a CALL statement,the ADDRESS special register is always passed by content. When identifier-1 is a Linkage Section data item for which the base address has not been set by being associated with an actual argument in a calling program or by execution of a SET statement, the ADDRESS special register will return a null pointer value. If identifier-1 were referenced in such a case without the ADDRESS special register, the run unit would terminate with a data reference error. Thus, the ADDRESS special register may be used in an IF statement to prevent a data reference termination of the run unit by avoiding the reference when the ADDRESS OF identifier-1 is equal to NULL.
The COUNT special register exists for each COBOL table data item, that is, data-name-1 must refer to a data item described with the OCCURS clause. For a fixed occurrence table, COUNT returns the fixed number of occurrences specified in the OCCURS clause. For a variable occurrence table, COUNT returns the value of the data-name specified by the DEPENDING ON phrase of the OCCURS clause. It may be used wherever an integer literal may be used in the Procedure Division.
The COUNT-MAX special register exists for each COBOL table data item, that is, data-name-1 must refer to a data item described with the OCCURS clause. COUNT-MAX always returns the maximum number of occurrences specified in the OCCURS clause. For a fixed occurrence table, COUNT, COUNT-MAX, and COUNT-MIN will return the same value. It may be used wherever an integer literal may be used in the Procedure Division.
The COUNT-MIN special register exists for each COBOL table data item, that is, data-name-1 must refer to a data item described with the OCCURS clause. COUNT-MIN always returns the minimum number of occurrences specified in the OCCURS clause. For a fixed occurrence table, COUNT, COUNT-MAX, and COUNT-MIN will return the same value. It may be used wherever an integer literal may be used in the Procedure Division.
The LENGTH special register exists for any data item or literal. It returns the length of the data item referenced by identifier-1 or value referenced by literal-1. It may be used wherever an integer literal may be used in the Procedure Division. For a variable length group, the LENGTH special register returns the current length of the group. For a reference modified identifier, the LENGTH special register returns the length of the result of the reference modification, that is, the result of the evaluation of the length modifier if it was specified or the remaining length of the data item after the offset has been applied if the length modifier is not specified. For a literal, the LENGTH special register returns the number of characters in the literal. If the literal is a numeric literal, the number of characters is the same as the number of digits.That is,for a numeric literal, the sign and decimal point characters, if specified, are not counted in the length of the literal.
The LINAGE-COUNTER special register is a line counter,generated by the presence of a LINAGE clause in a file description entry.PROGRAM-ID
The PROGRAM-ID special register exists for any program. It returns the program-name of the program in which it is used. It may be used wherever a nonnumeric literal may be used in the program, except for the END PROGRAM header. The PROGRAM-ID special register is an exception to the rule that special registers may be referenced only in Procedure Division statements. The PROGRAM-ID special register may be specified in VALUE clauses of data description entries for nonnumeric data items or constant-name definitions. If the program-name is specified as a nonnumeric literal in the PROGRAM-ID paragraph, the value of the PROGRAM-ID special register will match that nonnumeric literal,including its case; otherwise, the value of the PROGRAM-ID special register will be in uppercase.RETURN-CODE
The RETURN-CODE special register has the implicit description PICTURE S9999 COMP-4, and can be set by the user to pass a return code to the calling program or the operating system before executing a STOP RUN, EXIT PROGRAM or GOBACK statement. When control is returned to a calling program, the return code passed by the called program is available to the calling program in the RETURN-CODE special register;the return code value can be tested by specifying RETURN-CODE in a relation condition.When control is returned to the operating system, the return code may be available to the command language in a system dependent manner;see the RM/COBOL User’s Guide for specific information. The return code is initialized to zero at the start of a run unit. This is the normal return code for successful completion;other values returned are conventionally in multiples of four. Some return code values, generally the higher values,are reserved for runtime-detected errors;see the appropriate chapters on installation and system considerations in the RM/COBOL User’s Guide.
The return code is implicitly set to the value specified in statements having the following form:
This statement is equivalent to the statement sequence:
The words listed in Table A-1 on page A-7 are context-sensitive words and are reserved in the specified language construct or context.If a context-sensitive word is used where the context-sensitive word is permitted in the general format,the word is treated as a keyword;otherwise,it is treated as a user-defined word.
A literal is a character-string whose representation is identical to its value.Literals are either numeric or nonnumeric.
A numeric literal represents a numeric value,not a character-string.Numeric literals are built according to the following rules:
The word integer, when used in the syntax charts in this manual, designates an unsigned,numeric literal without a decimal point. Its value cannot be zero unless specifically allowed within a particular context.
Here are some examples:
A nonnumeric literal is a character-string enclosed in quotation marks. The character-string may contain any character from the character set of the computer. Quotation marks within the string are represented by two contiguous quotation marks. Either the quotation mark or the apostrophe may be used as the delimiter, but within one literal, the first quotation mark establishes the delimiter character for that literal. The value of the literal is the string itself excluding the delimiting character and one of each contiguous pair of embedded quotation marks. The literal may contain from 1 to 65535 characters.
Hexadecimal literals of the form:
are also permitted as another form of nonnumeric literal, where h is any valid hexadecimal digit. Two hexadecimal digits occupy one character position. If an odd number of hexadecimal digits is specified, the compiler assumes an additional hexadecimal zero digit on the right to complete the rightmost character position.
Table lists some nonnumeric literals and their associated values.
All nonnumeric literals are of category alphanumeric.
Non numeric Literals and Their Values
Figurative constants identify commonly used constant values. These constant values are generated by the compiler according to the context in which the references occur. Note that figurative constants represent values, not literal occurrences. Thus, QUOTE cannot delimit a nonnumeric literal, SPACE is not a separator, and so forth. Singular and pluralforms of figurative constants may be used interchangeably.
The following constant represents the value 0 or one or more zero characters, depending on context.[ALL] ZERO,[ALL] ZEROS,[ALL] ZEROES
The following constant represents one or more space characters.[ALL] SPACE, [ALL] SPACES
Except in the SPECIAL-NAMES paragraph, the following constant represents one or more occurrences of the character that has the highest ordinal position in the program collating sequence.The native HIGH-VALUE is FFh.[ALL] HIGH-VALUE, [ALL] HIGH-VALUES
Except in the SPECIAL-NAMES paragraph, the following constant represents one or more occurrences of the character that has the lowest ordinal position in the program collating sequence. The native LOW-VALUE is 00h.[ALL] LOW-VALUE, [ALL] LOW-VALUES
The following constant represents one or more quotation marks.[ALL] QUOTE, [ALL] QUOTES
The following constant represents one or more null or unset pointer values. The usage of this constant is POINTER. Thus, this constant may only be used in places where pointer literal is allowed,which are in the VALUE clause in the data description entry of a usage POINTER data item,in relation conditions involving another pointer data item, in the USING phrase of the CALL statement, and in Format 5 of the SET statement.[ALL] NULL, [ALL] NULLS
The following constant represents all or part of the string generated by successive concatenations of the characters comprising literal-1. literal-1 must be a nonnumeric literal and may be a concatenation expression.literal-1 must not be a figurative constant.ALL literal-1
The following constant represents one or more of the character specified as the value of symbolic-character-1 in the SYMBOLIC CHARACTERS clause of the SPECIAL-NAMES paragraph.[ALL ] symbolic-character-1
When a figurative constant represents a string of one or more characters,the length of the string is determined by the compiler from context according to the following rules:
A figurative constant may be used wherever literal appears in syntax,with the following exceptions:
Each reserved word which refers to a figurative constant value is a distinct character-string with the exception of constructs using the word ALL, such as ALL literal, ALL SPACES, and so forth, which are composed of two distinct characterstrings.
A concatenation expression consists of two nonnumeric literals separated by the concatenation operator &:literal-1 & literal-2
Both literal-1 and literal-2 must be nonnumeric literals, but either may be specified with a hexadecimal literal, a figurative constant (including a symbolic-character), or a constant-name that refers to a nonnumeric value. When a figurative constant is specified in a concatenation expression, its length is determined by the rules for a figurative constant that is not associated with another data item regardless of the context in which the concatenation expression is used.
The value of a concatenation expression is the concatenation of the value of literal-1 and literal-2.
A concatenation expression may be used anywhere a nonnumeric literal may be used unless otherwise prohibited by specific rules of a given format. literal-1 of a concatenation expression may be a concatenation expression, but, for formal reasons having to do with termination of the syntax production, literal-2 cannot be a concatenation expression. However, any number of nonnumeric literals may be concatenated by repeated application of literal-1 being a concatenation expression.
A PICTURE character-string consists of certain combinations of characters used as symbols. Any punctuation character appearing as part of a PICTURE character-string is considered a symbol, not a punctuation character. If the punctuation character comma, period, or semicolon is followed by a space, it is a separator that delimits the PICTURE character-string and is not part of the PICTURE character-string.
A comment-entry is an entry in the Identification Division that may contain any characters from the character set of the computer. It terminates at the next nonblank area A.
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 © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.