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

Select Clause in cobol


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vpr_118
Warnings : 1

New User


Joined: 07 Apr 2008
Posts: 64
Location: chennai

PostPosted: Mon Aug 09, 2010 10:50 am
Reply with quote

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

Moderator Emeritus


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

PostPosted: Mon Aug 09, 2010 10:57 am
Reply with quote

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

Moderator Emeritus


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

PostPosted: Mon Aug 09, 2010 11:00 am
Reply with quote

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

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Aug 09, 2010 1:40 pm
Reply with quote

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

New User


Joined: 07 Apr 2008
Posts: 64
Location: chennai

PostPosted: Mon Aug 09, 2010 5:04 pm
Reply with quote

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Aug 09, 2010 5:37 pm
Reply with quote

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
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 -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top