View previous topic :: View next topic
|
Author |
Message |
dineshsjce Currently Banned New User
Joined: 16 Apr 2007 Posts: 41 Location: Bangalore
|
|
|
|
Hi Freinds,
I have a COBOL program which performs some common function. This will be used by many users. Because of that input and output file LRECL and other parameters will vary. I have heard about dynamic file creation in COBOL. It would be great if some one gives me the sample code. My JCL code look like this:
//ST01 EXEC PGM=VCTV
//SYSUT1 DD DSN=GU00059.TEST.FILE,DISP=SHR
//SYSUT2 DD DSN=GU00059.TEST.FILE.OUT,DISP=(,CATLG,DELETE),
// DCB=(LRECL=120,BLKSIZE=1200,RECFM=FB),
// SPACE=(TRK,(1,1),RLSE),UNIT=APLWK
Everytime the DSN Name, LRECL, SPACE, UNIT, BLKSIZE, DISP will vary depending on the requirement of the users. How to handle this ? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Why not use VB records instead ? Then the universal code of
RECFM=VB,LRECL=27994
should always be valid. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
Back to top |
|
|
dineshsjce Currently Banned New User
Joined: 16 Apr 2007 Posts: 41 Location: Bangalore
|
|
|
|
Thanks Kevin, Anuj and Expat.
Kevin,
In all the above links dataset name and attributes are hardcoded. I did not get how to pass the dataset and other parameters from the JCL to the COBOL program. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
First, if you're dealing with fixed length files what you want to do cannot be done in COBOL. It can be done, sort of, with variable length files as long as the COBOL file length is the longest possible length -- 27994 per expat's post -- but if the JCL doesn't have LRECL=27994 you're going to get file status 39 (file attribute mismatch).
Find the COBOL Language Reference in the manual link above and read section 4.2.3.1 on Assignment Name for Environment Variable. This is the only way in COBOL to use dynamic allocation of files.
COBOL isn't really designed for dynamic allocation. This is much more typically done in Assembler, but it's not easy there.
From your description of the requirements, you need to reconsider your language choice and perhaps use REXX instead -- or even ISPF dialogs. Dynamic allocation is easy in SAS, for example. |
|
Back to top |
|
|
|