Shortest COBOL program that will ABEND
Select messages from
# through # FAQ
[/[Print]\]
Goto page 1, 2  Next  :| |:
MVSFORUMS.com -> Mainframe Challenge

#1: Shortest COBOL program that will ABEND Author: Cogito-Ergo-SumLocation: Bengaluru, INDIA PostPosted: Mon Oct 04, 2004 1:23 pm
    —
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.

#2:  Author: kolusuLocation: San Jose PostPosted: Mon Oct 04, 2004 1:32 pm
    —
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

#3:  Author: Cogito-Ergo-SumLocation: Bengaluru, INDIA PostPosted: Mon Oct 04, 2004 1:36 pm
    —
It can be shorter than that, Kolusu. 8)

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

#4:  Author: kolusuLocation: San Jose PostPosted: Mon Oct 04, 2004 1:58 pm
    —
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

#5:  Author: Cogito-Ergo-SumLocation: Bengaluru, INDIA PostPosted: Mon Oct 04, 2004 2:04 pm
    —
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

#6:  Author: kolusuLocation: San Jose PostPosted: Mon Oct 04, 2004 2:08 pm
    —
Cogito,

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

Kolusu

#7:  Author: Cogito-Ergo-SumLocation: Bengaluru, INDIA PostPosted: Mon Oct 04, 2004 2:12 pm
    —
Strange. Rolling Eyes

I get IGZ0037S message. Just tested again.

Don't you get IGZ0037S when you code only PROCEDURE DIVISION ?

#8:  Author: kolusuLocation: San Jose PostPosted: Mon Oct 04, 2004 2:23 pm
    —
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

#9:  Author: Cogito-Ergo-SumLocation: Bengaluru, INDIA PostPosted: Mon Oct 04, 2004 2:26 pm
    —
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.

#10:  Author: programmer1 PostPosted: Mon Oct 04, 2004 2:30 pm
    —
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.

#11:  Author: Cogito-Ergo-SumLocation: Bengaluru, INDIA PostPosted: Mon Oct 04, 2004 2:34 pm
    —
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.

#12:  Author: kolusuLocation: San Jose PostPosted: Mon Oct 04, 2004 2:36 pm
    —
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

#13:  Author: programmer1 PostPosted: Mon Oct 04, 2004 2:38 pm
    —
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.

#14:  Author: Cogito-Ergo-SumLocation: Bengaluru, INDIA PostPosted: Tue Oct 05, 2004 2:50 am
    —
Kolusu,
I am at VS COBOL II. However, I am compiling and linking with proper LE modules.

#15:  Author: Manas BiswalLocation: Chennai, India PostPosted: Fri Oct 08, 2004 4:48 pm
    —
I also got an abend when I tried running the COBOL program with only the id division and the program id.

Regards,
Manas



MVSFORUMS.com -> Mainframe Challenge


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

Goto page 1, 2  Next  :| |:
Page 1 of 2

Powered by phpBB © 2001, 2005 phpBB Group