Capturing return code from a JCL

General discussion on the JZOS batch launcher and toolkit
Post Reply
ek1975
Posts: 23
Joined: Tue Sep 30, 2008 10:04 pm

Capturing return code from a JCL

Post by ek1975 »

Hello, I was looking for samples in the cookbook, but so far haven't seen one yet. I am submitting a JCL from my Java program using something like this:

<code>
String ddname = ZFile.allocDummyDDName();
ZFile.bpxwdyn("alloc fi(" + ddname + ") sysout writer(intrdr) recfm(f) lrecl(80) reuse msg(2)");
BufferedWriter wtr = null;
try {
wtr = FileFactory.newBufferedWriter("//DD:" + ddname);
wtr.write("....\n");
....
} catch (IOException e) {
</code>

Now I would like my Java program to get the return code from the JCL. Is there a way to do it? I briefly read about MVSJobSubmitter. Is that the way to go? Thanks for your time.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

The MvsJobSubmitter sample program uses a Rexx script to submit jcl and return the jobname and jobid in an "MvsJob" object. The MvsJob.getStatus() method can be used to return the status (result from the TSO STATUS command), but it won't help you get the job condition code.

There are a couple of ways to do this:

1) you can use the sample MvsJobOutput class to read the job's output and parse out the CC.

2) Write your own code that uses a technique like MvsJobOutput, which submits a Rexx script that uses the REXX SDSF api. In your code you would return the job status information, rather than the job output.

Hope this helps.
Post Reply