Prev: Mainframe Question
Next: Search for a string using SORT
From: pottmi on 4 Feb 2006 16:00 I have been trying to get a microfocus cobol program to open and read a variable sequential file that is the same format as what gets transfer to my computer via ftp. That transfer format is very simple: 2 bytes indicating the length of the data. 2 bytes of low values N bytes of data. that pattern repeated for each record. Microfocus seems to want a 128 byte header on the file, along with some other differences. My questions are: 1) has anyone found a combination of options that allow a cobol program compiled with the microfocus compiler to read such a file? 2) has anyone written an external file handler using microfocus sanctioned techniques that will read such a file. 3) has anyone written an external file handler using microfocus sanctioned techniques that I can have so I can use it as a starting point to read such a file. By MicroFocus sanctioned techniques, I am referring to the microfocus "File Handling" book. Just to save everyone some time... I dont need to be told about options like converting the data comma delimited files for transfer, and I dont need any information about the possibilities of the data not being compatible. My question is about sequential file format compatibilty, not data compatiblity. Also, I have already written a C program to do the conversion so I already have a backup plan if I am not able to read the files directly. Michael Potter
From: Michael Mattias on 4 Feb 2006 17:36 > I have been trying to get a microfocus cobol program to open and read a > variable sequential file that is the same format as what gets transfer > to my computer via ftp. > > That transfer format is very simple: > 2 bytes indicating the length of the data. > 2 bytes of low values > N bytes of data. > that pattern repeated for each record. > > Microfocus seems to want a 128 byte header on the file, along with some > other differences. > > My questions are: > 1) has anyone found a combination of options that allow a cobol program > compiled with the microfocus compiler to read such a file? If the data truly are a stream like this (that is, there are no 'end of record' markers in the input stream) then you should be able to read it as a sequential file with any record length you want, provided once you read a record you take over the job of figuring out how much of what you read is actually one logical record, and you can execute any additional reads required to get the rest of a logical record. ie., say you pick a record length of 20 Read first record; let's say the length is give you as 10 bytes. Discard the four length bytes (I'll bet that's actually a 32-bit integer, not a 16-bit integer plus 0x0000), move next ten to your first output record. Now read the next four bytes of the first record to get the length of the next data record. Let's say that is also ten bytes. Get the remainder of your first record (20 - 4 - 10 -4 = 2) and make that the first two bytes of your second output record. Now read the next 20 bytes. The first eight bytes will be the rest of logical record number two, and the lengthword+data follows that. Nobody said it would be fun. MCM
From: pottmi on 4 Feb 2006 20:00 The data is truely as I stated. The second pair of bytes is always low values, it is not a 32 bit integer. I presume that IBM decided to leave a pair of extra bytes available incase they ever wanted to support records larger than 32k. You can not treat them as a 32bit value even tho they are always zero because the byte order is not defined. When I read the raw data with C I throw an error if the second pair have anything but zero. Back to the problem... I am trying to read the data using existing COBOL programs without modifing the existing COBOL programs. I can do this as long as I convert the data to the microfocus format (w/128 byte header). Now I am trying to figure out what compile options will allow me to read the data without converting it to microfocus format first. I would also consider well defined changes to the code such as adding a "RECORD MODE VARIABLE" to the select statement. I already called Microfocus and 1st level support could not help. I am going to call Monday morning to see if someone in the UK has a different angle. The compiler has some many options I would not blame first level support if they did not know of the existence of a particular compile or runtime option. thanks for you quick response. Michael Potter
From: James J. Gavan on 4 Feb 2006 21:26 pottmi(a)gmail.com wrote: > I have been trying to get a microfocus cobol program to open and read a > variable sequential file that is the same format as what gets transfer > to my computer via ftp. > > That transfer format is very simple: > 2 bytes indicating the length of the data. > 2 bytes of low values > N bytes of data. > that pattern repeated for each record. > > Microfocus seems to want a 128 byte header on the file, along with some > other differences. > > My questions are: > 1) has anyone found a combination of options that allow a cobol program > compiled with the microfocus compiler to read such a file? > 2) has anyone written an external file handler using microfocus > sanctioned techniques that will read such a file. > 3) has anyone written an external file handler using microfocus > sanctioned techniques that I can have so I can use it as a starting > point to read such a file. > > By MicroFocus sanctioned techniques, I am referring to the microfocus > "File Handling" book. > > Just to save everyone some time... > I dont need to be told about options like converting the data comma > delimited files for transfer, and I dont need any information about the > possibilities of the data not being compatible. My question is about > sequential file format compatibilty, not data compatiblity. Also, I > have already written a C program to do the conversion so I already have > a backup plan if I am not able to read the files directly. > > Michael Potter > I see elsewhere you hope to read in without necessarily going through an interim conversion - good luck if you can get the appropriate answer from Tech in UK. Have you considered the possibility of using M/F Byte-Stream file techniques using CBL_XXX_FILE routines - that's assuming they apply to your compiler. Shouldn't be difficult from what you have above, allowing you to read in chunks, or if the whole file is not too large, read it in as one big chunk. If interested I can send you a zipfile of two M/F Demos - e-mail me as above but "edit" my e-mail address. Jimmy, Calgary AB
From: Colin Campbell on 4 Feb 2006 23:58
pottmi(a)gmail.com wrote: >I have been trying to get a microfocus cobol program to open and read a >variable sequential file that is the same format as what gets transfer >to my computer via ftp. > >That transfer format is very simple: >2 bytes indicating the length of the data. >2 bytes of low values >N bytes of data. >that pattern repeated for each record. > >Microfocus seems to want a 128 byte header on the file, along with some >other differences. > >My questions are: >1) has anyone found a combination of options that allow a cobol program >compiled with the microfocus compiler to read such a file? >2) has anyone written an external file handler using microfocus >sanctioned techniques that will read such a file. >3) has anyone written an external file handler using microfocus >sanctioned techniques that I can have so I can use it as a starting >point to read such a file. > >By MicroFocus sanctioned techniques, I am referring to the microfocus >"File Handling" book. > >Just to save everyone some time... >I dont need to be told about options like converting the data comma >delimited files for transfer, and I dont need any information about the >possibilities of the data not being compatible. My question is about >sequential file format compatibilty, not data compatiblity. Also, I >have already written a C program to do the conversion so I already have >a backup plan if I am not able to read the files directly. > >Michael Potter > > > Michael, I believe MicroFocus took care of your problem many years ago. I looked at the manuals that came with the MF Workbench V3.1, dated 1993. They supplied a utility program VRECGEN to be run on the mainframe before downloading variable length record data, and VRECGEN2, to run on the PC before going the opposite direction. Do you have documentation of those programs, and / or can you find them in the distributed code (in those days, the directory structure was COBOL\SAMPLE)? The assumption was that you would use SEND / RECEIVE to move the data from the mainframe and back to it. VRECGEN "converted" RECFM=V records so that you could use the resulting records directly in your program on the PC. I don't have the old Workbench installed anywhere, nor do I have a mainframe connection, so I can't test this out. And I haven't seen a release of MF COBOL for many years, so I don't know whether they've changed the approach you should take for managing RECFM=V records, but I do recall that this approach worked satisfactorily. Final note: You might want to study the format of variable length records, including spanned records. It isn't 100% accurate to say that the last half of a record descriptor word contains low-values. You can find the exact format information by Googling on "IBM Using Data Sets". (There is a manual by that name.) For spanned records, search that manual for "segment control code". |