View previous topic :: View next topic
|
Author |
Message |
Vidhya Kalyanasundaram
New User
Joined: 19 Jul 2007 Posts: 30 Location: chennai
|
|
|
|
Hi All,
We are trying to create a generic cobol program which would read a PS file of any length and create an output PS of length(Input lrecl + 24). To read the file of any different length, we tried using "RECORD CONTAINS 0 CHARACTERS" and defining the 01 level with Maximum possible Input file length as shown below. It seems to work fine and the file is opened successfully for any given LRECL.
Code: |
FD I-FILE
RECORDING MODE IS F
BLOCK CONTAINS 0 RECORDS
RECORD CONTAINS 0 CHARACTERS.
01 I-DATE-FILE PIC X(20000). |
But, I am are not sure how to make the output to create record dynamically(Input lrecl + 24) . I tried the following format in FD section of Output file.
Code: |
FD O-FILE
RECORDING MODE IS V
BLOCK CONTAINS 0 RECORDS
RECORD IS VARYING FROM 1 TO 20024
DEPENDING ON WS-OFILE-LENGTH.
01 O-DATA-REC PIC X(20024). |
In the job, the Input Lrecl + 24 bytes was coded in DCB - LRECL parm and RECFM as VB.
But got error in Opening the Output file (File Status 39- An OPEN statement was unsuccessful because of a conflict between the fixed file attributes and the attributes specified for the file in the program) when tested with an Input of Lrecl 1200.
Any help regarding this is much appreciated |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You would need to dynamically allocate the output file.
If you proceed with the variable file definition, the output will have to be variable. . . |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Add on:
Why does someone believe you need to create this?
From what i've seen, what you want to do can be done with your sort product or some other utility? |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Whilst I'm not a COBOL programmer (or haven't been in recent decades ), remember that a variable-length logical record will have a record descriptor word that is included in the LRECL, but is not editable by the user-written code. The RECORD IS VARYING FROM 1 TO 20024 clause would, I think, be appropriate for LRECL=20028 (20,024 bytes of data and 4 bytes for the RDW). |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I used to work with a system that allowed for any length record. However, the file handling routine could not be written in COBOL but had to be written in Assembler. COBOL is just not designed to handle files unless the record length is known AT COMPILE TIME, period. Either give up on your idea, or plan on using Assembler (for example) to handle all the file processing. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
What are you trying to do, as there may be a better solution than the "Generic" Cobol program?
You want to extend all records on different datasets by 24 bytes? Whereabouts is the extension? Is it in a "fixed" part of the record or somehow you are extending the variable part? |
|
Back to top |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
Good afternoon to all!
You are reading a fixed length file but the length is allocated at run time and your block size is taken from the JCL. On your FD for the output you should specify ' RECORD IS VARYING IN SIZE FROM 1 TO 2002 DEPENDING ON WS-OFILE-LENGTH.' |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
On your FD for the output you should specify ' RECORD IS VARYING IN SIZE FROM 1 TO 2002 DEPENDING ON WS-OFILE-LENGTH.' |
Not if the output file is supposed to be fixed length. . . |
|
Back to top |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
Mr. Scherrer,
The output is variable depending on what he moves to WS-OFILE-LENGTH. But he wants to set WS-OFILE-LENGTH to the same length as the input then he's has a problem which I don't have a answer to. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Jose,
Quote: |
then he's has a problem which I don't have a answer to. |
Yup, we don't either in vanilla COBOL
The way several of us have done this is using assembler. Personally, i'd think that this late in IT history, whatever is needed can be done without writing assembler (frowned on at many places because there are few people still practicing assembler). If something generic was wanted, it should not be too difficult to write a "driver" that would take the specifics of the copy and generate sort (or other utility?) control statements to do what is needed. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Assembler would be the wise language to use for such an endevor.
For ease of maintenance, define a fixed-length DCB and a variable-length DCB in the program.
DCB keywords can use register notation (for example), LRECL=(Rx), BLKSIZE=(Rx), etc.
You pass the values for these registers in a parmlist from the Caller, as binary fullwords.
You can use a default DDNAME defined to the given DCB, such as FXDFILE or VARFILE and these would be the DDNAME(s) in the JCL.
This is just part of it, but this can get you on your way.... |
|
Back to top |
|
|
|