Global variables are accessible only to the batch program whereas external variables can be referenced from any batch program residing in the same system library.
DB2 pre-compiler (if embedded SQL is used), CICS translator (if CICS program), Cobol compiler, Link editor. If DB2 program, create plan by binding the DBRMs.
Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.
Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the dataset label). You will get file status 39 on an OPEN.
Supply the DD cards just as you would for files referred to in the main program.
Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should never have SIZE (MAX). BUFSIZE can be 2K, efficient enough.
Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or RIGHT.
For binary data items, the address resolution is faster if they are located at word boundaries in the memory. For example, on main frame the memory word size is 4 bytes. This means that each word will start from an address divisible by 4. If my first variable is x(3) and next one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from address 4. You might see some wastage of memory, but the access to this computational field is faster.
It is a special register that has the length of an elementary item or a group.
In COBOL language, NEXT STATEMENT is used to give control to the next verb following the next period. Next Sentence is the collection of sentences that always ends with (.) so the control passes over to the next verb following the next period. When the NEXT SENTENCE is coded, 1 will not be added to input count.
CONTINUE statement is used to give control to the next verb after the explicit scope terminator. When CONTINUE is coded, +1 will be added to input count.
In Cobol Level 66 is used for RENAMES clause and Level 88 is used for condition names.
Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE. If no options provided then it will abend with SOC4 -An Invalid address referenced due to subscript/index error.
These are options for a compiler to find the subscript out of range.
SSRANGE is a compiler option that handles the array overflow. SSRANGE also needs to be specified in COBOL programing language. These help in finding the subscript out of range.
NOSSRANGE is used for performance sensitive applications. NOSSRANGE is a default option that doesn’t support any runtime error if the index or subscript runs out of range.
The ONLY way is to look at the output of the linkage editor (IEWL) or the load module itself. If the module is being called DYNAMICALLY then it will not exist in the main module, if it is being called STATICALLY then it will be seen in the load module. Calling a working storage variable, containing a program name, does not make a DYNAMIC call. This type of call is known as IMPLICITE calling as the name of the module is implied by the contents of the working storage variable. Calling a program name literal.
When writing a structured COBOL program, one must follow a certain format that allows the proper implementation of the code. For instance, when constructing a case, one can use EQUIVALENT statements each time. When nesting, use scope terminators, and when you want the program to do something, try and use IN-LINE PERFORM statements. People also use TEST BEFORE and TEST AFTER statements while coding for do-while loop statements.
Structured programming is the logical way of writing a program where functions are divided into modules and tackled logically.
Object oriented programs are those where you write the methods and functions around the Object that is identified.
COBOL is a structured and a very user friendly programming language. It is one of the oldest programming language and the functionality it provides for big administrative systems cannot be easily replaced.
COBOL is a business-oriented application. It has many characteristics that help businesses to manage and update data. Being a business language, COBOL can handle large data volumes. Programmers can compile, execute and bring together COBOL on many machines together. It can also be used for debugging and testing tools when somebody is looking for solutions. Different versions of COBOL enhance its features manifold.
The following errors are trapped by the ON SIZE ERROR option:
Fixed point overflow
Number zero raised to power zero
Divide by zero
Number zero raised to power negative number
A negative number raised to the power of a fraction.
Structured programming is logical way of programming where the functionalities are divided into modules and helps write the code logically.
Object Oriented Cobol language is a Natural way of programming in which you identify the objects, and then write functions and procedures around that object.
It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last byte, hex 1C if your number is 101, hex 2C if your number is 102, hex 1D if the number is -101, hex 2D if the number is -102 etc...
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.
Yes. Redefines just causes both fields to start at the same location. For example:
01 WS-TOP PIC X(1)
01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).
If you MOVE '12' to WS-TOP-RED,
DISPLAY WS-TOP will show 1 while
DISPLAY WS-TOP-RED will show 12.
Does nothing ! If used, must be the only sentence within a paragraph.
>> INPUT PROCEDURE- It defines the operations where input files are first opened. After opening, records are read, edited and altered. It then goes for sorting operations and finally the files are closed.
[plain]RELEASE recordname FROM inputrecord [/plain]
>> OUTPUT PROCEDURE- It defines the operations where output file is first opened and it receives the sorted record in output record. Then the file is written and finally closed.
ON SIZE ERROR happens in situations when the result of the arithmetic operation is larger than the fixed point field. It also happens when it is divisible by 0. Other situations that result in ON SIZE ERRORS are zero raised to zero, zero raised to some negative number or a negative number raised to a fractional power.
There are two types of linking in COBOL: static linking and dynamic linking.
In static linking, subroutine links into the calling program and doesn’t exist as a separate module.
In the dynamic module, subroutine doesn’t link into the main program and exists as a separate module. DYNAM or NODYNAM link edit options can be used for static and dynamic linking.
S0C1 can be caused due to:
• A misspelled DD name.
• Read/Write to a dataset that is unopened.
• The subprogram called cannot be found.
• Read to the dataset for an opened output.
S0C5 can be caused due to:
• A bad or damaged Subscript/index.
• An incorrect exit from a preform.
• The I/O area is accessed before reading.
• An unopen dataset is closed.
S0C7 can be caused due to:
• A numeric operation is performed in a non-numeric data.
• Working storage is un-initialized.
• Excess coding past the max permitted dub script.
When the body of the perform will not be used in other paragraphs. If the body of the perform is a generic type of code (used from various other places in the program), it would be better to put the code in a separate para and use PERFORM paraname rather than in-line perform.
REPLACING allows for the same copy to be repeated more than once in the same code just by replacing the value.
Yes, COBOL is still worth learning, irrespective of the fact whether the user or programmer wants to maintain them or port them to any other programming languages. With COBOL, it could be done easily. The language is more than 60 years old, but recently, there has been a rise in demand for this due to the requirements of some government agencies. Recently programmers have been using COBOL in state government operations to handle unemployment benefits amid the pandemic.
The modes of opening a file in COBOL are OUTPUT, INPUT, I/O and EXTEND.
What is the extreme size of a mimetic field that can be defined in COBOL?
The maximum size of a numeric field that can be defined in COBOL is PIC 9(18).
REPLACING allows for the same copy to be used more than once in the same code by changing the replace value.
COPY <Name> REPLACING BY
In static linking, called subroutine links into the calling program, while in dynamic linking, the subroutine & the main program will exist as separate modules. Dynamic and Static linking can be achieved by choosing either the DYNAM or NODYNAM link edit option.
Open modes can be used for
<> Input – Output
When you perform a SECTION, all paragraphs under the section will be performed. But if you are performing a paragraph, only the particular paragraph will be performed.
CONTINUE is like a null statement and it continues execution, while NEXT SENTENCE transfers control to the next sentence.
SECTION will have all the paragraphs that are part of the section, to be performed.
PARAGRAPH will have only that paragraph to be performed.
These are the options of compile/link editing:
AMODE: Addressing Mode.
• AMODE(24): It is a 24-bit addressing mode.
• AMODE(31): It is a 31-bit addressing mode.
• AMODE(ANY): Either 24 bit or 31-bit address mode depending upon RMODE.
RMODE: Resident mode.
• RMODE(24): It resides within virtual storage below 16 Meg line.
a. Programs of 31 bit which call 24-bit programs are preferred to use this mode.
b. RMODE(ANY): Either 24 bit or 31-bit address mode depending upon RMODE.
c. OS/VS COBOL program uses 24-bit address only.
• RMODE(ANY): This mode can reside below or above 16 Meg line.
Many times the reason for SOC7 is an un-initialized numeric item.
a. Offending data need to be corrected, focus on examining this.
b. A lot of installations provide a dump for run time abends, and these abends provide the offset which is returned by the last instruction where the abend occurred.
c. Focus on examining the compilation output XREF listing to find the verb and the line number within the source code at this offset.
d. Later investigate the source code for finding the bug.
e. Define certain datasets(SYSABOUT etc) in JCL, for capturing runtime dumps.
f. At times few installations might have batch program debugging tool. Utilize them to resolve the issue.
Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no 'break' is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made.
Performing a SECTION will cause all the paragraphs that are part of the section, to be performed.
Performing a PARAGRAPH will cause only that paragraph to be performed.
It can be either ASCENDING or DESCENDING. ASCENDING is default. 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).
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.
There are 2 searching techniques in COBOL.
Serial search: SEARCH
• It is a process of finding a particular value in a given list.
• The search is implemented by checking each element in the list, one at a time and in sequence.
• This process is continued until the desired element is found.
• SEARCH is used for serial search.
Binary Search: SEARCH ALL
• It is a process of finding a particular element in a sorted list.
• The binary search starts by comparing the middle element of the array.
• The comparison determines the element’s location – either in the first half of the list or in the second half of the list.
• This process continues until the search element is equal to the middle element of the list
• SEARCH ALL is used for binary search.
• The list must be sorted by using the ASCENDING / DESCENDING KEY clause, which loads.
• The default key is ASCENDING KEY.
SEARCH - is a serial search.
SEARCH ALL - is a binary search & the table must be sorted
ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before using SEARCH ALL.
Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET.
Need to have index for a table in order to use SEARCH, SEARCH ALL.
The IS NUMERIC clause is used to check if an item is numeric or not. The value returned will be TRUE if the item that is checked for contains only numbers whether positive or negative.
COBOL is a structured, standard programming language that can be compiled and executed on any machine. It is typically used in business applications as it can handle a large volume of data. It contains numerous debugging and testing capabilities.
The various divisions of a COBOL program are IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION and PROCEDURE DIVISION.
There are three data types in Cobol:
1. Alpha-numeric (X)
2. Alphabetic (A) and
3. Numeric (9)
COBOL is the abbreviation for Common Business Oriented Language. It is among the old programming languages and is primarily used in finance, business and administrative systems and applications.