MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Shortest COBOL program that will ABEND
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Mainframe Challenge
View previous topic :: View next topic  
Author Message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Oct 04, 2004 1:23 pm    Post subject: Shortest COBOL program that will ABEND Reply with quote

What is the shortest batch COBOL code which will ABEND?

Ground rules: Basically none. In other words,

Meaning of SHORTEST : Up to you.
Release/Level/Flavor of COBOL : Up to you.
ABEND type (User/Sxxx/others) : Up to you.

BTW, this is not my creation. Got it from WWW.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 11794
Topics: 74
Location: San Jose

PostPosted: Mon Oct 04, 2004 1:32 pm    Post subject: Reply with quote

Cogito,

On the first look , I could manage with 7 lines. I assumed that compile errors do not count in here.

Version used: IBM Enterprise COBOL for z/OS and OS/390 3.2.0


Code:

IDENTIFICATION DIVISION.             
PROGRAM-ID. ABND                     
DATA DIVISION.                       
WORKING-STORAGE SECTION.             
01 W-VAR      PIC S9(05) COMP-3.     
PROCEDURE DIVISION.                   
                                     
    COMPUTE W-VAR  = (W-VAR / ZERO ).
                                     


Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Oct 04, 2004 1:36 pm    Post subject: Reply with quote

It can be shorter than that, Kolusu. 8)

(I want a program that compiles successfully; MAXCC <= 4; but, ABENDs while executing).
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 11794
Topics: 74
Location: San Jose

PostPosted: Mon Oct 04, 2004 1:58 pm    Post subject: Reply with quote

cogito,

How about this one? just 4 lines.

Code:

IDENTIFICATION DIVISION.     
PROGRAM-ID. ABND             
PROCEDURE DIVISION.         
                             
    ADD +1 TO RETURN-CODE.   
                             


Abend : IGZ0037S The flow of control in program ABND proceeded beyond the last line of the program.

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Oct 04, 2004 2:04 pm    Post subject: Reply with quote

Why bother with the RETURN-CODE part? Leave it off. And, the ID DIVISION is the only required DIVISION in COBOL is IDENTIFICATION DIVISION. So, the shortest code becomes:

Code:

IDENTIFICATION DIVISION.
PROGRAM-ID. SHORTCOB.   


Nevertheless, you win this hands down! Smile
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 11794
Topics: 74
Location: San Jose

PostPosted: Mon Oct 04, 2004 2:08 pm    Post subject: Reply with quote

Cogito,

I ran your code and I got a return-code of ZERO. Hmm wasn't it supposed to abend?

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Oct 04, 2004 2:12 pm    Post subject: Reply with quote

Strange. Rolling Eyes

I get IGZ0037S message. Just tested again.

Don't you get IGZ0037S when you code only PROCEDURE DIVISION ?
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 11794
Topics: 74
Location: San Jose

PostPosted: Mon Oct 04, 2004 2:23 pm    Post subject: Reply with quote

Cogito,

I get an IGZ0037S abend when I added the procedure division.

Code:

IDENTIFICATION DIVISION.   
PROGRAM-ID. SHORTCOB.       
PROCEDURE DIVISION.         


Your earlier post just the ID division and Program ID code. When I ran with the 2 lines the return code is 0 . When I added the procedure division , it abended with IGZ0037S. So the shortest code is 3 lines. Now let us see if some one can beat that.

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Oct 04, 2004 2:26 pm    Post subject: Reply with quote

Kolusu,
Could it be because, I run my COBOL programs under LE?

Actually, I was under the impression that, indeed, three lines is least possible number of COBOL code. But, just out of curiosity, I removed the PROCEDURE DIVISION too. I still got the IGZ0037S message.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Mon Oct 04, 2004 2:30 pm    Post subject: Reply with quote

Hi,

Will the program not abend if there is no GOBACK statement.

I ran this code and it abended with S0C4.

IDENTIFICATION DIVISION.
PROGRAM-ID. ABND
PROCEDURE DIVISION.
display '123'.

Worked fine with the GOBACK statement.
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Oct 04, 2004 2:34 pm    Post subject: Reply with quote

programmer1,
Perhaps for the first time in this board, the request is to provide the code that will ABEND. Laughing However, the challenge is to do so in least possible lines of code.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 11794
Topics: 74
Location: San Jose

PostPosted: Mon Oct 04, 2004 2:36 pm    Post subject: Reply with quote

Cogito,
This is the JCL I ran. I got a return code of zero.

Code:

//STEP0100 EXEC PGM=IGYCRCTL                       
//STEPLIB  DD DSN=SYS1.SIGYCOMP,                   
//            DISP=SHR                             
//SYSPRINT DD SYSOUT=*                             
//SYSTERM  DD SYSOUT=*                             
//SYSUT1   DD UNIT=DISK,SPACE=(CYL,(10,2),RLSE)   
//SYSUT2   DD UNIT=DISK,SPACE=(CYL,(10,2),RLSE)   
//SYSUT3   DD UNIT=DISK,SPACE=(CYL,(10,2),RLSE)   
//SYSUT4   DD UNIT=DISK,SPACE=(CYL,(10,2),RLSE)   
//SYSUT5   DD UNIT=DISK,SPACE=(CYL,(10,2),RLSE)   
//SYSUT6   DD UNIT=DISK,SPACE=(CYL,(10,2),RLSE)   
//SYSUT7   DD UNIT=DISK,SPACE=(CYL,(10,2),RLSE)   
//SYSLIN   DD DSN=&&LOADSET,                       
//            DISP=(MOD,PASS),                     
//            UNIT=DISK,                           
//            SPACE=(CYL,(1,1),RLSE)               
//SYSIN    DD *                                   
        IDENTIFICATION DIVISION.                   
        PROGRAM-ID. SHORTCOB.                     
                                                   
/*                                                 
//STEP0200 EXEC PGM=LOADER,                       
//             PARM=('LIST,LET,XREF,DCBS,'),       
//             COND=(5,LT,STEP0100)               
//SYSLIB   DD DSN=SYS1.SCEELKED,                   
//            DISP=SHR                             
//SYSLIN   DD DSN=*.STEP0100.SYSLIN,               
//            DISP=(OLD,DELETE)                   
//SYSOUT   DD SYSOUT=*                             
//SYSPRINT DD SYSOUT=*                             
/*                                                 


When I added the procedure division the Job abended with IGZ0037S.The following is the message

Code:

IGZ0037S The flow of control in program SHORTCOB proceeded beyond the last line of the program.

From compile unit SHORTCOB at entry point SHORTCOB at compile unit offset +000002A6 at entry offset +000002A6 at address 176212A6.

<> LEAID ENTERED (LEVEL 07/09/2002 AT 11.37)                 
<> LEAID ABENDAID DD ALLOCATED BY #XAMAKDD DYNALLOC RC =00000
<> LEAID PROCESSING COMPLETE.                                 


What is your version of COBOL?

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Mon Oct 04, 2004 2:38 pm    Post subject: Reply with quote

Cogito-Ergo-Sum,

I understand that. Smile I got confused when Kolusu tried to abend the code with the computation
Quote:

COMPUTE W-VAR = (W-VAR / ZERO ).


Whereas the code could have abended because there was no GOBACK statement.
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Oct 05, 2004 2:50 am    Post subject: Reply with quote

Kolusu,
I am at VS COBOL II. However, I am compiling and linking with proper LE modules.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Fri Oct 08, 2004 4:48 pm    Post subject: Reply with quote

I also got an abend when I tried running the COBOL program with only the id division and the program id.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Mainframe Challenge All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group