Java access to sms and uncatalogued datasets



Support for Java SE, EE & ME, JVM, JNI, JDBC, EJB, JFC, JPDA, JAAS,JCE, JAXP, XML and Java API.

Java access to sms and uncatalogued datasets

Postby wcn00 » Thu Feb 28, 2008 12:52 am

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
wcn00
 
Posts: 2
Joined: Thu Feb 28, 2008 12:47 am
Has thanked: 0 time
Been thanked: 0 time

Re: Java access to sms and uncatalogued datasets

Postby wcn00 » Tue Mar 04, 2008 9:35 am

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
wcn00
 
Posts: 2
Joined: Thu Feb 28, 2008 12:47 am
Has thanked: 0 time
Been thanked: 0 time

Re: Java access to sms and uncatalogued datasets

Postby dick scherrer » Tue Mar 04, 2008 9:52 am

Thank you for posting what you found :)

It will probably help someone else later ;)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6269
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to Mainframe Java

 


  • Related topics
    Replies
    Views
    Last post