View previous topic :: View next topic
|
Author |
Message |
devidas-patil
New User
Joined: 08 Jan 2007 Posts: 54 Location: pune
|
|
|
|
Hi all
i have two file and i want to use both the file in the cobol program and both file have the same attribute as well as the same FD entires but allowed me to use only one SELECT INFILE ASSIGN TO DDNAME
i cant
---> use two select statement in my program and
--> i cant merge two file,
--> i can't concatenate two file
what to do in this situation?
please let me know. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Patil,
Quote: |
--> i cant merge two file,
--> i can't concatenate two file |
Why cant? Is there any business reason for this. |
|
Back to top |
|
|
devidas-patil
New User
Joined: 08 Jan 2007 Posts: 54 Location: pune
|
|
|
|
hi murali
this is question of my interviews so oi told him this two option but he was expecting something different than this |
|
Back to top |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
|
|
Quote: |
--> cant use two select statement in my program and
--> i cant merge two file,
--> i can't concatenate two file |
Can you atleast execute the program twice with 2 diff files? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
devidas-patil wrote: |
Hi all
i have two file ...
|
I think the interviewer was talking about one input & one output.
Quote: |
i cant
---> use two select statement in my program and
|
Under the above assumption, one can direct the output to SYSOUT dataset & one'll need only one SELECT statement in COBOL program.
Quote: |
--> i cant merge two file,
--> i can't concatenate two file
what to do in this situation?
|
If Both the files are inputs.. then don't know.
Did you ask about the files usage !? If yes please let me know. Hopefully we can come up with some good idea. |
|
Back to top |
|
|
devidas-patil
New User
Joined: 08 Jan 2007 Posts: 54 Location: pune
|
|
|
|
Hi anuj
i not asked him about the file usage. i am very sure he was asking me both are the input file. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
devidas-patil wrote: |
Hi anuj
i not asked him about the file usage. i am very sure he was asking me both are the input file. |
Hi,
Every file used in COBOL program has to have a SELECT clause, so if both are inputs, then in this situation answer for the question is - not possible. |
|
Back to top |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
|
|
Quote: |
Every file used in COBOL program has to have a SELECT clause |
This is not true and cannot be generalized.
There is no need for SELECT statement in below COBOL code
- From COBOL you can open/close/read using assembler routintes without COBOL SELECT clause
- In IMS COBOL you can read files without COBOL SELECT clause
-In CICS COBOL program there is no need for COBOL SELECT clause |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You might run a step that copies/merges the 2 files into one before executing your program with these strange rules. . . |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
I hope interviewer asked about simple COBOL-batch program, by simple I mean a program which is not using any database. From the window of original question I think I didn't direct the OP in wrong direction.
However, if you can provide some examples or can direct to some link, that would be great to understand your statements rather better.
dick scherrer wrote: |
Hello,
You might run a step that copies/merges the 2 files into one before executing your program with these strange rules. . . |
Dick,
I didn't get your intention here..!? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Anuj,
If the files were combined prior to the COBOL program, the rather non-business "rules" of the question (can't use 2 . . .etc in the COBOL program) might be met.
I just took that work out of the COBOL code to satisfy the "rules" - probably not the best way to approach this, but keeps the 3 "can't"s out of COBOL
There is always the chance that what the interviewer meant to ask and what was understood to be the requirement was not the same. . . Happens quite often when you combine an interviewer with limited technical knowldege with an interviewee with limited experience and especially if they are communicating in a language that is not the "main" language of either one. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Still bounced..!
Let's leave it. |
|
Back to top |
|
|
utkarshtewari
New User
Joined: 26 Mar 2007 Posts: 9 Location: UK
|
|
|
|
Hi Anuj,
Guess what dick is suggesting is that in RUN JCL we need to put a step to merge/sort the two files into one, using Utilities...thus creating a single file to be dealt with in the program...
and in the next JCL step you can execute the program. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Yup, not a way i'd do it if i had the need to process those files, but might get around the non-business requirement mentioned above.
I am fairly sure there is no business reason for the restrictons. . . |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Thanks Utkarsh.
dick scherrer wrote: |
I am fairly sure there is no business reason for the restrictons. . . |
Yeah, I do agree. |
|
Back to top |
|
|
skkp2006
New User
Joined: 14 Jul 2006 Posts: 93 Location: Chennai,India
|
|
|
|
When two different files are used in a program two sets of output files or processing(database updates/deletes) is to be expected.
I would suggest to create a proc which would run the program in step1 and overriding the file in step2 which would run the same proc in a jcl to get the results.
Regards,
Syam |
|
Back to top |
|
|
Johnson_Jiang
New User
Joined: 05 Apr 2007 Posts: 11 Location: China,ShenZhen
|
|
|
|
Hi, Patil,
I think the question is about the run jcl. In your COBOL program, you can use one SELECT statement to handle several input file (same layout, same length), just implement it in JCL like follows:
//INPUTFIL DD DSN=FILE1.XXX,DISP=SHR
// DD DSN=FILE2.XXX,DISP=SHR
// DD DSN=FILE3.XXX,DISP=SHR
:
:
:
So in cobol program, you can use:
SELECT Inputfil-file ASSIGN TO INPUTFIL ....
It works! |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Johnson,
Quote: |
//INPUTFIL DD DSN=FILE1.TTT,DISP=SHR
// DD DSN=FILE2.TTT,DISP=SHR
// DD DSN=FILE3.TTT,DISP=SHR |
Please go through the original post, which says - cant concatenate two files. |
|
Back to top |
|
|
devidas-patil
New User
Joined: 08 Jan 2007 Posts: 54 Location: pune
|
|
|
|
Thanks all!!!!!!!!!!!!! |
|
Back to top |
|
|
Naresh Kumar Reddy P
New User
Joined: 24 May 2007 Posts: 8 Location: Bangalore
|
|
|
|
Probably, the interviewer was expecting DD concatination in your JCL. I believe it is the only way to accept two input files with one select statement in your program (for pure cobol program).
Thanks
Reddy |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Reddy,
Please read the post from the beginning. The initial post post says
Quote: |
--> i can't concatenate two file |
|
|
Back to top |
|
|
kgumraj
Active User
Joined: 01 May 2006 Posts: 151 Location: Hyderabad
|
|
|
|
Hi,
I can imagine only this: Using same DD name for the input files.
When I ran it only took the first input file.
But I didnt get the buisnees in doing so |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Anju,
There's a relatively new feature in COBOL (Eviroment Variables - I think) that allows the coder to change the FD stmt to define a different dataset than the one being currently used. It calls a subroutine "putenv", among other things. It's a fairly involved process.
Another approach is BPXWDYN, an interface to SVC 99.
I haven't used either of these so this is about all I know on the subject. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
If this is for me, then my name is Anuj not Anju
However,coming to the topic of thread..
OP says
so
Quote: |
that allows the coder to change the FD |
will not suffice the requirement of OP. As stated by you, subroutine 'putenv' will allow to change the FD of the same file while OP says
Quote: |
both file have the same attribute as well as the same FD entires |
, so he does not want to open the same file with different layout instead he wants to open a different file with the same layout. In a nutshell, there are two input files, with different data, but with same FD entries and he wants to refer both files with a single SELECT. |
|
Back to top |
|
|
Earl
Active User
Joined: 17 Jun 2007 Posts: 148 Location: oklahoma
|
|
|
|
I think you can only have max of 16 fd's per cobol program. was involved with project years ago that required using same fd in cobol
program. I used a dynamic allocation subroutine to change
the dataset name on the fly and then open/close the file as logically needed.
FD SAME-FD assign SAMEFD
..
..
..
PROCEDURE DIVISION.
MOVE 'MYFILE.FILEONE' TO WS-FILE-NAME.
CALL 'DYDSN' USING WS-FILE-NAME, SAME-FD, 'SAMEFD'.
OPEN INPUT SAME-FD.
READ SAME-FD INTO WS-SAVE-FILEONE-RECORD.
CLOSE SAME-FD.
MOVE 'MYFILE.FILETWO' TO WS-FILE=NAME.
CALL 'DYDSN' USING WS-FILE-NAME, SAME-FILE.
OPEN INPUT SAME-FD
READ SAME-FD INTO WS-SAVE-FILETWO-RECORD.
PERFORM PROCESS-FILE-TWO.
....
...
.... |
|
Back to top |
|
|
|