|
The Buckalew Group
|
|
| |
|
|
P M Buckalew
The 77 level is an elementary level item. It cannot be subdivided into other items (cannot be qualified), nor can they be subdivided themselves.
An 88 level is used for condition names.
A 66 level is used for RENAMES clause.
The IS NUMERIC clause is used in conjunction with alphanumeric item, signed numeric & packed decimal items and unsigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However, if the item being tested is a signed item, then it may contain 0-9, + and - .
An ARRAY is defined in COBOL as follows:
An OCCURS clause CANNOT be at the 01 level.
Indexes and Subscripts
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. An index for a table is required in order to use SEARCH or SEARCH ALL clause.
The difference between SEARCH and SEARCH ALL is that a SEARCH is a serial search where a SEARCH ALL is a binary search. The table must be sorted (ASCENDING/DESCENDING using the KEY clause along with the data) before using SEARCH ALL.
When using SEARCH ALL, it can be either ASCENDING or DESCENDING. ASCENDING is the default. If you want the search to be done on an array sorted in descending order, you should use the DESCENDING KEY clause when defining the array. (You must load the table in the specified order).
A BINARY Search is a search on a sorted array. Compare the item to be searched with the item at the center. If it matches, fine else the process is repeated using the top half or bottom half depending on where the item lies.
Debugging Subscript Errors
To prevent a subscript value that is outside of the array range, you must use compiler option SSRANGE if you want array bounds checking. Typically, the default is NOSSRANGE.
To sort within a COBOL program, you much provide the sort file definition (SD), the sort statement syntax and meaning.
Syntax:
SECTIONs and PARAGRAPHs
Examples of EVALUATE statement is as follows:
After the execution of one of the WHEN clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need of any extra code. In an EVALUATE statement, you can give complex conditions on a when clause.
Scope terminators are used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF. A scope terminator can also be a PERIOD.
In-line PERFORMs are recommended if 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 paragraph rather than in-line perform.
The difference between CONTINUE and NEXT SENTENCE is that the CONTINUE clause is like a null statement (do nothing) , while NEXT SENTENCE transfers control to the next sentence (terminated by a period).
If there is an EXIT clause in a paragraph, it should be the only statement there!!
REDEFINES
You can REDEFINE to a data area that is larger. For example:
If you REDEFINE to a data area that is smaller. There is a risk of encountering an S0C7 abend. To resolve an SOC-7 error, Basically you need to correct the offending data. Many times the reason for SOC7 is an un-initialized numeric item (i.e. spaces). Examine that possibility first.
Many installations provide you a dump for run time abends (it can be generated also by calling some subroutines or OS services thru assembly language). These dumps provide the offset of the last instruction at which the abend occurred. Examine the compilation output XREF listing to get the verb and the line number of the source code at this offset. Then you can look at the source code to find the bug. To get capture the runtime dumps, you will have to define some datasets (SYSABOUT, etc) in the JCL.
If none of these are helpful, use judgment and DISPLAY to localize the source of error. Some installation might have batch program debugging tools. Use them.
PACKED and ZONED DECIMAL fields...
A PACKED DECIMAL field is where the sign is stored as a hex value in the last nibble (4 bits) of the storage. COMP-3 fields are PACKED DECIMAL
ZONED DECIMAL fields, as a default, have its sign as an over punch with the numeric value stored in the last bite. 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...
In a COMP field, the value is in the most significant bit. Bit is on if -, off if +. The difference between COMP & COMP-3 is that COMP is a binary storage format while COMP-3 is packed decimal format.
Remember that when you define a variable of COMP-1 or COMP-2, no picture clause is given.
In a COMP-3 fiend, remember that the field is compressed. Two digits occupy the same byte. If there is an odd number of digits, there will be an extra byte used. For example, in a S9(7) COMP-3 field, it will take 4 bytes. Sign is stored as hex value in the last nibble.
General formula is INT((n/2) + 1)), where n=7 in this example.
When using SIGN TRAILING SEPARATE clause and there is an odd number of digits, (i.e. S9(7))
will occupy 8 bytes (one extra byte for sign).
If you have an S9(8) COMP field defined, it will occupy 4 bytes.
COMP SYNC 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.
ORGANIZATION IS...:
There are FOUR different file OPEN modes available in COBOL
Open for INPUT, OUTPUT, I-O, EXTEND.
If you plan to OPEN a file for writing only, use either OUTPUT or EXTEND
STATIC vs. DYNAMIC Linking
In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine and the main program will exist as separate load modules. You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call. A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.
Within the MVS/ESA Enterprise Server architecture, there are different addressing and residency modes that are set as compile/link edit options.
programs.
To submit a job from a COBOL program, write JCL statements to an output dataset as follows ...
Differences between OS VS COBOL and VS COBOL II
The steps to go through to make a COBOL program executable is as follows:
You can call an OS VS COBOL programs from a VS COBOL II program, but only within a batch process. In a CICS environment, this is not possible.
|
Send mail to
webmaster@pbtechgroup.com with
questions or comments about this web site.
|