View previous topic :: View next topic
|
Author |
Message |
mangalrajnm
New User
Joined: 13 Apr 2007 Posts: 7 Location: Chennai
|
|
|
|
Dear All,
I created a file dynamically using COBOL and the assembler program BPXWDYN. But i am not able to open the file which i created , as the requirement for us is to pass the record length of the file during run time. Since we define the record paramters in the FD section as
FD FILEIN
BLOCK CONTAINS 0 RECORDS
RECORD CONTAINS 0 CHARACTERS
RECORDING MODE IS F.
01 FD-GDG-IN-RECORD PIC X(1000).
and then specify the allocation parameters in the procedure division which need not be with a record length of 1000 i am getting file status 39.
Please let me know how to avoid file status 39 when i need to create each time a file of different record length. I am struggling a lot with this
ALLOC DD(DYNCRE) DSN('test.file') MSG(WTP) NEW CYL SPACE(10,10) KEEP LRECL(200) |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Are you opening INPUT or OUTPUT? |
|
Back to top |
|
|
mangalrajnm
New User
Joined: 13 Apr 2007 Posts: 7 Location: Chennai
|
|
|
|
I am opening in OUTPUT mode |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
From the Enterpise COBOL Language Reference.
Quote: |
Must be an unsigned integer that specifies the number of bytes contained in each record in the file. The RECORD CONTAINS 0 CHARACTERS clause can be specified for input QSAM files containing fixed-length records; the record size is determined at object time from the DD statement parameters or the data set label.
|
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Just a thought.
Can't you stick with a standard file record-length (1000) temporary dataset for the COBOL program. Then, right before ending the program, write out a proper SORT control file, and call DFSORT or SYNCSORT to easily create the cataloged dataset in the desired record length. |
|
Back to top |
|
|
mangalrajnm
New User
Joined: 13 Apr 2007 Posts: 7 Location: Chennai
|
|
|
|
Dear All,
My challenge is that I want my output file's length to be determined at run time (390 or enterprise 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.
Please let me know how to do this as it is very critical for our project |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
I suggest you re-read the quote from the cobol manual posted above. . . If we can believe IBM, it only works for input files.
Quote: |
Please let me know how to do this as it is very critical for our project |
If it is that critical and the volume is not too high, create the file at the longest possible fixed length and then reformat it in another utility step (sort, iegbener, etc). |
|
Back to top |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
At one time I used a COBOL program Sort exit for a situation like this. Sort passed each input record to the COBOL exit, the COBOL program processed the records and passed it back to sort to be written out. The COBOL program did not need to work with the actual length of the record sort and JCL took care of that. The COBOL program just had to allocate the longest allowed record length. |
|
Back to top |
|
|
mangalrajnm
New User
Joined: 13 Apr 2007 Posts: 7 Location: Chennai
|
|
|
|
Hi Dick,
Thanks a lot for your timely reply . Can I proceed using a sort step to reformat the file? |
|
Back to top |
|
|
mangalrajnm
New User
Joined: 13 Apr 2007 Posts: 7 Location: Chennai
|
|
|
|
I thank each and every one who has provided me your valuable thought |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
You're welcome
Quote: |
Can I proceed using a sort step to reformat the file? |
Sure. If you look in the DFSORT or JCL sections of the forum (depending on whether you have DFSORT or Syncsort), there are examples of reformatting data.
There should also be info in the appropriate manual. |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
I spent a decent amount of time on this same problem. And the sort step is the only approach I could get to work. I thought I worked somewhere once that called an assembler program to do this but I haven't been able to find anyone there who knows what I'm talking about so I must have been mistaken. |
|
Back to top |
|
|
|