Page 1 of 1

Java access to sms and uncatalogued datasets

PostPosted: Thu Feb 28, 2008 12:52 am
by wcn00
Ibm provides the recordio package for accessing zos datasets from java, but I don't see any way to specify SMS parms or access uncatalogued datasets. Anyone ever do that?
wcn

Re: Java access to sms and uncatalogued datasets

PostPosted: Tue Mar 04, 2008 9:35 am
by wcn00
Answered my own question... finally.
The JZOS package (freely available for IBM) provides a ZFile object which has static methods which allow you to allocate a DDNAME, dynamically map it to a dataset and then open it. Like this:
ddName = ZFile.allocDummyDDName();
String dynallocRequest = "alloc fi("ddName") da(bob.dev.c(sample)) shr reuse msg(2)";
System.out.println("Attempting to dynamically allocate a dataset using:\n "+dynallocRequest);
zf.bpxwdyn(dynallocRequest);
zf = new ZFile("//DD:" + ddName,"r");

zf.seek(0,ZFile.SEEK_END);
long size = zf.tell();
zf.seek(0,ZFile.SEEK_SET);
byte[] barray = new byte(int) size;
int read = zf.read(barray,0,(int)size);
String thing = new String(barray, "Cp037");
System.out.println(thing);

In this case I didn't do anything fancy like use an uncatalogued dataset, but the principle holds. The bpxwdyn method takes any string allowable by the equivalent REXX function, see the rex for uss doc.
Not that once you have allocated a DDname you can use the regular java rio package to do more java centric operations on it.

wcn

Re: Java access to sms and uncatalogued datasets

PostPosted: Tue Mar 04, 2008 9:52 am
by dick scherrer
Thank you for posting what you found :)

It will probably help someone else later ;)

d