IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

creating a flat file using COBOL dynamically using BPXWDYN


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mangalrajnm

New User


Joined: 13 Apr 2007
Posts: 7
Location: Chennai

PostPosted: Thu Apr 24, 2008 11:14 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Apr 24, 2008 11:22 pm
Reply with quote

Are you opening INPUT or OUTPUT?
Back to top
View user's profile Send private message
mangalrajnm

New User


Joined: 13 Apr 2007
Posts: 7
Location: Chennai

PostPosted: Thu Apr 24, 2008 11:31 pm
Reply with quote

I am opening in OUTPUT mode
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Apr 24, 2008 11:43 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Apr 24, 2008 11:51 pm
Reply with quote

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
View user's profile Send private message
mangalrajnm

New User


Joined: 13 Apr 2007
Posts: 7
Location: Chennai

PostPosted: Thu May 01, 2008 10:13 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu May 01, 2008 10:31 pm
Reply with quote

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
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Thu May 01, 2008 11:28 pm
Reply with quote

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
View user's profile Send private message
mangalrajnm

New User


Joined: 13 Apr 2007
Posts: 7
Location: Chennai

PostPosted: Thu May 01, 2008 11:31 pm
Reply with quote

Hi Dick,

Thanks a lot for your timely reply icon_smile.gif . Can I proceed using a sort step to reformat the file?
Back to top
View user's profile Send private message
mangalrajnm

New User


Joined: 13 Apr 2007
Posts: 7
Location: Chennai

PostPosted: Thu May 01, 2008 11:35 pm
Reply with quote

I thank each and every one who has provided me your valuable thought icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu May 01, 2008 11:43 pm
Reply with quote

You're welcome icon_smile.gif

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
View user's profile Send private message
jasorn
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Fri May 16, 2008 10:34 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top