TIP # 038
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 # 039
COBOL
When writing a COBOL program that is to be used as a CICS application program,do not use the
compiler option DYNAM.
TIP # 040
COBOL
MERGE statement can have OUTPUT PROCEDURE but not INPUT PROCEDURE !!
TIP # 041
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 # 042
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 # 043
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 # 044
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 # 045
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 # 046
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 # 047
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 # 048
COBOL
Consider using an in-line PERFORM instead of a SEARCH when you have less than 20
elements in a table.
TIP # 049
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 # 050
COBOL
For KSDS or RRDS , when DELETE statement is used, the file must be
opened in I-O Mode.
TIP # 051
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 # 052
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 # 053
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 # 054
COBOL
In general, it is advantage to use COMP for numeric data and COMP-3 for decimal data.
TIP # 055
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 # 056
COBOL
SEARCH ALL condition only test an equal condition.
TIP # 057
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 # 058
COBOL
When using INPUT /OUTPUT PROCEDURE with SORT
We RELEASE record-name (for INPUT PROCEDURE) and
We RETURN file-name (for OUTPUT PROCEDURE)
Sunday, June 10, 2007
Subscribe to:
Post Comments (Atom)
4 comments:
Good Tips
great work! please continue...
http://mainframetips-n-tricks.blogspot.com/
Post a Comment