View previous topic :: View next topic
|
Author |
Message |
new2cobol
New User
Joined: 04 Jan 2006 Posts: 77 Location: Bangalore
|
|
|
|
We code a file control statement as
SELECT <filename> ASSIGN TO <ddname>
where DDNAME is assigned to a DSN in the JCL.
Can I in COBOL, change the file name associated to the DDNAME?
ie if <ddname> is assigned to <file01> in the JCL, can I change it to point to <file02> in COBOL? |
|
Back to top |
|
|
Pollyannaish
New User
Joined: 09 Jul 2005 Posts: 31 Location: Pune, India
|
|
|
|
new2cobol wrote: |
ie if <ddname> is assigned to <file01> in the JCL, can I change it to point to <file02> in COBOL? |
I am not sure of COBOL but a simple solution to this is use symbolic parameter in JCl to change the DDNAME dynamically.......
Let me know if this helps you.. |
|
Back to top |
|
|
martin9
Active User
Joined: 01 Mar 2006 Posts: 290 Location: Basel, Switzerland
|
|
|
|
hy there,
you cannot change the ddname dynamically,
or any association from select clause to the jcl's ddname.
as long you do not allocate any dataset dynamically
by your program, this is not possible...
martin9 |
|
Back to top |
|
|
new2cobol
New User
Joined: 04 Jan 2006 Posts: 77 Location: Bangalore
|
|
|
|
Ok, let me explain.
I am dynamically allocating a dataset in my COBOL program and I want to write int the file using COBOL's WRITE. I could have use an in-house assembler utility to write, but it takes 5 times the cpu time than a COBOL Write takes, and I am talking about writing 250-300 million records in each files and there are a total of 10-15 files.
I saw in UNISYS systems, the COBOL they use has a CHANGE ATTRIBUTE FILENAME command in the COBOL they use, which dynamically re-allocates the DDNAME with a different File.
I was wondering whether there was an MVS way to do this, I know there is know COBOL keywords for this, but if there is some utility which does this...
Any info |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
new2cobol,
I didn't read your requirements close enough, so I don't think this is what you want, but I'll post it anyway. This will change the DDNAME associated with an "FD"
This works for me, but I have only used it once. Maybe it wont work on all types of files.
Code this subroutine:
Code: |
ID DIVISION.
PROGRAM-ID. CHGDDN.
AUTHOR. DAVIDATK.
DATE-WRITTEN.
DATE-COMPILED.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
LINKAGE SECTION.
01 DCB.
05 FILLER PIC X(40).
05 DDNAME PIC X(8).
05 FILLER PIC X(192).
05 DDNAME2 PIC X(8).
01 NEW-DDNAME PIC X(8).
PROCEDURE DIVISION USING DCB
NEW-DDNAME.
MOVE NEW-DDNAME TO DDNAME2 DDNAME.
GOBACK.
|
Call like this:
Code: |
FILE-CONTROL.
SELECT TEST-FILE ASSIGN TO DD1.
SELECT TEST-DD2 ASSIGN TO DD2.
DATA DIVISION.
FILE SECTION.
FD TEST-FILE
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS.
01 TEST-REC PIC X(80).
FD TEST-DD2
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS.
01 TEST-DD2REC PIC X(80).
WORKING-STORAGE SECTION.
01 NEW-DDNAME PIC X(8) VALUE 'NEWDD1'.
01 WS-EOF-SW PIC X VALUE 'N'.
88 EOF VALUE 'Y'.
LINKAGE SECTION.
PROCEDURE DIVISION.
CALL 'CHGDDN' USING TEST-FILE NEW-DDNAME.
OPEN INPUT TEST-FILE
TEST-DD2.
PERFORM
UNTIL EOF
READ TEST-FILE
AT END MOVE 'Y' TO WS-EOF-SW
END-READ
DISPLAY TEST-REC
END-PERFORM.
CLOSE TEST-FILE
TEST-DD2.
GOBACK.
|
See if this works for you.
Dave, |
|
Back to top |
|
|
new2cobol
New User
Joined: 04 Jan 2006 Posts: 77 Location: Bangalore
|
|
|
|
Thanks Dave,
But I guess it won't fit into my requirement. Your code still points to same physical file; you are only changing the logical file. But thanks anyway... |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
new2cobol,
I'm still a little confused about what you want to accomplish, (the bulb burns dimly sometimes).
In your COBOL program you have a select that makes the relationship between your FD entry and the DDNAME/DSNAME (Physical file on disk).
Do you want to change the DDNAME the FD has the relationship to, or do you want to change the DSNAME the DDNAME has the relationship to, or other.
You also said that you are dynamically allocating the dataset in you Cobol program. What method are you using to accomplish this?
Maybe you could give a Pseudo code example.
Please come back
Dave |
|
Back to top |
|
|
gowrishankars
New User
Joined: 27 Mar 2006 Posts: 4 Location: pune
|
|
|
|
HI new2cobol,
I think you can do that.
Check the following logic.
You have to use two cobol programs.
Step1:Write the cobol program(2) which contains cobol READ and WRITE commands.
Step2:a.Write cobol program(1) in which you have to write the entire JCL
to compile the cobol program(2)and display that in spool.
b.Use ACCEPT to accept the DSNNAME.
c. Put a,b in a loop.
Step3: Write the main JCL with INTRDR and pass the list of
DSNNAMES thru SYSIN DD.
Corrections and suggestions welcome.
Gowri |
|
Back to top |
|
|
new2cobol
New User
Joined: 04 Jan 2006 Posts: 77 Location: Bangalore
|
|
|
|
Hey Dave,
Let me explain my problem a bit.
I have this input file which has 200 - 300 million records. I need to format them and load them to a storage. The Data storage to which I load the file, can accept only files of X size. So I have to load a file which has 20 million records max.
So I open the file reformat the record and write it in to a new output file. When the count reaches 20 million, I close the output file and allocate a new file, open it and start writing into it.
Now I've done all these with assembler utilities which my shop provides, but the job takes a hell lot of time to run. So what I need to do is use COBOL WRITE keyword to reduce the CPU time it takes.
Now I can declare one file, say file01 and declare it in JCL as
Code: |
//DD1 DD DSN=A.B.C.FILE01,...
|
And have corresponding cobol File control and file sections as
Code: |
SELECT OUTFILE ASSIGN TO DD1
....
....
FD OUTFILE
RECORDING MODE IS F.
01 OUTREC.
05 FILLER PIC X(133).
|
Now, I successfully write in 20 million records and close this file. I dynamically allocate another file with my assembler utility, viz. A.B.C.FILE02. Now to access the new file using the same FD, the JCL DD1 statement should point to A.B.C.FILE02.
OR
I should have some way to dynamically code an FD statement while the code is in execution.
I guess you all got a gist of my problems ... Whacking my head for a solution... |
|
Back to top |
|
|
new2cobol
New User
Joined: 04 Jan 2006 Posts: 77 Location: Bangalore
|
|
|
|
Gowri,
With all due respect, I did not understand what you were trying to explain here...
Is it that I couldn't comprehend what you keyed in or did you completely miss the target? |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
new2cobol,
I think I understand what you are trying to accomplish now.
In your Assembler subroutine, when you allocate a new file, you must also have to give it a DDNAME to access it through? i.e.
CALL 'ALLOC' USING 'DDNAME','YOUR.OUTPUT.FILE'. ?
Two solutions come to mind.
If your shop has an allocate subroutine, it probably has a de-allocate subrotine also.
After Closing the first file, de-allocate it, allocate the second file to DD1, re-open and continue.
or, if a de-allocate routine is not available,
After closing the first file, Allocate the second file to DD2, use the subroutine above to re-assign the FD to DD2, open and continue.
or am I again missing something?
Please come back, I'm sure this is solvable.
Dave |
|
Back to top |
|
|
new2cobol
New User
Joined: 04 Jan 2006 Posts: 77 Location: Bangalore
|
|
|
|
Yes Dave, I am passing the DDNAME and File name to the assembler utility. Let me check upon the "de-allocate" options I have
Thanks a lot for the response!!! |
|
Back to top |
|
|
new2cobol
New User
Joined: 04 Jan 2006 Posts: 77 Location: Bangalore
|
|
|
|
Dave. Sir.
YOU ARE A LIFE-SAVER!!!
The second option you provided worked ! Now let me get some info from you...
The "DCB" you coded was the 248 char long was the FD section argument, which has the DD name at two places... what does the fillers include? is it file name? |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
New2cobol,
I followed your query about PUTENV. I think this will suit you to a ?T?. The routine I gave you is old and was designed to re-assign the DDNAME only. The PUTENV subroutine is new with Enterprise Cobol. I just tried this and it does work well. Follow the code in the Other Post by dmmadsen.
Check this link for other allocation options for PUTENV
Assignment name for environment variable
If you have trouble with it, or have questions, please come back.
Well, come back anyway and let us know how it works for you.
Good luck,
Dave |
|
Back to top |
|
|
salehi
New User
Joined: 30 Sep 2006 Posts: 14 Location: Iran
|
|
|
|
Hi,
This can be done using some integration between COBOL and PL1 or any other program which is able to change the DD statement dynamically through using ISPF command.
Your program shoukd CALL the second program which change the DD statement dynamically anywhere he needs.
Try using INTEGRATION techniques .. |
|
Back to top |
|
|
lohithegde
New User
Joined: 18 May 2008 Posts: 31 Location: Chennai
|
|
|
|
Hi New2Cobol
Normally we wont change the FIlenames in Cobol,and we will try to change in JCL
To change in JCL Dynamically we use Rexx to do that
Regards
Lohit |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello salehi,
It is best to reply to current topics rather than a topic that has been inactive for almost 3 years. . .
d |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
I use BPXWDYN for this. It's similar to putenv but I have less trouble with it and you don't have to worry about the dynamic vs static call to putenv. |
|
Back to top |
|
|
mfguy01
New User
Joined: 06 Sep 2010 Posts: 30 Location: India
|
|
|
|
Hi,
I went through this thread to work on one of requirements and had 2 queries :-
1.
For David,
Its about dynamically changing dd name.I used routine provied by you(I.e. program CHGDDN & its call) and want info that how its working....i m not getting it neither from first look nor from executing it(though its working fine if used with one file only).
2. As per my requirement,we had 2 file with same record structure and LRECL.File1 is opening in input mode and file 2 is in output mode.Now using CHGDDN,file1 is opened successfully but its not opening file2 in output mode and giving status code 41.
Then I placed DISPLAY statements in CHGDDN before & after MOVE statements to check whether its processing with correct file.DISPLAY results showed that file2 is received by parameters(I.e. NEW-DDNAME,DDNAME2 & DDNAME).Now I m not aware of backend process so couldn't dig more in it.So need to help. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
This topic has been happily dormant for 21 months.
If you have a question, please start a new topic. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
And it has been nearly 4 years since David last posted. . . |
|
Back to top |
|
|
|