Page 1 of 1

The COBOL standards?

Posted: Tue Apr 04, 2017 2:57 pm
by Kishor Sonawane
Hi,

Are there some COBOL standards for coding? What are they,is there some good guidance on them? Please let me know.

Re: The COBOL standards?

Posted: Tue Apr 04, 2017 3:46 pm
by nicc
Use the same standards as you would for any other programming language remembering that your in-house standards, no matter what they are, override all others.

Re: The COBOL standards?

Posted: Tue Apr 04, 2017 5:29 pm
by Anuj Dhawan
There are many rules - some might be very general in nature a programmer should always follow as suggested by Nic and there are others which are more popular with in your company. (Popular is not always right though.) Some of the rules which comes to mind are listed below, in no-chronological order though:
  1. IDENTIFICATION DIVISION of any COBOL program must contain at least the program name. But it can have some of the follosing to make it more meaningful:
    1. AUTHOR - we will know who to blame when things go wrong! Yeah!? :D
    2. DATE-WRITTEN - this gives us the age of the original version. And you can boast in the glory to disrupt a program written before you were born.
    3. DATE-COMPILED - this is automatically inserted by the COBOL compiler, and shows the age of the current version of this program.
    4. Program function - It should tell about the purpose of the program and/or if it is a stand-alone program, or part of a suite of programs? When is it run?
    5. Database access - what databases are used, and in what modes?
    6. Amendment history - each time a program is changed you should insert a note giving the amendment date, a brief description of the amendment, plus your name.
    7. INPUT FILES. List the internal name for each file used as input, followed by its disk file name and the sort sequence (if any) of the file.
    8. OUTPUT FILES. List the internal name for each file used for output, followed by its disk file name and the sort sequence (if any) of the file.
  2. Have a good record structure and PICTURE clauses must be vertically aligned in the program: For example, this (reference taken from A J Marston document)

    Code: Select all

    01  RECORD-NAME.
    05      DATA-NAME-1-ALPHA                 PIC X(2).
    05      DATA-NAME-2.
    10          DATA-NAME-3-NUMERIC           PIC 99.
    10          DATA-NAME-4.
    15              DATA-NAME-5-ALPHA         PIC X(2).
    15              DATA-NAME-6-NUMERIC       PIC 9(5).
    05      DATA-NAME-7-ALPHA                 PIC X(6).
    
    is much better than this structure:

    Code: Select all

    01 RECORD-NAME.
    02 DATA-NAME-1-ALPHA PIC X(2).
    02 DATA-NAME-2.
    03 DATA-NAME-3-NUMERIC PIC 99.
    03 DATA-NAME-4.
    04 DATA-NAME-5-ALPHA PIC X(2).
    04 DATA-NAME-6-NUMERIC PIC 9(5).
    02 DATA-NAME-7-ALPHA PIC X(6).
    
  3. Use meaningful paragraph and section names.
There can be many more rules however, these should help you to get started.

Re: The COBOL standards?

Posted: Wed Apr 05, 2017 2:15 am
by William Collins
Not a very useful document. Written in 1984, updated last in 1993. Odd things in it.

Re: The COBOL standards?

Posted: Wed Apr 05, 2017 7:46 am
by Anuj Dhawan
William Collins wrote: Not a very useful document. Written in 1984, updated last in 1993. Odd things in it.
Agree, that's why I did not link it to directly, though still wanted to give some food for thought to the topic author to get started...

Re: The COBOL standards?

Posted: Thu Feb 01, 2018 10:24 am
by Kishor Sonawane
Thanks Anuj and William for the guidance. Have been struggling it personal life, could not log in to Forums often.

Re: The COBOL standards?

Posted: Thu Feb 01, 2018 3:05 pm
by Anuj Dhawan
Go easy - life has different plan at times.