Write a JCL by using the below requirement:
File1 =1, File2 =11 and output needs to come as File3 =111?
Answers were Sorted based on User's Feedback
Answer / mdv
Step 1.
Add SEQNUM for both the files @ positions 3 to 8 and 2 to 7
respectively.
Step 2.
Join based on key and reformat as needed.
// SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(3,6,A)
JOINKEYS FILE=F2,FIELDS=(2,6,A)
REFORMAT FIELDS=(F1:1,2,F2:1,1)
SORT FIELDS=COPY
/*
Note: Not tested.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / sathish kumar chandra sekaran
//D362967J JOB (UBS-UBS-D362967-XXX-999),CLASS=C,
// MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=D362967
//STEP1 EXEC PGM=SORT
//SORTIN DD *
1
/*
//SORTOUT DD DSN=D362967.TEST.PS3,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSDUMP DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:1,8,60:SEQNUM,3,ZD,START=1,INCR=2)
/*
//STEP2 EXEC PGM=SORT
//SORTIN DD *
11
/*
//SORTOUT DD DSN=D362967.TEST.PS4,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSDUMP DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:C'1',2:1,8,60:SEQNUM,3,ZD,START=2,INCR=2)
/*
//STEP3 EXEC PGM=SORT
//SORTIN DD DSN=D362967.TEST.PS3,DISP=SHR
// DD DSN=D362967.TEST.PS4,DISP=SHR
//SORTOUT DD DSN=D362967.TEST.PS5,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSDUMP DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(60,3,CH,A)
/*
//STEP4 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=D362967.TEST.PS5,DISP=SHR
//OUT1 DD SYSOUT=*
//TOOLIN DD *
SPLICE FROM(IN1) TO(OUT1)-
ON(1,1,CH) KEEPNODUPS WITH(2,2)
/*
This will meet your requirement.
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / nishant singhal
we can do it by cobol pgm also.
File1=1,file2=11 and
fd file3
01 file3-rec
05 ws1 pic 9(1) value zero.
05 ws2 pic 9(2) value zero.
open file1 in inpute mode and write the record in file3
which is opened in output mode. Now open file2 in input and
file3 in IO mode and update the record.
I think it should work.
Muttiah, would you suggest any better approach by using JCL
thn please share with us. Thanks
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / muttiah
Nishant,
Thanks for your answer. It's a correct approach to achieve
the result as '111' in file 3..
I'm not sure how this can be done in JCL.
Can someone suggest how this can be achieved.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ram mohan
@MDV:
I have tested the code. but it's giving Maxcc - 16. Can you
please give us the exact JCL. I feel Joinkeys are not
supporting in the sort which we are using.
thanks in advance.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / msharib
One can try this
//STEP2 EXEC PGM=SORT
//IN1 DD *
1
/*
//IN2 DD *
111
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=IN1,FIELDS=(1,1,A)
JOINKEYS F2=IN2,FIELDS=(1,1,A)
REFORMAT FIELDS=(F1:1,1,F2:1,3)
OPTION COPY
/*
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / muttiah
@satish:
I'm not sure on what basis you have created this jcl. But
if i'm your interviewer i would have blasted you like
anything.
Findings:
1. step1 output will be 1 in postion 1 followed by 001 in
pos 60 - 62.
2. step2 output will be 111 in position 1-3 followed by 002
in pos 60-63. why the hell are you hardcoding sortin in
both the steps and sortout of step2 you are force fully
making it come as '111' because of this
OUTREC FIELDS=1:C'1',2:1
Then what is the case of having step1 if you force fully
making it as '111'..
Coming to step4: i'm not sure what does it mean but i
executed and saw like the output is in this format.
111 in pos 1-3 and 001 in pos 60-62.
Then where are you eliminating 001 in cols 60.
If you are not sure of the answer don't post anything. But
never divert people with your answers. People who are new
to mainframe can feel your answer is correct.
| Is This Answer Correct ? | 0 Yes | 3 No |
What is the use of disp parameter?
How do You skip a Step In JCL?
What is the difference between Sysin,Sysout,Sysdbout and Sysudump?
Is acct parameter mandatory?
Explain about LMQUERY�give a dialog information about a data set
In all our JOB Statement we have always COND=(4,LT) defined. Nevertheless when a Job failed the last step should then be executed (send a message to an user). Due to we don't like to change all our JOB's (ca. 2000), we are looking for a simply solution.
Is condition checking possible in jcl? If yes, how?
what is the compile process of cobol program expalin with code
How to rename a VSAM file as well as it's index file?
How to execute step2,step1,step3 when step1,2&3 are in order
what happens in conversion stage in job processing?
I have 10 steps, I want to run STEP1 TO STEP4 then I should not run STEP5 and STEP6. Aganin I want to execute from STEP7 to STEP10. ONLY using CONDITION CODES how can we execute this process? 1. Where we can set cond codes for STEP5 and STEP6? 2. How can we execute remaining steps from STEP7 to STEP10?