I am writing some java code that creates a file on my zOS system via some java code running on the mainframe. After this file is created I want to be able to submit it as batch.
I have tried using the tso sub command with both the -o and -t flags in use, but have been told that since tso sub is an APF authorized command I cannot use it directly from Java. It was then recommended that I use a REXX script to get the job done, but I am trying to develop this program solely on Java. I am sure there must be a back-door way to submit a batch job via Java.
The following is a Java package to allow JCL submission
[code]
package com.healthmarkets.util;
/*
* submit.java
*
* Created on February 5, 2007, 1:51 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/** Creates a new instance of submit */
public submit()
throws java.io.IOException
{
ddname=ZFile.allocDummyDDName();
ZFile.bpxwdyn("free fi("+ddname+")");
ZFile.bpxwdyn("alloc fi("+ddname+") sysout(x) writer(INTRDR) recfm(f) lrecl(80) msg(2) reuse");
intrdr=FileFactory.newBufferedWriter("//DD:"+ddname);
}
public void write(String statement)
throws java.io.IOException
{
if (debug) System.err.println("write String");
cardCount++;
if (statement.length() > 80) throw new java.io.IOException("Record too long");
intrdr.write(statement+"\n");
if (debug) System.err.println(statement+"\n");
}
public void write(String[] statements)
throws java.io.IOException
{
int i;
if (debug) System.err.println("write String[]");
for(i=0;i<statements.length;i++) {
if (statements[i].length() > 80) throw new java.io.IOException("Record too long");
intrdr.write(statements[i]+"\n");
if (debug) System.err.println(statements[i]+"\n");
cardCount++;
}
}
public void setDebug(boolean debug)
{
System.err.println("setDebug("+debug+")");
this.debug=debug;
}
public void write(ZFile file)
throws ZFileException, java.io.IOException
{
byte[] buffer= new byte[file.getLrecl()];
int bytesRead;
if (debug) System.err.println("write ZFile");
if (buffer.length > 80) throw new java.io.IOException("LRECL > 80");
while((bytesRead=file.read(buffer))>=0) {
intrdr.write(new String(buffer)+"\n");
if (debug) System.err.println(new String(buffer)+"\n");
cardCount++;
}
file.close();
}
public void write(java.io.File file)
throws java.io.IOException
{
if (debug) System.err.println("write java.io.File");
if (! file.exists()) throw new java.io.IOException("File does not exist");
if (! file.isFile()) throw new java.io.IOException("Not a valie UNIX file");
if (! file.canRead()) throw new java.io.IOException("Cannot read UNIX file");
BufferedReader input=new BufferedReader( new FileReader(file));
String line=null;
while ((line=input.readLine())!=null) {
intrdr.write(line+"\n");
if (debug) System.err.println(line+"\n");
cardCount++;
}
input.close();
input=null;
}
public void close()
throws java.io.IOException
{
if (debug) System.err.println("close");
intrdr.close();
ZFile.bpxwdyn("free fi("+ddname+") msg(2)");
System.err.println("Wrote "+cardCount+" JCL statements");
}
public void abort()
throws java.io.IOException
{
if (debug) System.err.println("abort");
write("/*PURGE");
close();
}
}
[/code]
BTW - the latest version of JZOS on alphaWorks (2.1.1) has sample code for submitting JCL and getting job status via a REXX child process. This has the advantage of returning the jobname and jobid of the submitted job.
Just curious?
Is it possible, alone with obtaining the Job Id, to get the start and ending times of a particular Jobname, with the above REXX child process?