View previous topic :: View next topic
Author
Message
senjay Active User Joined: 10 May 2007Posts: 147 Location: India
Hi,
Could you please clarify how can the below requirement be solved in DFSORT?
Input:
A1
B2
C3
A4
C5
C6
B7
C8
C9
.
.
.
.
Output:
C3
C8
Only the record C (and only one) which is after B record should be selected.
I know this can be easily done through PL/1 or COBOL programs. But still curious to know how to handle in DFSORT?
Back to top
karthikr44 Active User Joined: 25 Aug 2007Posts: 235 Location: Chennai
Hi senjay,
The follwoing JCL will give u the solution.
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=DEV2.RK.TEST.REC80,DISP=SHR
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5,)),DISP=(MOD,PASS)
//OUT DD DSN=DEV2.RK.TEST.REC80.OUT,DISP=SHR
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(OUT) ON(81,8,CH) LASTDUP USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,1,SS,EQ,C'B,C')
OUTREC OVERLAY=(81:SEQNUM,8,ZD)
/*
//CTL2CNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,1,CH,EQ,C'B'),
OVERLAY=(81:+1,ADD,81,8,ZD,M11,LENGTH=8))
OUTFIL FNAMES=OUT,BUILD=(01,80)
/*
Sample input:
Code:
A1
B2
C3
A4
C5
C6
B7
C8
C9
Output i got:
Regards
R KARTHIK
Back to top
senjay Active User Joined: 10 May 2007Posts: 147 Location: India
Hi karthik,
Thanks for your reply. But I afraid your solution won't work. Please go through the below case.
Input:
A1
B2
C3
A4
C5
C6
B7
C8
C9
B3
B4
A3
C0
.
.
.
Required output:
C3
C8
But your code will give the output as below
C3
C8
C0
C0 should not come as the previous record of C0 is not starting with B.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Senjay,
Quote:
C0 should not come as the previous record of C0 is not starting with B.
This is happening as Karthik had included only records with either 'B' or 'C' as per the first control card. hence A3 would be removed and it would be like
B4
C0 ( no A3 as it is removed)
Back to top
karthikr44 Active User Joined: 25 Aug 2007Posts: 235 Location: Chennai
Hi senthil,
Then u can use following JCL for the desired results.
Code:
//S1 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=DEV2.RK.TEST.REC80,DISP=SHR
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5,)),DISP=(MOD,PASS)
//OUT DD DSN=DEV2.RK.TEST.REC80.OUT,DISP=SHR
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(OUT) ON(81,8,CH) LASTDUP USING(CTL2)
/*
//CTL1CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD)
/*
//CTL2CNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,1,CH,EQ,C'B'),
OVERLAY=(81:+1,ADD,81,8,ZD,M11,LENGTH=8))
OUTFIL FNAMES=OUT,INCLUDE=(1,1,CH,EQ,C'C'),BUILD=(01,80)
/*
//*
Regards
R KARTHIK
Back to top
senjay Active User Joined: 10 May 2007Posts: 147 Location: India
Aaru wrote:
Quote:
This is happening as Karthik had included only records with either 'B' or 'C' as per the first control card
Yup. I agree.
Hi Karthik,
Thanks. Let me go through the solution and get back to you.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Karthik,
Quote:
Then u can use following JCL for the desired results.
Perfect and a quick turn around time. Hope it works for all scenarios.
Also i think there is no need of the first control card (CTL1CNTL) as your overlaying the sequence no again in the second control card for all input records.(WHEN=INIT).
I have modified your JCl a bit. Check if this would work.
Code:
//TOOLIN DD *
SELECT FROM(IN1) TO(OUT) ON(81,8,CH) LASTDUP USING(CTL1)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,1,CH,EQ,C'B'),
OVERLAY=(81:+1,ADD,81,8,ZD,M11,LENGTH=8))
OUTFIL FNAMES=OUT,INCLUDE=(1,1,CH,EQ,C'C'),BUILD=(01,80)
/*
Back to top
senjay Active User Joined: 10 May 2007Posts: 147 Location: India
Aaru,
Great. i just modified it and thought of posting. But you did it ahead of me.
Karthik,
Thanks for your solution and time.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
senjay,
Quote:
Great. I just modified it and thought of posting. But you did it ahead of me.
Thanks. Fastest finger first .
Back to top
karthikr44 Active User Joined: 25 Aug 2007Posts: 235 Location: Chennai
Hi,
Thanks for sharing optimised coding style.
Regards
R KARHTIK
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
With z/OS DFSORT V1R5 PTF UK90013 (July, 2008), you can do this much more easily and efficiently with the new WHEN=GROUP function like this:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'B'),
PUSH=(81:SEQ=8))
OUTFIL INCLUDE=(1,1,CH,EQ,C'C',AND,81,8,ZD,EQ,2),
BUILD=(1,80)
/*
For complete details on the new WHEN=GROUP function and the other new functions available with PTF UK90013, see:
Use [URL] BBCode for External Links
Back to top
Please enable JavaScript!