0

First 4 bytes of Variable block file in mainframe contains information about record and block. I'm able to read data from variable block file of mainframe via FTP or FTPS. But while trying to write back the data if I don't append space in each record then data is jumbled. Only if I append space in each record, I'm getting expected output. Is there any way I can write information of record in those first four bytes of variable block file?

  • Please improve your question - it is hard to understand. What language are you programming in? How does your data look? What is supposed to be in the initial field? Where is your code? – Mark Setchell Apr 12 '17 at 13:27
  • Please state exactly what you are doing. Are you using a package like curl to use the FTP protocol programmatically? Are you using FTP as an beginning step and a ending step, with processing in the middle? @MarkSetchell is correct, what you are saying makes no sense. – zarchasmpgmr Apr 13 '17 at 02:45
  • What FTP-commands do you use? Are you writing to an existing dataset or creating a new one? – piet.t Apr 13 '17 at 06:31
  • ftps.site("QUOTE RDW"); binp=new BufferedInputStream(ftps.retrieveFileStream(fileSrc)); final byte []bufLen= new byte[4]; int readLen=binp.read(bufLen, 0, 4); while(readLen!=-1){ ByteArrayInputStream ba2=new ByteArrayInputStream(bufLen,0,4); int z=ba2.read(); int reclen=0; int li=0; while(z!=-1){//Only first 2 bytes represents length of record. if(li==0) reclen+=z*256; else if(li==1) reclen+=z; li++; z=ba2.read(); } ba2.close(); reclen-=4; readLen=binp.read(new byte[reclen], 0, reclen); readLen=binp.read(bufLen, 0, 4);// Read length- RDW } – Sanjay Surana Apr 17 '17 at 05:20

1 Answers1

0

It's unclear exactly what you're doing and trying to accomplish. I'll assume though that you fetched some data from a VB (or maybe VBS) mainframe dataset via FTP. Then you process it on a non-mainframe platform and then FTP it back.

If you want to be able to read the block and record length successfully off-platform, you need to reference the mainframe dataset in the FTP job with RECFM=U. Note that this requires you to initiate the FTP from the mainframe side, I don't believe you can do an FTP get and preserve the block/record length from a VB(S) file. You may however be able to first copy the file on the mainframe to a RECFM=U file, then FTP that down. Again, requires action on the mainframe side to condition the data for your use.

When you put it back you may have a similar problem. Frankly, I haven't tried PUTting to RECFM=VB file to know if the mainframe FTP server will do the record/block lengths correctly for you by default, but it sounds like maybe not. So if you have to programmatically manage the record/block lengths in your off-platform code (this might not be quite as trivial as it might sound) before doing a PUT back to the mainframe, my guess is that you're going to have to put to a pre-allocated file that already has the correct RECFM. You might be able to use quote site commands (IIRC) to allocate a new dataset correctly, but again I haven't tried that.

In short, RECFM=U can get you the block/record lengths, putting them back may be trickier. But I'm not as sure about that direction.

Depending on what you're trying to do exactly, it very well may be easier to process the data in place on the mainframe. Especially if your code is Java: IBM makes the JZOS classes available that makes it pretty easy to read mainframe datasets on the mainframe.

randomScott
  • 306
  • 2
  • 8
  • I have used JZOS classes to read and write VB file in mainframe platform. But in current scenario I need to read VB via FTP and process it in Windows platform and again write back VB file in same order via FTP. Presently I'm able to read each record length of VB file but while writing it back if I don't append space in VB file, data is jumbled – Sanjay Surana Apr 17 '17 at 05:24