|
oldtimer (IS/IT--Management) |
25 Sep 00 17:26 |
On the mainframe the RDW is hidden, the system routines return the correct record although you still have to decode it using a record type etc. To transfer character data (ie. 'flat' or 'visible', typical PC/UNIX) FTP will obviously work, for packed and binary data (ie. typical mainframe) it WON'T, you need a proprietary solution like Connect Direct (both the sending AND receiving systems need the sofware ie. CD for MVS & CD for Unix, expensive!). When your Unix program reads the transferred file you get the whole record. So say the RDW (bytes 1-2 actually contain the count, ignore 3-4) contains 228, this is the length of the data (224) PLUS the rdw itself (4), if you coded - 01 REC 02 RDW PIC X(4) 02 REDEFINES RDW 03 LRECL PIC 9(4)BINARY 03 FILLER PIC XX 02 DATA PIC X OCCURS 0 TO 999 DEPENDING ON LRECL then you would actually read 232 bytes ie. 4 bytes into the next record - PROBLEM!!!. One (only?) solution is to use C byte-stream routines, these come with Microfocus (Merant?) COBOL and Fujitsu COBOL, possibly other vendors. Routines you need to CALL are CBL_OPEN_FILE, CBL_READ_FILE, CBL_CLOSE_FILE (lots of others too). Procedure is - 1. call CBL_OPEN_FILE, set read function to 'filesize' 3. call CBL_READ_FILE to get file size in bytes 3. set read function to 'i/o', set offset to 0, 4. call CBL_READ_FILE to read next 4 bytes, get lrecl 5. add 4 to offset and call CBL_READ_FILE read next (lrecl) bytes ie. the data 6. process data 7. add lrecl to offset and repeat from 4. 8. End-of-file is when the offset reaches the file size, then call CBL_CLOSE_FILE. Sounds fiddly but actually works well. Hope this helps. Alternatively knock up a routine in C yourself, not too difficult.
|
|