Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Write to spool even when job abends?

Former Member
0 Kudos

There's got to be a way to do this, but I can't seem to find it. I have several background jobs, each of which writes some diagnostic information to the spool. That diagnostic information would be most useful in cases where the job terminates unsuccessfully. But, in those cases, the spool is never saved, and all that information is lost.

I know I can write to the job log instead of the spool, but is there a way other than the log to obtain\show that information? Assume that my program is robust enough to capture all error conditions before terminating.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello Chris,

I'm sure you might be knowing this, but shall post it here anyways, just in case it skipped your mind.

When you run a background job, the job will abend when either of the following types of message are issued in the program:

1. Warning Message ( Type W )

2. Error Message ( Type E )

3. Abend Message ( Type A )

4. Short Dump Message ( Type X )

In case of either an Abend Message or a Short Dump Message, the entire spool list is erased and thereafter unavailable.

However, in case of either an error message or a warning message, the contents of the spool till the point where the message has occurred are retained.

So, in your case, I suspect that there are some abend messages in the program, issued upon erroneous conditions. If you could change them to ERROR messages (or WARNING messages as you deem appropriate), the spool list is not destroyed.

For your further understanding, I have included the following code snippet.

=======================================================

do 10 times.

write : / sy-index.

case sy-index.

when 3.

message s702(bctrain).

when 5.

message i702(bctrain).

when 7.

message w702(bctrain). " or message e702(bctrain).

endcase.

enddo.

=======================================================

The above program, when scheduled as a background job will get abended, but will retail the spool list :

1

2

3

4

5

6

7

After 7, the warning message abends the job and no other numbers are printed.

Hope this explanation would help you overcome your problem.

Regards,

Anand Mandalika.

2 REPLIES 2

Former Member
0 Kudos

Hello Chris,

I'm sure you might be knowing this, but shall post it here anyways, just in case it skipped your mind.

When you run a background job, the job will abend when either of the following types of message are issued in the program:

1. Warning Message ( Type W )

2. Error Message ( Type E )

3. Abend Message ( Type A )

4. Short Dump Message ( Type X )

In case of either an Abend Message or a Short Dump Message, the entire spool list is erased and thereafter unavailable.

However, in case of either an error message or a warning message, the contents of the spool till the point where the message has occurred are retained.

So, in your case, I suspect that there are some abend messages in the program, issued upon erroneous conditions. If you could change them to ERROR messages (or WARNING messages as you deem appropriate), the spool list is not destroyed.

For your further understanding, I have included the following code snippet.

=======================================================

do 10 times.

write : / sy-index.

case sy-index.

when 3.

message s702(bctrain).

when 5.

message i702(bctrain).

when 7.

message w702(bctrain). " or message e702(bctrain).

endcase.

enddo.

=======================================================

The above program, when scheduled as a background job will get abended, but will retail the spool list :

1

2

3

4

5

6

7

After 7, the warning message abends the job and no other numbers are printed.

Hope this explanation would help you overcome your problem.

Regards,

Anand Mandalika.

0 Kudos

Anand,

Thanks very much for your answer. I guess I've always used the "A" message type, and never realized that "E" would retain the spool.

Chris