Hi Folks,
Is there someway to declare file defination whose record length and record format coming in dynamically when running the program.
I can mingle around with the logic to populate this in a variable before opening the file...
I don't know OS/390 but I think that if you define the file as line sequential it will be able to handle different record legths (delimited by CR and/or LF I suppose) without any other work from you.
One of the key things is to specify "RECORD CONTAINS 0 CHARACTERS" in your FD section for the file. Cobol will then use the lrecl definition specified in your JCL or the actual lrecl the file was created with if not specified in your JCL.
Next, define your record layout as the largest you expect to receive. You will have to have some way of knowing exactly how large your record is so once you issue a read you can move the valid portion of the record from your input area into a working storage field with a proper layout.
Example.
FD INPUTFILE
......
RECORD CONTAINS 0 RECORDS.
01 INPUTAREA PIC X(2000).
READ INPUTFILE .....
MOVE INPUTAREA(1:LRECL) TO WORKINGSTORAGELAYOUT.
There's a cobol pgm written by CHARLIE HOTTEL that shows how to get the LRECL for any file used by the pgm. Don't know how to contact him, but I do have the code.
If you want a copy contact me at jacksleight@hotmail.com
If you want to excise the code you need, just do a search
for "LRECL" or "DCB". Also don't forget to OPEN your target file before you begin your search of the TIOT for the DDNAME associated with it.
It's a handy pgm to have. It shows you how to get at most of the system info you might have a need for.
I don't know if this is still supoported but we used to define files as format "U", (undefined), in jcl. you used to be able to bypass dcb processing. (i come from a world where we had 4k machines. we had to write our own iocs, (input output control system), and do necessary label checking and deblocking ourselves to eliminate the high space using ibm software.
It has been a long time since I used format "U" however, I do think it is still available in the mainframe compilers. If I remember correctly, this option reads the whole block of records at once and your program must deblock the data to retrieve the actual record.
It does sound like this might do the job however, A123I indicates they want to read any type of input. Variable and Fixed. Using this option would make the program somewhat more difficult as you would have to know the format of the file ahead of time and adjust your deblocking for variable block files to deal with the variable record sizes.
2) For what you are doing (and as long as your input is ALWAYS a QSAM file), you can CALL a subroutine passing the FD-name *before* your open, and that subroutine will get the "DCB" as an input field that you can then "modify" as you wish. Traditionally such subroutines are in Assembler, but if you really like "working with pointers" - you can also process this in COBOL (just get the layout of the DCB macro).
First, I want to thank Slade for providing the refrenced code -- it will be handy.
My challenge is that I want my output file's length to be determined at run time (390 Cobol). I want it to be fixed (not variable), but potentially a different fixed length each time it runs. This length could EITHER be taken from the JCL DD statement (new allocated file, complete with DCB information) or calculated in the program -- either approach works for me, although the latter is preferred. From all my reading, it appears that to use the information from the JCL, I *should* be able to code the output file FD with "RECORD CONTAINS 0 CHARACTERS". However, the Cobol compiler gives an error on the OPEN OUTPUT for this FD:
IGYPA3143-E Physical "SEQUENITAL" file "OUT-FILE" specified in an "OPEN OUTPUT" or "OPEN EXTEND" statement was defined with a "RECORD CONTAINS 0 CHARACTERS" clause. The statement was processed as written.
This works fine for the input files, by the way, but I can't figure out how to do so for the output file.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.