Dynamic length file declaration in COBOL in VS Cobol II
Dynamic length file declaration in COBOL in VS Cobol II
(OP)
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...
Thanks and regards,
A123I
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...
Thanks and regards,
A123I
RE: Dynamic length file declaration in COBOL in VS Cobol II
What Cobol? What OS? What kind of file? (Line/Binary) Sequential, Indexed, Relative?
I think the only "standard" is for Line Sequential files (plain text). Other cases depend on vendor. Please specify.
Theophilos.
RE: Dynamic length file declaration in COBOL in VS Cobol II
thanks for that.. I'm working on OS/390, and I am going to handle the Sequential file.
Regards,
A123I
RE: Dynamic length file declaration in COBOL in VS Cobol II
RE: Dynamic length file declaration in COBOL in VS Cobol II
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.
I think this is what you are asking.
etom
RE: Dynamic length file declaration in COBOL in VS Cobol II
The following link might help. Also try using the "advanced search function here. You might find other threads on the subject.
Regards, Jack.
Thread209-659340
RE: Dynamic length file declaration in COBOL in VS Cobol II
This was really close to what I was looking for. I would like to slightly more descriptive on my problem...
I wanted to code a universal program in cobol that could process input file of any record format, record length.
Thanks once again for everbody's help on this...
Regards,
Atul
RE: Dynamic length file declaration in COBOL in VS Cobol II
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.
Regards, Jack.
RE: Dynamic length file declaration in COBOL in VS Cobol II
RE: Dynamic length file declaration in COBOL in VS Cobol II
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.
etom.
RE: Dynamic length file declaration in COBOL in VS Cobol II
Thanks everybody,
A
RE: Dynamic length file declaration in COBOL in VS Cobol II
Regards,
A
RE: Dynamic length file declaration in COBOL in VS Cobol II
I sent you the code the same day that I received your
e-mail. I deleted your e-mail w/your return address, so please resend it.
Thanx, Jack.
RE: Dynamic length file declaration in COBOL in VS Cobol II
1) Regarding using RECORDING MODE IS U
Make certain that you read,
"Change in file handling for COBOL programs with RECORDING MODE U under OS/390, Version 2 Release 10"
at:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BO...
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).
Bill Klein
RE: Dynamic length file declaration in COBOL in VS Cobol II
Just for your all reference the things are working using pointer which return the details of the files that are being used.
Regards,
A
RE: Dynamic length file declaration in COBOL in VS Cobol II
RE: Dynamic length file declaration in COBOL in VS Cobol II
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.
Thanks, Craig
RE: Dynamic length file declaration in COBOL in VS Cobol II
It doesn't work for the output files. Perhaps you can use a byte-stream output file.
Regards,
Crox
RE: Dynamic length file declaration in COBOL in VS Cobol II
RE: Dynamic length file declaration in COBOL in VS Cobol II
RE: Dynamic length file declaration in COBOL in VS Cobol II
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BO...
Bill Klein
RE: Dynamic length file declaration in COBOL in VS Cobol II
RE: Dynamic length file declaration in COBOL in VS Cobol II
The bottom-line is that there is NO truly supported way to do this.
Another (unsupported) solution (for QSAM - nto VSAM) would be to create a "random" record layout in your source fprogram; after you OPEN the file, do a CALL "assembler-program" USING FD-name.
Then the Assembler subprogram will receive addresability to the DCB and could "manually" modify the attributes.
HOWEVER, the bottom-line is that (Standard and/or IBM) COBOL is NOT intended to create "dynamic" files.
Bill Klein
RE: Dynamic length file declaration in COBOL in VS Cobol II
RE: Dynamic length file declaration in COBOL in VS Cobol II
Sure. What'a your e-addr?
Regards, Jack.
RE: Dynamic length file declaration in COBOL in VS Cobol II
I wonder what would happen if I used the same code Slade provided to find the LRECL and write a new value to it (after opening it with a very large LRECL, but never yet writing) -- would this work, or would Cobol choke on the first write?
Again, I appreciate all the help.
Craig
RE: Dynamic length file declaration in COBOL in VS Cobol II
RE: Dynamic length file declaration in COBOL in VS Cobol II
Make certain that you use the AWO compiler option. To the besto of my knowledge, this compiler option NEVER causes a problem - and is always a "performance" (and space) benefit when writing blocked VB files.
See:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BO...
Bill Klein
RE: Dynamic length file declaration in COBOL in VS Cobol II
schristi69@yahoo.com
RE: Dynamic length file declaration in COBOL in VS Cobol II
I am working with a similar problem trying to write a general program that works on different input and output files - record sizes not known until run time.
Regards
Olav
RE: Dynamic length file declaration in COBOL in VS Cobol II
If you find a way to dynamically set output record length (new file), PLEASE let me know.
Thanks, Craig