Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic length file declaration in COBOL in VS Cobol II 5

Status
Not open for further replies.

A123I

Programmer
Oct 15, 2003
8
US
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
 
Hi A123I,

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.
 
Hi theotyflos,
thanks for that.. I'm working on OS/390, and I am going to handle the Sequential file.

Regards,
A123I
 
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.
 
A123I,

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
 
Hi A,

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
 
Hi Etom,
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
 
Hi A,

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.
 
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.

etom.
 
Etom is correct on this... I am still waiting for the response from slade once I get it I'll let you all know about this.

Thanks everybody,
A
 
Hi Slade, Still waiting for the response from your side. Can u please arrange to send the program?

Regards,
A
 
Hi A,

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.
 
A couple of "updates"

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:


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
 
A star to Slade he had send the code to me and this is going to solve my problem. Thanks a million to everybody for helping me out with this.

Just for your all reference the things are working using pointer which return the details of the files that are being used.

Regards,
A
 
[This is my first-ever posting to Tek-Tips]

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
 
Hi,

It doesn't work for the output files. Perhaps you can use a byte-stream output file.

Regards,

Crox
 
I never used it but what would RECORDING U mean?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top