View previous topic :: View next topic
Author
Message
Senthilkumar k Warnings : 1 New User Joined: 07 May 2009Posts: 51 Location: Chennai
Hi I have requirement like below, could anyone help me to write sort for this,
Input file1,
1010
2020
3030
Input file2,
1010001
1010002
.
.
1010999
2020001
.
.
2020999
3030001
.
.
3030999
Output,
1010 2020 3030
-------- --------- ------
001 001 001
002 002 002
. . .
. . .
. . .
999 999 999
(input File 1 should come as header)
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Do you always have THREE input records, or can there be different numbers of input records (if so, what is the maximum number)?
What is the RECFM and LRECL of the input file? What RECFM and LRECL do you want for the output file?
Back to top
Senthilkumar k Warnings : 1 New User Joined: 07 May 2009Posts: 51 Location: Chennai
Input record(max = 5) may differ everytime...but it will always have 4 char(eg: 1010).
Input
RECFM = VB
LRECL = 656
Output
RECFM = FB
LRECL = 80
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Hmmm ... now that I look at this some more, I'm a bit confused.
What is the relationship between file1 and file2? Do the keys in file match the keys in file2 one for one? Why do you need to use file1 at all if the keys are available in file2? Given each key in file1, why couldn't you just generate the columns for each key with the seqnos. Why would you even need file2?
You need to do a better job of explaining what you're trying to accomplish.
Back to top
Senthilkumar k Warnings : 1 New User Joined: 07 May 2009Posts: 51 Location: Chennai
Hi Frank, I will explain you my reuirement clealy with example,
Please leave(not reuired) the input file 1.
Say We have only input file 2, it is having record like below,
5252001
5252003
5252008
2323018
2323079
.
.
.
I need output like below,
5252 2323 . .
------ ------- -----------
001 018 .
003 079 .
008 .
I think this would be clear for you.
Back to top
sqlcode1 Active Member Joined: 08 Apr 2010Posts: 577 Location: USA
Senthilkumar k,
Here is one way to get expected results with multiple pass. I tried to reduce number of pass but no luck
Assumption :- Input and Output are FB 80.
Question :- Do you really need those dash lines '-' in the output?
Code:
//STEP01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
SPLICE FROM(T1) TO(T2) ON(81,2,CH) WITHANY KEEPNODUPS -
WITH(09,08) WITH(17,08) WITH(25,08) WITH(33,08)
COPY FROM(T2) TO(OUT) USING(CTL2)
/*
//IN DD *
5252001
5252003
5252008
2323018
2323079
1111001
1111002
1111003
2222001
2222002
2222003
2222004
3333001
3333002
3333003
3333004
3333005
3333006
3333007
3333008
3333009
3333010
/*
//OUT DD SYSOUT=*
//T1 DD DSN=&&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//T2 DD DSN=&&T2,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//CTL1CNTL DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,2,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=GROUP,BEGIN=(81,2,ZD,EQ,1),PUSH=(83:ID=2))
OUTREC IFTHEN=(WHEN=(83,02,ZD,EQ,01),BUILD=(1,7,80:X,81,2)),
IFTHEN=(WHEN=(83,02,ZD,EQ,02),BUILD=(08X,09:1,7,1X,80:X,81,2)),
IFTHEN=(WHEN=(83,02,ZD,EQ,03),BUILD=(16X,17:1,7,1X,80:X,81,2)),
IFTHEN=(WHEN=(83,02,ZD,EQ,04),BUILD=(24X,25:1,7,1X,80:X,81,2)),
IFTHEN=(WHEN=(83,02,ZD,EQ,05),BUILD=(32X,33:1,7,1X,80:X,81,2))
OUTFIL FNAMES=T1,BUILD=(1,84)
/*
//*
//CTL2CNTL DD *
OPTION COPY
OUTFIL REMOVECC,
HEADER1=(01,04,1X,09,04,1X,17,04,1X,25,04,1X,33,04,80:X,/,
C'----',1X,C'----',1X,C'----',1X,C'----',1X,C'----',80:X),
BUILD=(1X,05,03,2X,13,03,2X,21,03,2X,29,03,2X,37,03,80:X)
/*
//*
OUTPUT
Code:
5252 2323 1111 2222 3333
---- ---- ---- ---- ----
001 018 001 001 001
003 079 002 002 002
008 003 003 003
004 004
005
006
007
008
009
010
Thanks,
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
sqlcode1 has the right idea, but you don't need three passes - you can do it in one pass and a bit more simply with this DFSORT/ICETOOL job:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
5252001
5252003
5252008
2323018
2323079
1111001
1111002
1111003
2222001
2222002
2222003
2222004
3333001
3333002
3333003
3333004
3333005
3333006
3333007
3333008
3333009
3333010
//OUT DD SYSOUT=*
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(81,2,CH) WITHANY KEEPNODUPS -
WITH(9,8) WITH(17,8) WITH(25,8) WITH(33,8) USING(CTL1)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,2,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=GROUP,BEGIN=(81,2,ZD,EQ,1),PUSH=(83:ID=2)),
IFTHEN=(WHEN=(83,2,ZD,EQ,2),OVERLAY=(9:1,7,1:8X)),
IFTHEN=(WHEN=(83,2,ZD,EQ,3),OVERLAY=(17:1,7,1:16X)),
IFTHEN=(WHEN=(83,2,ZD,EQ,4),OVERLAY=(25:1,7,1:24X)),
IFTHEN=(WHEN=(83,2,ZD,EQ,5),OVERLAY=(33:1,7,1:32X))
OUTFIL FNAMES=OUT,REMOVECC,
HEADER1=(1,4,X,9,4,X,17,4,X,25,4,X,33,4,/,
4C'-',X,4C'-',X,4C'-',X,4C'-',X,4C'-'),
BUILD=(X,5,3,2X,13,3,2X,21,3,2X,29,3,2X,37,3,80:X)
/*
Back to top
Senthilkumar k Warnings : 1 New User Joined: 07 May 2009Posts: 51 Location: Chennai
Thanks sqlcode and frank....Both codes are working fine...
Back to top
sqlcode1 Active Member Joined: 08 Apr 2010Posts: 577 Location: USA
Frank,
Thanks for the correction.
Initially, I tried to use the single pass but it didn't work . I realized my mistake after going through your card.
Thanks,
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Yes, you can do a lot before and after SPLICE with DFSORT statements in xxxxCNTL. But your approach was good!
Back to top
Please enable JavaScript!