View previous topic :: View next topic
|
Author |
Message |
sreekanth1984
New User
Joined: 23 Mar 2010 Posts: 22 Location: Bangalore
|
|
|
|
Please advice me on below.
1.How to read the PS file in reverse order using cobol program.
My Answer: Read the file till end of the file reached, and store into a array. Display the last record from the array first.
2. Interviewr: What is temporary data set?
My Ans: Temporary dataset which is deleted automatically after successful completion of job.
Interviewr: In case of unsuccessful completion of job what will happened to dataset.
My Ans: Data set will be deleted even after unsuccess ful completion of job.
Interviewr: I have a job where three steps are exist in the JCL. First two steps are using tempoary data sets and step3 is using the data set created in previous steps. After completion of step2 job got abended, I want to see the certain record in temporary data set, How?
3. Cobol program A is calling B statically. B is calling C statically and D dynamically.
Scenario1: In subprogram D some changes has been made. How many programs need to be compiled and how many load modules will be generated?
Scenario2: In subprogram C some changes has been made. How many programs need to be compiled and how many load modules will be generated? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
1.How to read the PS file in reverse order using cobol program.
My Answer: Read the file till end of the file reached, and store into a array. Display the last record from the array first.
|
You are not reading ps in reverse order. Actually you can not.
You are presenting results in reverse order. |
|
Back to top |
|
|
sreekanth1984
New User
Joined: 23 Mar 2010 Posts: 22 Location: Bangalore
|
|
|
|
Hi Sambhaji,
Thanks for ur quick reply.
Can you provide ur comments on questions 2 and 3.
One more question is
Can we read the PS file using relative record number in a COBOL program? I don't have access to Mainframe. Otherwise I would have tried this one?
Thanks
Srikanth |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
sreekanth1984 wrote: |
Can we read the PS file using relative record number in a COBOL program? |
Never heard of such a thing for PS datasets. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Can we read the PS file using relative record number in a COBOL program? |
PS means physical sequential. There is no relative record number to use in COBOL to read the file. |
|
Back to top |
|
|
ajay_diaz Warnings : 1 New User
Joined: 12 Sep 2005 Posts: 28
|
|
|
|
Regarding Question 2,
It's not possible to view the contents of the temporary datasets. Temp dataset gets deleted once the job is over.
For debugging, the temporary dataset can be copied to the DASD dataset and the records in it can be viewed. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
sreekanth1984 wrote: |
1.How to read the PS file in reverse order using cobol program. |
If only given option is COBOL it cann't be done. As you said, it's a sequential file - you have to read each record one-by-one. COBOL READ verb does a sequentail read, one-record-per-read - there is no magic trick to reach at last record in first read (unless you have only one record in the file ).
However, if SORT can be an option, you can use that. If you have File-aid, you can use the below job to read the "x" records from bottom and then use the output from this as an input to COBOL program Code:
Code: |
//COPYREC EXEC PGM=FILEAID
//DD01 DD DSN=..input file,DISP=SHR
//DD01O DD DSN=...reversed.recds,DISP=(,CATLG,DELETE),
// DCB=*.DD01
//SYSIN DD *
$$DD01 COPYBACK OUT=X
//SYSPRINT DD SYSOUT=A |
Quote: |
2. Interviewr: What is temporary data set? |
By Definition, your answer is correct.
Quote: |
Interviewr: In case of unsuccessful completion of job what will happened to dataset. |
It depends, in which step &&TEMP DSN is created. If the job abends before the step in which &&temp was created - ofcourse it' not created nor deleted.
Quote: |
Interviewr: I have a job where three steps are exist in the JCL. First two steps are using tempoary data sets and step3 is using the data set created in previous steps. After completion of step2 job got abended, I want to see the certain record in temporary data set, How? |
What was your answer?
Quote: |
3. Cobol program A is calling B statically. B is calling C statically and D dynamically.
Scenario1: In subprogram D some changes has been made. How many programs need to be compiled and how many load modules will be generated?
Scenario2: In subprogram C some changes has been made. How many programs need to be compiled and how many load modules will be generated? |
Your answers, please? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
ajay_diaz wrote: |
Regarding Question 2,
For debugging, the temporary dataset can be copied to the DASD dataset and the records in it can be viewed. |
Copied from where, the job has abended and the temporary dataset has gone.
Perhaps you really meant to say that the allocation should be made permanent for debugging purposes. |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
sreekanth1984 wrote: |
1.How to read the PS file in reverse order using cobol program. |
If the RECFM is F(ixed), then, according to the Enterprise COBOL Language Reference, you can:
1) Copy the file to a TAPE device ( single reel only ).
2) In the COBOL program, OPEN INPUT Tape-File REVERSED
The first READ will retrieve the LAST record, and each subsequent READ will retrieve the next Previous record.
The manual says:
When REVERSED is specified, OPEN statement execution positions the QSAM file at its end. Subsequent READ statements make the data records available in reversed order, starting with the last record. When OPEN REVERSED is specified, the record format must be fixed.
and
REVERSED is Valid only for sequential single-reel files. REVERSED is not valid for VSAM files. If the concept of reels has no meaning for the storage medium (for example, a direct access device), the REVERSED and NO REWIND phrases do not apply. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Nice shot Ronald! |
|
Back to top |
|
|
sreekanth1984
New User
Joined: 23 Mar 2010 Posts: 22 Location: Bangalore
|
|
|
|
Hi All,
Thanks for your inputs.
Quote: |
It depends, in which step &&TEMP DSN is created. If the job abends before the step in which &&temp was created - ofcourse it' not created nor deleted. |
What will happened to temporary data set if the job got abended once the step creating temporary data set executed.
Quote: |
Quote: |
Interviewr: I have a job where three steps are exist in the JCL. First two steps are using tempoary data sets and step3 is using the data set created in previous steps. After completion of step2 job got abended, I want to see the certain record in temporary data set, How? |
What was your answer? |
I didn't give any answer for this.
Quote: |
Quote: |
3. Cobol program A is calling B statically. B is calling C statically and D dynamically.
Scenario1: In subprogram D some changes has been made. How many programs need to be compiled and how many load modules will be generated?
Scenario2: In subprogram C some changes has been made. How many programs need to be compiled and how many load modules will be generated? |
Your answers, please? |
My Answers:
For Scenario1:
Only program D needs to be recomplied and no. of load modules generated is one.
For Scenario1:
Programs A,B,C need to be recompiled and no. of load modules generated are three. |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
sreekanth1984 wrote: |
Quote: |
3. Cobol program A is calling B statically. B is calling C statically and D dynamically.
Scenario1: In subprogram D some changes has been made. How many programs need to be compiled and how many load modules will be generated?
Scenario2: In subprogram C some changes has been made. How many programs need to be compiled and how many load modules will be generated? |
Your answers, please?
My Answers:
For Scenario1:
Only program D needs to be recomplied and no. of load modules generated is one.
For Scenario1:
Programs A,B,C need to be recompiled and no. of load modules generated are three. |
For Scenario1 - Your answer is correct
For Scenario2 - The FIRST part of your answer, though not exactly correct, is probably the answer the interviewer ( erroneously ) expects is the correct answer. In reality, only program C needs to be recompiled, then the static executable containing programs A, B, and C needs to be re-link-edited or re-bound ( depending on which method you are using to create your executable ) to replace program C in that executable.
The SECOND part of your answer is incorrect - you should only generate ONE executable - the Static executable containing programs A, B, and C. |
|
Back to top |
|
|
|