Tags
ALL, AS, CICS, COBOL, COMP, COMP3, DYNAM, ESDS, INDEX, mainframe, MERGE, ORGANIZATION, PERFORM, SEARCH, SORT-RETURN, SUBSCRIPT
——————————————————————————————————————–
TIP # COBOL
If you are accessing ESDS VSAM file, then in COBOL do you know
that SELECT clause has something different about it!!
For ESDS,
SELECT FILE ASSIGN TO AS-DDNAME
Y
es, the DDNAMEs should be prefixed with AS- .
If you are not doing that then an S213 ABEND might occur when
attempting to open data set.
——————————————————————————————————————–
TIP # COBOL
When writing a COBOL program that is to be used as a CICS application program,do not use the
compiler option DYNAM.
——————————————————————————————————————–
TIP # COBOL
MERGE statement can have OUTPUT PROCEDURE but not INPUT PROCEDURE !!
——————————————————————————————————————–
TIP # COBOL
Do you know how COBOL Compiler finds a dataset as VSAM dataset?
When the ORGANIZATION clause is coded for a file, the COBOL compiler interprets it as a
VSAM dataset. Hence, the ORGANIZATION clause should not be coded with a non-VSAM
dataset.
——————————————————————————————————————–
TIP # COBOL
Do you know using an odd number of digits for PACKED DECIMAL (COMP-3) is 5% to 20%
faster than using an even number of digits !!
——————————————————————————————————————–
TIP # COBOL
Performance considerations for indexes vs subscripts:
using COMP to address a table is 30% slower than using indexes!
using COMP-3 to address a table is 300% slower than using indexes !!
using DISPLAY data items to address a table is 450% slower than using indexes !!!
(source: Cobol performance tuning manual)
——————————————————————————————————————–
TIP # COBOL
Rule of the THUMB:
For a table with less than 50 entries ==> go for SEARCH ( Sequential Search)
greater than 50 entries ==> go for SEARCH ALL ( Binary Search)
——————————————————————————————————————–
TIP # COBOL
In CO BO L, why we READ FILE but W RITE RECO RD?
You READ a FI LE becaus e you don’t know in advance:
1.whether ther e actually is a RECORD to read or not
2. For var iable or undefined length files , how long the nex t RECORD will be,
if ther e is one.
You Wr ite a RECORD becaus e you know in advance the answer s to both of
the above ques tions .
——————————————————————————————————————–
TIP # COBOL
Using OPEN OUTPUT to load a VSAM file will significantly improve the performance of your
program. Using OPEN I-O or OPEN EXTEND will have a negative impact on your program’s
performance.
——————————————————————————————————————–
TIP # COBOL
Avoid repetitive uses of the INITIALIZE statement.
INITIALIZE once and move it to a second like sized 01 level, then move the second 01 level to
the first to initialize the fields.
——————————————————————————————————————–
TIP # COBOL
Consider using an in-line PERFORM instead of a SEARCH when you have less than 20
elements in a table.
——————————————————————————————————————–
TIP # COBOL
One can generate a complete listing of compiler diagnostic messages, with their explanations, by
compiling a program with the program-id of ERRMSG specified in the PROGRAM-ID
paragraph.
EX:
IDENTIFICATION DIVISION
PROGRAM-ID.ERRMSG.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
STOP RUN.
——————————————————————————————————————–
TIP # COBOL
For KSDS or RRDS , when DELETE statement is used, the file must be
opened in I-O Mode.
——————————————————————————————————————–
TIP # COBOL
Performance Tuning
Taking constant expressions out of a loop speeds up a program with no ill effects.
Example
Move zero to total.
Perform varying I from 1 by 1 until I > 100
Compute total = total + item (i) * discount
End-perform
Remove multiply from loop
Move zero to total
Perform varying I from 1 by 1 until I > 100
Compute total = total + item (i)
End-perform
Compute total = total * discount
——————————————————————————————————————–
TIP # COBOL
Sometimes my initialization doesn’t work when I use INTIALIZE verb? Is there anything that I should take
care of?
When we use INITIALIZE verb to initialize group verbs, group elements which are FILLERs will
not be initialized!
——————————————————————————————————————–
TIP # COBOL
I am using internal sort in my COBOL Program. Is there anyway to test the return code of sort
operation?
The return-code or completion code is stored in a SORT-RETURN special register.
If SORT-RETURN = 0 (successful completion of SORT/MERGE)
If SORT-RETURN = 16 (Unsuccessful completion of SORT/MERGE)
——————————————————————————————————————–
TIP # COBOL
In general, it is advantage to use COMP for numeric data and COMP-3 for decimal data.
——————————————————————————————————————–
TIP # COBOL
Here is one better way of INITIALIZATION of a record or group item.
INTIALIZE WS-RECORD
REPLACING ALPHANUMERIC DATA BY SPACES
NUMERIC DATA BY ZEROES.
——————————————————————————————————————–
TIP # COBOL
SEARCH ALL condition only test an equal condition.
——————————————————————————————————————–
TIP # COBOL
In COBOL SELECT clause, I see sometimes see ASSIGN coded like this…
SELECT INFILE ASSIGN TO UT-S-INFILE
OR
SELECT INFILE ASSIGN TO DA-S-INFILE
What they mean actually…
First part in DDNAME: – Device Class
UT stands for Utility (Tape or Sequential Disk)
DA stands for Direct-Access (disk)
Second part in DDNAME: – Method of Organization
S – Sequential (Printer, terminal, disk or tape)
I, R, D – Disk files to be accessed randomly
——————————————————————————————————————–
TIP # COBOL
When using INPUT /OUTPUT PROCEDURE with SORT
We RELEASE record-name (for INPUT PROCEDURE) and
We RETURN file-name (for OUTPUT PROCEDURE)
If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog
You may also like to look at: