Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 3: COBOL Program structure


Coding Sheet

  • COBOL source program must be written in a format acceptable to the COBOL compilers. Thus COBOL programs are always written on COBOL Coding Sheet.
  • The Coding Sheet has 80 character positions and these positions are grouped into the five fields

    Figure: - Illustration of COBOL Coding Sheet
  • Margin A and Margin B actually contains the COBOL code.
  • Sometimes Margin A and Margin B are also referred to as Area A & Area B
  • Explanation of each of fields given as follows:-
    Positions Field Explanation
    1-6
    Sequence Field
    • Sequence Field is optional to specify
    • It is usually used to give sequence number to the lines of code.
    • This sequence number is formed by specifying page number on positions 1-3 and line number on positions 4-6
    7
    Indicator Field
    • Indicator Field is optional to specify
    • Coded asterisk(*) to indicate that the whole line is comment line
    • Coded hyphen (-) to indicate that the current line I continuation of previous line
    • Coded character D (single char D) to indicate that the current line is Debugging line. When DEBUGGING MODE is enabled in the program, these debugging lines are made part of program for debugging purpose. When DEBUGGIN MODE is not enabled, these lines will be considered as dummy lines (more information about DEBUGGING MODE and use of debugging line is provided in CONFIGURATION SECTION)
    • Coded slash (/) to indicate new page in the listing. i.e. The lines are printed after skipping to the top of the next page
    • When left blank it will be considered as normal coding line
    8-11
    Margin A
    • All Divisions, Sections, Paragraphs and some special entry declarations like ‘01’ and ‘77’ must start here
    12-72
    Margin B
    • All Statements, Sentences and other entry declaration should be coded here
    73-80
    Identification Field
    • As name suggests, it is used for identification purpose.
    • COBOL programmers use this field as TAG field to identify their changes.
    • COBOL compiler ignores this field of Coding Sheet

Example Program:-

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. MFPROG1. 000300 ENVIRONMENT DIVISION. 000400 CONFIGURATION SECTION. 000500 SOURCE-COMPUTER. IBM-3090 WITH DEBUGGING MODE. 000600 PROCEDURE DIVISION. 000700 MAIN-PARA. 000800 DISPLAY 'COBOL PROGRAMMING LANGUAGE' 000900D DISPLAY 'DEBUGGING MODE ACTIVATED' 001000* THIS IS LINE IS COMMENTED AS IT CONTAINS '*' ON POSITION 7 001100 DISPLAY 'LINE CONTIN' 001200- 'UATION' 001300 STOP RUN.

Output:-

************************ TOP OF DATA *********************** COBOL PROGRAMMING LANGUAGE DEBUGGING MODE ACTIVATED LINE CONTINUATION ********************** BOTTOM OF DATA **********************

Explanation:-
In above example, we can see, first 6 positions are used as sequence field. Actual coding is done in position 8-72. Asterisk at 7th position on line number ‘010000’ is used to comment the line. Character ‘D’ at 7th position on line number ‘000900’ is used for debugging purpose, debugging clause will be explained in more detail in later Module. Character ‘-‘ at 7th position on line ‘001200’ is used to indicate the continuation from previous line.






© copyright mainframebug.com
Privacy Policy