abend a program

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
vaishalisingh
Member
Posts: 1
Joined: Sun Aug 16, 2009 4:34 pm

abend a program

Post by vaishalisingh » Mon Aug 17, 2009 5:55 pm

In Cobol, suppose i want that if a particular business logic does not fulfills a particular criteria, the program should abend.
how do we code that ?
eg- i have a emp-id which cannot have more then 4 characters, so if any emp-id comes with more then 4 characters the program should immediately abend..

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Mon Aug 17, 2009 11:16 pm

Easy.

Call the common Language Environment routine CEE3ABD:

Code: Select all

       IDENTIFICATION DIVISION.                   
       PROGRAM-ID. ABEND.                         
                                                  
       ENVIRONMENT DIVISION.                      
       INPUT-OUTPUT SECTION.                      
                                                  
       DATA DIVISION.                             
       FILE SECTION.                              
                                                  
       WORKING-STORAGE SECTION.                   
       01  ABCODE PIC S9(9) BINARY.               
       01  TIMING PIC S9(9) BINARY.               
                                                  
       PROCEDURE DIVISION.                        
           MOVE ZEROS TO RETURN-CODE.             
           MOVE 904 TO ABCODE.                    
           MOVE 0 TO TIMING.                      
           CALL 'CEE3ABD' USING ABCODE,TIMING.    
           STOP RUN.                              

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Tue Aug 18, 2009 1:40 pm

MrSpock has given you a correct solution for what you asked. But usually, abend is something one should avoid in practical scenario, you may MOVE some specific value to RC to show that
emp-id cannot have more then 4 characters
instead of casuing an abend.
Regards,
Anuj

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others