Submitting JCL from Java

General discussion on the JZOS batch launcher and toolkit
Post Reply
Rhys
Posts: 1
Joined: Thu Jul 06, 2006 8:13 am

Submitting JCL from Java

Post by Rhys »

Is it possible to submit JCL from Java on zOS?
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

You can submit JCL to the internal reader from Java by Allocating a DD using BPXWDYN and then opening the dd and writing JCL to it.


Something like this:

Code: Select all

ZFile.bpxwdyn("alloc fi(JCL) sysout writer(intrdr) recfm(f) lrecl(80) msg(2)");
BufferedWriter wtr = null;
		
try {
	wtr = FileFactory.newBufferedWriter("//DD:JCL");
	wtr.write("//USERA JOB (),USER \n");   // terminate with newline
	wtr.write("// EXEC PGM=IEFBR14 \n");   
	wtr.write("// \n");  
} finally {
	if (wtr != null) 
		try { wtr.close(); } catch(IOException ignore) {}
		
	ZFile.bpxwdyn("free fi(JCL) msg(2)");
}
MarkRucker
Posts: 1
Joined: Tue Jul 11, 2006 1:31 pm
Location: State of TN

How to submit directly to the JES spooler

Post by MarkRucker »

Is there a way to magically submit to the JES spooler and have it print immediately from Java using JZOS? We are trying to do real time prints of Vehicle Titles from Java/WebSphere.

Thanks
Mark Rucker
State of TN
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

(this is a little different from submitting a job... it seems that what you want is just to print some data to a JES printer)

What you would like to do is to have your long-running job (Websphere) dynamically allocate a SYSOUT dataset, write data to it, and then close and free it. To allow the sysout data to hit the print queue immediately, you need to "spin" it.

I'm assuming that you already have your printers hooked up to JES somehow, and that the data you are printing is simple "line-mode" data.

Here are the steps:

1) Dynamically allocate a DD for the output data. Since you may want to support multiple concurrent "print" transactions, you need to somehow generate a unique ddname. (Note: the name only needs to be unique withing the scope of the job). A future version of JZOS will support a feature that allows the system to assign a DDNAME, but in the mean time you will have to somehow generate your own. One approach is to have a singleton object or class variable that safely hands out a "next" DDNAME. It could be generated from a wrap-around counter, or maybe "Pnnnnnnn" where n is a sequence number. You will be freeing these after you use them.

Eg.

Code: Select all

 
String ddname = getNextDDName();   // like "Pnnnnnnn"
ZFile.bpxwdyn("alloc fi(" +ddname+ 
           ") sysout(a) spin(unalloc) recfm(v,b,a) lrecl(133) msg(2)" );
(change the DCB parameters to meet your needs)

2) Open the DD and write data to it, and then free the DD

Eg.

Code: Select all

BufferedWriter wtr = null;
try {
   wtr = FileFactory.newBufferedWriter("//DD:" + ddname);
   wtr.write(line1 + "\n");
   ....  
} finally {
   if (wtr != null)
      try { wtr.close(); } catch(IOException ignore) {}
      
   ZFile.bpxwdyn("free fi(" + ddname+ ") msg(2)");
} 
Post Reply