views:

81

answers:

2

Hi,

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?

+2  A: 

see the following link on how to set the return code passed back to a JCL job step as well as force an Abened code. http://www.tek-tips.com/viewthread.cfm?qid=1058302&page=22

Jared
+3  A: 

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

I suspect setting a RETURN-CODE, writting 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 by creating a data exception error (SOC7). 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.

NealB