The COBOL standards?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.

Topic author
Kishor Sonawane
Registered Member
Posts: 17
Joined: Thu Nov 21, 2013 3:25 pm
Has thanked: 1 time

The COBOL standards?

Postby Kishor Sonawane » Tue Apr 04, 2017 2:57 pm

Hi,

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




nicc
Global Moderator
Global Moderator
Posts: 544
Joined: Wed Apr 23, 2014 8:45 pm
Been thanked: 11 times

Re: The COBOL standards?

Postby nicc » Tue Apr 04, 2017 3:46 pm

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.


Regards
Nic

User avatar

Anuj Dhawan
Founder
Posts: 2392
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Has thanked: 152 times
Been thanked: 66 times

Re: The COBOL standards?

Postby Anuj Dhawan » Tue Apr 04, 2017 5:29 pm

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.


Thanks,
Anuj


William Collins
Global Moderator
Global Moderator
Posts: 499
Joined: Sun Aug 25, 2013 7:24 pm
Has thanked: 1 time
Been thanked: 25 times

Re: The COBOL standards?

Postby William Collins » Wed Apr 05, 2017 2:15 am

Not a very useful document. Written in 1984, updated last in 1993. Odd things in it.



User avatar

Anuj Dhawan
Founder
Posts: 2392
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Has thanked: 152 times
Been thanked: 66 times

Re: The COBOL standards?

Postby Anuj Dhawan » Wed Apr 05, 2017 7:46 am

William Collins wrote:Source of the post 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...


Thanks,
Anuj


Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 2 guests