Shortest COBOL program (Again!)
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Mainframe Challenge

#1: Shortest COBOL program (Again!) Author: Cogito-Ergo-SumLocation: Bengaluru, INDIA PostPosted: Tue Nov 02, 2004 10:42 am
    —
Hi all,
Can anyone tell me what is so special about this COBOL program without actually compiling it? Yes. Only compilation.

Code:

IDENTIFICATION DIVISION.
PROGRAM-ID. ERRMSG.     
    STOP RUN .         


Will it compile successfully?
If not, what will be compilation messages?

8)

#2:  Author: kolusuLocation: San Jose PostPosted: Tue Nov 02, 2004 10:51 am
    —
Cogito,

If I remember correctly ERRMSG is used to generate the compiler listing with explanations. is that Right?

It will compile successfully.

Kolusu

#3:  Author: Cogito-Ergo-SumLocation: Bengaluru, INDIA PostPosted: Tue Nov 02, 2004 12:01 pm
    —
100% !

It compiles successfully. And, yes, it generates a list of various compiler messages.

Kolusu, you are great!

#4:  Author: mokLocation: paris PostPosted: Tue Nov 09, 2004 1:19 pm
    —
Hi,
ERRMSG exists since Cobol II ! Furthermore, you can do it shorter : the STOP RUN statement is not mandatory.
Cheers

#5:  Author: KathiLocation: Mission Viejo, California PostPosted: Tue Dec 28, 2004 1:52 am
    —
I think some people have too much time on their hands! Laughing

#6:  Author: ranga_subham PostPosted: Sun Feb 25, 2007 3:12 am
    —
Hi, mok.

Quote:

ERRMSG exists since Cobol II ! Furthermore, you can do it shorter : the STOP RUN statement is not mandatory.


Would you please explain in detail?

TIA.

#7:  Author: kolusuLocation: San Jose PostPosted: Sun Feb 25, 2007 10:42 am
    —
ranga_subham,

If control reaches the end of the Procedure Division of a method, and there is no next executable statement, an implicit EXIT METHOD statement is executed. ie the control is returned to the system. So if you don't have an explicit STOP RUN statement and the control reaches the end, then the program automatically execuetes the implicit exit method and return the control which is what mok is saying.


Kolusu

#8:  Author: peagletLocation: Chicago PostPosted: Mon Jun 11, 2007 4:58 pm
    —
If you're still using STOP RUN you need to move up to the newest compiler. GOBACK is now the standard

#9:  Author: balaji.p.ramanLocation: India PostPosted: Thu Sep 02, 2010 7:17 am
    —
Well, I hope you guys would be shooting me for posting this! Very Happy

The shortest COBOL program I have managed to write was this

"PROGRAM-ID. SHORT." bonk

Compiler used: Fujitsu NetCOBOL for Windows!

No kidding!

Reason:
A file input is treated to be a COBOL input file ONLY when it is identified with an IDENTIFICATION DIVISION. However, if one forgets just that small bit and a COBOL verb PROGRAM-ID follows, this compiler works around and recognizes the file as a valid COBOL file.

Can someone confirm if IBM compilers exhibit this behavior?

#10:  Author: Anuj DhawanLocation: Mumbai,India PostPosted: Thu Sep 02, 2010 8:08 am
    —
No that will not work on zOS. For IBM Enterprise COBOL for z/OS 3.4.1 you get this error
Code:
IGYDS1000-E   A "IDENTIFICATION DIVISION" header was not found in this program.  It was assumed present.
and program does not compile successfully.



MVSFORUMS.com -> Mainframe Challenge


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group