Page 1 of 1

abend a program

PostPosted: Mon Aug 24, 2009 1:40 pm
by vaishalisingh
how can we abend a particulare program if it does not satisfies a particular condition ?

Re: abend a program

PostPosted: Mon Aug 24, 2009 5:31 pm
by MrSpock
You can try something like this:
       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.                               

Re: abend a program

PostPosted: Tue Aug 25, 2009 11:26 am
by vaishalisingh
thanks for the reply.. but the condition is we cannot call any routines.. eg.. i have a condition that if the id no of employee is more then 6 then immediately my program should abend.. how can we do this ?

Re: abend a program

PostPosted: Wed Aug 26, 2009 3:48 am
by dick scherrer
Hello,

but the condition is we cannot call any routines.
Nonsense! If whatever passes for management will not allow calling a standard abend routine, then an abend is not needed. The whole purpose of User abends (as opposed to system abends) is to provide something meaningful to the people who must correct the problem. If an id greater than 6 is used to cause a s0c7, it is really pathetic. . .

Suggest you settle for setting a condition code that is treated as a problem by the following jcl and/or the scheduling software.

Re: abend a program

PostPosted: Tue Oct 13, 2009 8:17 pm
by n459760
Dick is correct. A requirement like should not be a cause to abend a routine. Ideally, you must write those error records into an error file with appropriate message for reviewers to review and fix.

However if you still want to abend a program for no reason then just move a return code greater than 8 to RETURN-RC (Do not define this field in COBOL). Your program should abend.

Re: abend a program

PostPosted: Tue Oct 13, 2009 8:21 pm
by MrSpock
How would that:

A. Allow the program to successfully compile and

B. Cause an abend?

Re: abend a program

PostPosted: Wed Oct 14, 2009 6:11 pm
by n459760
MrSpock,
I am not sure if your question is for me but:
A. Yes, the program will successfully compile because its just code. You are not introducing a syntax error in code when you specifically move a value to RETURN-RC.
B. It will cause an abend based on a particular condition reached (please see original post when the length of particular field is less than 6).

Re: abend a program

PostPosted: Wed Oct 14, 2009 11:45 pm
by dick scherrer
Hello,

(please see original post when the length of particular field is less than 6).

I see nothing like this in the original post . . .

I have no idea how A above relates to the question :?

It will cause an abend based on a particular condition reached
What will cause an abend?

Most confusing. . .

Please re-read the original request and explain how any return-code can cause an abend (Hint - it will/can NOT). . . Abends are Sxxx (Syatem) or Unnnn (User). A return-code is never an abend. . . It may signify a problem, but it is not an abend.

Re: abend a program

PostPosted: Thu Oct 15, 2009 2:55 am
by n459760
Dick,
I did a mistake of re-wording it. See the message from vaishalisingh " thanks for the reply.. but the condition is we cannot call any routines.. eg.. i have a condition that if the id no of employee is more then 6 then immediately my program should abend.. how can we do this ?"

Yes, I understand there are system and user abends but what I am giving an example of what I meant so that there it does not appear to be confusing:

IF LENGTH OF EMP_ID > 6
MOVE 12 TO RETURN-CODE
SET ERROR-SW TO TRUE
END-IF

While processing further if an error report needs to be written for this INVALID ID then the programmar should code accordingly.

What is being translated/interpreted as an abend by the original poster as well as my second reply above relates more to coding that the programmar is trying to accomplish.

Re: abend a program

PostPosted: Thu Oct 15, 2009 3:21 am
by dick scherrer
Hello,

We need a better answer from vaishalisingh . . .

The original post says an abend is needed. Setting a return-code is not an abend. It might indicate something fatal has happened, but it is not an abend. . .