Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to abend job intentionally

Is it possible to abend your job intentionally through COBOL program. suppose I have an Input file having Header,Detail and Trailer records. I will write a COBOL pgm which reads this file.If no Detail records are found in this file then I want to abend my job by giving some Abend Message and some Abend Code.Is it Possible?

like image 897
Manasi Avatar asked Jul 02 '10 06:07

Manasi


People also ask

How do you bypass a step in JCL?

A COND parameter can be coded in the JOB or EXEC statement of JCL. It is a test on the return code of the preceding job steps. If the test is evaluated to be true, the current job step execution is bypassed. Bypassing is just omission of the job step and not an abnormal termination.


1 Answers

Do you want to ABEND your program or just set a RETURN-CODE?

I suspect setting a RETURN-CODE, writing a message and then terminating the program via a STOP RUN or GOBACK is all that you really want to do. Causing an actual ABEND may not be necessary.

In an IBM batch environment, the RETURN-CODE set by your program becomes the RC for the JCL job step the program was run under. This is typically what you want to set and test for.

The RETURN-CODE is set by MOVEing a numeric value to it. For example:

         DISPLAY 'No Detail Records found in file.'
         MOVE 16 TO RETURN-CODE
         GOBACK.
            

You may also issue a program dump from a program run under Language Environment (IBM Mainframe option) using the CEE3DMP--Generate dump utility.

In older IBM Mainframe COBOL programs, you might see calls to the ILBOABN0 routine. This call abended your program and issued a dump. This routine is now depreciated in favour of the technique outlined above.

Finally, really old programs might have code in them to generate abends. This can be done in any number of ways, but division by zero was often a favourite:

        DIVIDE SOME-NUMBER BY ZERO GIVING SOME-NUMBER.
        

Works every time!

Personally, I recommend setting the RETURN-CODE over calling ILBOABN0 or data-exception tehcniques.

Note: The RETURN-CODE special-register is not part of the COBOL-85 standard. It is available as an IBM extention to the language. You may need to resort to a different mechanism if you are working in a non-IBM compatible environment.

like image 133
NealB Avatar answered Sep 30 '22 21:09

NealB