IBM Mainframe Tutorials - COBOL Cheat Sheet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

11/28/21, 1:50 AM IBM Mainframe Tutorials: COBOL cheat sheet

More

IBM Mainframe Tutorials


This blog is created to help people understand different concepts of IBM
mainframes and it will be updated on a regular basis with the new topics and also
adding more details to the existing ones.

Sunday, 26 August 2018 Categories

CICS
(2)
COBOL cheat sheet COBOL
(12)
DB2
(11)
JCL
(11)
1. ENVIRONMENT DIVISION is optional. Mainframe Tips & Tricks
(6)
2. DATA DIVISION is optional. MQ Series
(1)
3. In IDENTIFICATION DIVISION, except PROGRAM-ID. everything else is optional. MVS
(1)

4. From Column 8-11, we call AREA-A where we should code DIVISIONS, SECTIONS, SDSF
(1)
PARAGRAPHS and 01 group level items. VSAM
(3)

5. From column 12-72, we call AREA-B where we will code rest of the Cobol


statements other than DIVISIONS, SECTIONS, PARAGRAPHS and 01 group level Blog Archive Total Pageviews
items.
► 
2020
(1)
► 

6. If you specify SELECT OPTIONAL file ASSIGN TO filename, and if filename is not


► 
2019
(7)
► 

present physically then the program will NOT abend. Files with OPTIONAL can be
▼ 
2018
(2)
▼ 

opened with EXTEND, I/O or INPUT mode so that the file will be created else it
▼ 
August
(2)
▼ 

return status code 35.


DB2 LOAD
7. FILE STATUS is used to identify the status of each operation performed against error :
the file. FILE STATUS IS ws-status, where ws-status can be declared in working INPUT
storage section with length of 2 bytes.   FIELD
'field-name'
8. SELECT empfile ASSIGN TO empfileo where empfile is a logical file and empfileo is NOT ENT...
physical file. Inside the cobol program, for any operation on this file we have to COBOL cheat
use logical file name which is empfile and later all these operations will be sheet
reflected in physical file empfileo.
9. If you are passing data from JCL to cobol program using PARM parameter, please ► 
2017
(4)
► 

declare two variables in linkage section viz., one is to store length of the data and ► 
2016
(1)
► 

the other one for actual data. ► 


2015
(36)
► 

10. Main program will have 'PROCEDURE DIVISION' where as sub-program or called
program will have 'PROCEDURE DIVISION using [data-items]...' 
11. USAGE clause reduce the storage space indirectly increasing the efficiency of the
program. The default usage is DISPLAY and its not applicable for 66,77 and 88
level items. 
12. COMP-1 => Left most 8 bits for exponent and remaining 24 bits for mantissa.
COMP-2 => Left most 12 bits for exponent and 52 bits for mantissa. Both of the
items store data in the format of Mantissa and exponent.
13. Comp-3 => also called as packed decimal form where the data will be stored in
memory as BCD (Binary Coded Decimal) format. Two digits can be stored in each
byte and the number of bytes required for a variable is calculated using formula
(n+1)/2. The low nybble of the least significant byte contains a sign. So even
though we didn't define sign variable for COMP-3, a nibble is reserved for it. 

    Examples: 

    PIC S9(7) COMP-3.     Byte size = (7 + 1) / 2 = 4

    PIC S9(5)V99 COMP-3.  Byte size = (5 + 2 + 1) / 2 = 4

    PIC S9(6) COMP-3.     Byte size = (6 + 1) / 2 = 3.5, rounded to 4


Comp-3 fields reserve a nybble for the sign, even for "unsigned" values, so the following
fields are still 4 bytes:
    PIC 9(7) COMP-3.     Byte size = (7 + 1) / 2 = 4
    PIC 9(6) COMP-3.     Byte size = (6 + 1) / 2 = 3.5, rounded to 4

14. START command is used in DYNAMIC mode to read the KSDS file. It will set the
pointer to the next read for reading the record.

ibmmainframetutorials.blogspot.com/2018/08/cobol-cheat-sheet.html 1/2
11/28/21, 1:50 AM IBM Mainframe Tutorials: COBOL cheat sheet
     START file-name KEY <relational-operator> <data-name>

             [INVALID KEY statements]

             [NOT INVALID KEY statements]

     END-EVALUATE.

     First key-value will be moved to data name and once START commands executes,
the pointer will be placed at the starting of matched record.

15. READ NEXT is used to read the records sequentially after the record to which
pointer was set by the START command based on key value.

    

Posted by
Azhar
at
21:24

Labels:
COBOL

No comments:

Post a Comment

Enter your comment...

Comment as:
sundar.emailbo Sign out

Publish Preview
Notify me

Newer Post Home Older Post

Subscribe to:
Post Comments (Atom)

Simple theme. Theme images by gaffera. Powered by Blogger.

ibmmainframetutorials.blogspot.com/2018/08/cobol-cheat-sheet.html 2/2

You might also like