View previous topic :: View next topic
|
Author |
Message |
vpr_118 Warnings : 1 New User
Joined: 07 Apr 2008 Posts: 64 Location: chennai
|
|
|
|
Hi All,
I have a scenario where there are four files of same attribute (LRECL and RECFM).
Can i Assign all these files to same Label in the DATA DIVISION as below.
SELECT CLOCKFILE ASSIGN TO DD1
SELECT CLOCKFILE ASSIGN TO DD2
SELECT CLOCKFILE ASSIGN TO DD3
SELECT CLOCKFILE ASSIGN TO DD4
Where CLOCKFILE is PIC(100).
Or can we do as below
SELECT CLOCKFILE ASSIGN TO DD1 DD2 DD3 DD4
I guess second is not possible but guess first one is logically correct.
But while processing we have to be very careful.
Please guide me on this.
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Unfortunately, both are incorrect. Neither should successfully compile.
Suggest you use:
Code: |
SELECT CLOCKFILE1 ASSIGN TO DD1
SELECT CLOCKFILE2 ASSIGN TO DD2
SELECT CLOCKFILE3 ASSIGN TO DD3
SELECT CLOCKFILE4 ASSIGN TO DD4 |
If you were considerable more experienced, you might use dynamic allocation, but this will take you much more time than simply coding the routines for each file.
If there is no concern over which file is currently being processed, the 4 files could be concatenated in one DD statement. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
But while processing we have to be very careful. |
Why might this require more care than some other program/requirement? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
vpr_118 wrote: |
Can i Assign all these files to same Label in the DATA DIVISION as below.
SELECT CLOCKFILE ASSIGN TO DD1
SELECT CLOCKFILE ASSIGN TO DD2
SELECT CLOCKFILE ASSIGN TO DD3
SELECT CLOCKFILE ASSIGN TO DD4 |
You said "these files" - that means more than one file, then why do you ask to use the "same name" for all of them, they all are different files - are not they? |
|
Back to top |
|
|
vpr_118 Warnings : 1 New User
Joined: 07 Apr 2008 Posts: 64 Location: chennai
|
|
|
|
Hi,
But while processing we have to be very careful..
Though all the files have same attributes, there might be a requirement where i will process the records in each of them in different manner.
In that case if i read 1st file, and then if i read the 2nd file, the data of 2nd file will present in the File layout (overrides the data of 1st file in the layout which is prescribed in data division).
I mean this was just a case which i thought. There could me many scenarios,
So what i understand is "We can not define or assign four different files though having same attributes to a single layout.
Yes we can concatenate and give that DD name alone in the assign clause.
But as the case mentioned above, where requirement is to process the records in each of file with different logic, then only way out is to have 4 SELECT clauses with their respective layouts.
Thanks Everyone. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
But as the case mentioned above, where requirement is to process the records in each of file with different logic, then only way out is to have 4 SELECT clauses with their respective layouts. |
so little imagination!
have you thought of using an intervening file which would indicate which file follows when you concatenate?
Code: |
//input dd dsn=firstfile.identifier
// dd dsn=firstfile
// dd dsn=secondfile.identifier
// dd dsn=secondfile
...
|
where firstfile.identifier and secondfile.identifier
would be of the same dcb as the the others, contain one record
but would contain info that idicated that this is an identifier file
and that the following file is ... |
|
Back to top |
|
|
|