By using Intrinsic function, FUNCTION CURRENT-DATE
The difference between the next and continue verb is that in the continue verb it is used for a situation where there in no EOF condition that is the records are to be accessed again and again in an file, whereas in the next verb the indexed file is accessed sequentially, read next record command is used.
Because, Occurs clause is there to repeat fields with same format, not the records.
Always compare on the highest-level first, because if you have a break at a highest level, each level beneath it must also break. Add to the lowest level for each record but add to the higher level only on a break.
There is no picture clause to be given. Example 01 WS-VAR USAGE COMP-1.
It is stored in the most significant bit. Bit is ON if -ve, OFF if +ve.
01 EMP-GRP.
49 E-LEN PIC S9(4) COMP.
49 E-NAME PIC X(25).
The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs.
A report item is a field to be printed which has Edit Symbols.
A literal is a data item which consists value by itself. It cannot be referred by a name. They are constant data items. There are two types of literals:
String / Alphanumeric Literals
Numeric Literals
S(8) can store 4 bytes and the highest value is 99999999.
The serial SEARCH verb is equivalent to the Perform-Varying statement, and it is nothing but search without ALL.
Even before the REWRITE is performed, the record must be opened and read from the file. For the same purpose, the file must be opened in I-O mode for REWRITE functionality.
The parameters passed in a call by context are protected from modification by the called program. In a normal call they are able to be modified.
A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then incremented or decrements by ADD TO and SUBTRACT FROM statements. An index is a register item that exists outside the programs working storage. You SET an index to a value and SET it UP BY value and DOWN BY value.
1) use 'evaluate' stmt for constructing cases.
2) use scope terminators for nesting.
3) use in line perform stmt for writing 'do ' constructions.
4) use test before and test after in the perform stmt for writing do-while constructions.
The program will go in an infinite loop.
INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. The REPLACING option can be used to override these defaults.
In a binary search the table element key values must be in ascending or descending sequence. The table is 'halved' to search for equal to, greater than or less than conditions until the element is found. In a sequential search the table is searched from top to bottom, so (ironically) the elements do not have to be in a specific sequence. The binary search is much faster for larger tables, while sequential works well with smaller ones. SEARCH ALL is used for binary searches; SEARCH for sequential.
Searching orders for SEARCH ALL can be either ASCENDING or DESCENDING. ASCENDING is the default one. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).
INITIALIZE verb initializes the values in a data item to the default value. Numeric edited items are set to zero, alphabetic fields and alphanumeric edited items are set to spaces. FILLERS, OCCURS DEPENDING ON items are left untouched.
Fixed Block File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0 .
Fixed Unblocked – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, do not use BLOCK CONTAINS
Variable Block File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4 Variable Unblocked – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4.
ESDS VSAM file – Use ORGANISATION IS SEQUENTIAL.
KSDS VSAM file – Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD KEY IS
RRDS File – Use ORGANISATION IS RELATIVE, RELATIVE KEY IS
Printer File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).
In COBOL II the optional clause WITH TEST BEFORE or WITH TEST AFTER can be added to all perform statements. By default the test is performed before the perform.
A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then incremented or decrements by ADD TO and SUBTRACT FROM statements. An index is a register item that exists outside the program's working storage. You SET an index to a value and SET it UP BY value and DOWN BY value.
Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. Make scope terminator as explicit for good coding standards.
SORT can be performed when
1. Input and Output files must remain closed
2. Working file must have a select clause
3. Input and Output files have FD entries
4. Work file should have short description in File Section
Using EXEC CICS SPOOL WRITE (var-name) END-EXEC command. Var-name is a COBOL host structure containing JCL statements.
1. You can REDEFINE a Variable from one PICTURE class to another PICTURE class by using the same memory location.
2. By REDEFINES we can INITIALISE the variable in WORKING-STORAGE Section itself.
3. We can REDEFINE a Single Variable into so many sub variables. (This facility is very useful in solving Y2000 Problem.)
A program that follows a top down approach. It is also one that other programmers or users can follow logically and is easy to read and understand.
In a binary search, the table element key values will be in ascending or descending sequence. The table is ‘halved'(Divided into two) to search for equal to, greater than or less than conditions until the element is found.
In a sequential search, the table is searched from top to bottom, so the elements do not have to be in a specific sequence.
The binary search is much faster for more tables, while sequential Search works well with lesser ones. SEARCH ALL is used for binary search; SEARCH for sequential search.
First, we have to compare the item to be searched with the item at the center.
If it matches, it is good to go with the value else repeat the process with the left half or the right half depending on where the item lies.
To find out the current date with the century, use an Intrinsic function called Function Current Date.
Following guidelines to be following while writing Cobol program:
>> Use ‘EVALUATE’ statement for constructing cases.
>> Use scope terminators for nesting.
>> Use in-line Perform statement for writing ‘do’ constructions.
>> Use Test Before and Test After in the Perform statement while writing Do-While statements.
One must follow certain guidelines while writing COBOL. They are mentioned below:
Using the ‘EVALUATE’ statement for constructing cases
Using scope terminators for nesting
Using in-line Perform statement for writing ‘do’ constructions
Using Test Before and Test After in the Perform statement while writing Do-While statements
Pic 9v99 refers to a three-position numeric field with an implied or assumed decimal point after the first position.
Here, v stands for an implied decimal point.
When any data name, file-name, Record-name, condition name or Index defined in an Including Program can be referenced by a directly or indirectly in an included program, Provided the said name has been declared to be a global name by GLOBAL Format of Global Clause is01 data-1 pic 9(5) IS GLOBAL.
REPLACING allows for the same copy to be repeated more than once in the same code just by replacing the value.
Syntax: COPY REPLACING BY
Because, Occurs clause is there to repeat fields with same format, not the records.
No, it can be used only with alphabetic and alphanumeric data types.
You can REDEFINE a Variable from one PICTURE class to another PICTURE class by using the same memory location. By REDEFINES we can INITIALIZE the variable in WORKING-STORAGE Section itself. We can REDEFINE a Single Variable into so many sub-variables. (This facility is very useful in solving Y2K Problem.)
The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs.
A scope terminator brackets its preceding verb, e.g. IF .. END-IF, so that all statements between the verb and its scope terminator are grouped together. Other common COBOL II verbs are READ, PERFORM, EVALUATE, SEARCH and STRING.
There are at least five differences:
COBOL II supports structured programming by using in line Performs and explicit scope terminators, It introduces
new features (EVALUATE, SET. TO TRUE, CALL. BY CONTEXT, etc) It permits programs to be loaded and
addressed above the 16-megabyte line It does not support many old features (READY TRACE, REPORT-WRITER,
ISAM, Etc.), and It offers enhanced CICS support.
COMP is a binary storage format while COMP-3 is packed decimal format.
Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the storage.
Zoned Decimal fields: As a default, sign is over punched with the numeric value stored in the last bite
Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.
Through an IN-LINE PERFORM statement, the routine is being performed to be nested within the perform statement instead of being a separate paragraph.
While the PERFORM and END-PERFORM statements are used to block the COBOL statements between them, in line PERFORM work as long as there are no internal GO TOs, not even to an exit.
Each time the program is called, Local-Storage is allocated, and then it is deallocated when the program stops via an EXIT PROGRAM, GOBACK, or STOP RUN. It is defined in the DATA DIVISION after WORKING-STORAGE SECTION.
Structured programming can be defined as a logical way of programming. In this, the functionalities are divided into modules and help the programmer to write the code logically.
Object-Oriented COBOL is a natural way of programming. In this, programmers identify the objects and then write functions and procedures around that object.
The ACCEPT verb is a basic statement used in COBOL for retrieving data like time, date and day from the user or program. In the educational data, ACCEPT verb and DISPLAY are used to receive information for a student record.