The COBOL standards?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Kishor Sonawane
Registered Member
Posts: 24
Joined: Thu Nov 21, 2013 3:25 pm

The COBOL standards?

Post 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.
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: The COBOL standards?

Post 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.
Regards
Nic
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: The COBOL standards?

Post 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.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: The COBOL standards?

Post by William Collins »

Not a very useful document. Written in 1984, updated last in 1993. Odd things in it.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: The COBOL standards?

Post 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...
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Kishor Sonawane
Registered Member
Posts: 24
Joined: Thu Nov 21, 2013 3:25 pm

Re: The COBOL standards?

Post by Kishor Sonawane »

Thanks Anuj and William for the guidance. Have been struggling it personal life, could not log in to Forums often.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: The COBOL standards?

Post by Anuj Dhawan »

Go easy - life has different plan at times.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

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