2

I need to write to a non-VSAM dataset in the mainframe. I know that we need to use the ZFile library to do it and I found how to do it here

I am running my Java batch job in the WebSphere Liberty on zOS. How do I specify the dataset? Can I directly give the DataSet a name like this?

dsnFile = new ZFile("X.Y.Z", "wb,type=record,noseek");

I am able to write it to a text file on the server itself using Java's File Writers but I don't know how to access a mvs dataset.

I am relatively new to the world of zOS and mainframe.

ragingasiancoder
  • 616
  • 6
  • 17
Fazil Hussain
  • 425
  • 3
  • 16

1 Answers1

2

It sounds like you might be asking more generally how to use the ZFile API on WebSphere Liberty on z/OS.

Have you tried something like:

    String pdsName = ZFile.getSlashSlashQuotedDSN("X.Y.Z");
    ZFile zfile = new ZFile(pdsName , ...options...)

As far as batch-specific use cases, you might obviously have to differentiate between writing to a new file that's created for the first time on an original execution, as opposed to appending to an already-existing one on a restart.

You also might find some useful snipopets in this doctorbatch.io repo, along with the original link you posted.

For reference, I'll copy/paste from the ZFile Javadoc:

ZFile dd = new ZFile("//DD:MYDD", "r");

Opens the DD namee MYDD for reading

ZFile dsn = new ZFile("//'SYS1.HELP(ACCOUNT)'", "rt");

Opens the member ACCOUNT from the PDS SYS1.HELP for reading text records

ZFile dsn = new ZFile("//SEQ", "wb,type=record,recfm=fb,lrecl=80,noseek");

Opens the data set {MVS_USER}.SEQ for sequential binary writing. Note that ",noseek" should be specified with "type=record" if access is sequential, since performance is greatly improved. 

One final note, another couple useful ZFile helper methods are: bpxwdyn() and getFullyQualifiedDSN().

Scott Kurz
  • 4,985
  • 1
  • 18
  • 40