Skip to main content

alphaWorks  >  Forums  >  IBM JZOS Batch Toolkit for z/OS SDKs  >  developerWorks

ZFile and HFS files    Point your RSS reader here for a feed of the latest messages in this thread


     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
Permlink Replies: 8 - Pages: 1 - Last Post: Oct 13, 2009 12:17 PM Last Post By: KirkWolf Threads: [ Previous | Next ]
cogitoergosum

Posts: 30
Registered: Aug 18, 2005 02:03:51 PM
ZFile and HFS files
Posted: Jul 14, 2007 12:17:27 AM
Click to report abuse...   Click to reply to this thread Reply
Hi,
I know that, java.io package should be used for HFS files rather than ZFile. But, I am facing a situation where it is possible that the user may supply a HFS file or a MVS dataset to a DD name. I notice that, the error messages are same when the DD name is not coded or pointed to a HFS file :
code
//DD:INPUT: fopen() failed - EDC5037I The specified ddname was not found. errno=37 errno2=0xc00b05b1 last_op=40[/code]

Therefore, in my case, is coding two versions of my class (one using jrio and other using ZFile) the solution ?

Regards,
Nags.
cogitoergosum

Posts: 30
Registered: Aug 18, 2005 02:03:51 PM
Re: ZFile and HFS files
Posted: Jul 14, 2007 12:18:51 AM   in response to: cogitoergosum in response to: cogitoergosum's post
Click to report abuse...   Click to reply to this thread Reply
[i]jrio, above, should read as java.io package[/i]
KirkWolf

Posts: 195
Registered: Jan 17, 2006 03:13:58 PM
Re: ZFile and HFS files
Posted: Jul 14, 2007 11:29:26 AM   in response to: cogitoergosum in response to: cogitoergosum's post
Click to report abuse...   Click to reply to this thread Reply
You should be able to use ZFile to open a DD that points to an HFS file.
What options are you using to open the file?
You might check the job log for additional IO error messages (IECxxxx) that might indicate what the problem is.

Also, you might want to look at the FileFactory.newBufferedReader(String) method that is part of JZOS. It allows you to open a text file with either a HFS-style name or a //MVS name and it will give you a java.io.BufferedReader. Underneath, there will be either a java.io FileReader or a jzos ZFile.
cogitoergosum

Posts: 30
Registered: Aug 18, 2005 02:03:51 PM
Re: ZFile and HFS files
Posted: Jul 15, 2007 04:48:03 AM   in response to: KirkWolf in response to: KirkWolf's post
Click to report abuse...   Click to reply to this thread Reply
Hi Kirk,
I was using open options as rb,type=record,noseek. I got it working with options as r. I didn't see any IEC messages.

I think, FileFactory will serve my purpose.

Sorry, should have gone through the doc more before I posted.

Thanks,
Nags.
cogitoergosum

Posts: 30
Registered: Aug 18, 2005 02:03:51 PM
Re: ZFile and HFS files
Posted: Jul 16, 2007 11:04:54 PM   in response to: cogitoergosum in response to: cogitoergosum's post
Click to report abuse...   Click to reply to this thread Reply
Yes, I got it working. I was interested in creating an InputSource object. I did it thus :
code
public InputSource getInputSource(String DDname) throws IOException {
ZFile zf = new ZFile(DDname, "r");
int dsorg = zf.getDsorg() ;
String fileName = "";

if (dsorg==zf.DSORG_HFS) {
fileName = zf.getActualFilename();
} else {
fileName = "//'" + zf.getActualFilename() + "'";
}
InputStream istr = FileFactory.newInputStream(fileName);
InputSource isrc = new InputSource(istr);
return isrc;
}
[/code]

Thanks again, Kirk !

Regards,
Nags
KirkWolf

Posts: 195
Registered: Jan 17, 2006 03:13:58 PM
Re: ZFile and HFS files
Posted: Jul 16, 2007 11:31:43 PM   in response to: cogitoergosum in response to: cogitoergosum's post
Click to report abuse...   Click to reply to this thread Reply

AFAIK, the following should also work. In your example you will end up leaving the DD open, even if the InputSource is closed by the XML parser.

public InputSource getInputSource(String DDname) throws IOException {
InputStream istr = FileFactory.newInputStream("//DD:" + DDname);
InputSource isrc = new InputSource(istr);
return isrc;
}

cogitoergosum

Posts: 30
Registered: Aug 18, 2005 02:03:51 PM
Re: ZFile and HFS files
Posted: Jul 17, 2007 12:03:54 AM   in response to: KirkWolf in response to: KirkWolf's post
Click to report abuse...   Click to reply to this thread Reply
Neat !

I took the filename to mean the fully-qualified name. I did not know, I could have provided the DD name itself.

Thanks, Kirk !

Regards,
Nags.
hhoward

Posts: 1
Registered: Oct 13, 2009 10:46:17 AM
Re: ZFile and HFS files
Posted: Oct 13, 2009 11:06:26 AM   in response to: cogitoergosum in response to: cogitoergosum's post
Click to report abuse...   Click to reply to this thread Reply
Regarding this statement:
Also, you might want to look at the FileFactory.newBufferedReader(String) method that is part of JZOS. It allows you to open a text file with either a HFS-style name or a //MVS name and it will give you a java.io.BufferedReader. Underneath, there will be either a java.io FileReader or a jzos ZFile.

My project is trying to read a flat file, do some calculations and/or balancing of the data, and write out a flat file using the same Java code. This code would execute on the mid-tier and the mainframe to process the flat files created on either (using the JZOS batch launcher on the mainframe). I'm trying to use the FileFactory class, but my test class won't compile; it can't find the com.ibm.jzos package. That's on the mainframe. Do I have to maintain different classes/methods to read the file - one on the mainframe that uses the FileFactory class and another on the mid-tier that uses the FileReader class?

KirkWolf

Posts: 195
Registered: Jan 17, 2006 03:13:58 PM
Re: ZFile and HFS files
Posted: Oct 13, 2009 12:17:41 PM   in response to: hhoward in response to: hhoward's post
Click to report abuse...   Click to reply to this thread Reply
You will need to have <JAVA_HOME>/lib/ext/ibmjzos.jar to compile or run your code that uses com.ibm.jzos.FileFactory

Point your RSS reader here for a feed of the latest messages in all forums