View previous topic :: View next topic
Author
Message
pavanchandana New User Joined: 05 Sep 2008Posts: 15 Location: Hyderabad
Hi,
Here is my requirement. Input file (FB, Lrecl=80) looks like this:
001 51531324154 NYC
001 51531346454 NYK
001 51531322323 NYC
003 51531324154 NYB
007 51456424154 NYC
007 51531345454 NY3
007 51531345454 NYC
007 51545645644 NYC
Here considering positions 1-3 as key, my requirement is to count the number of occurences of the record. And the count should be appended to the end of the record in the output file.(FB, Lrecl = 82)
Output file should look like:
001 51531324154 NYC 03
001 51531346454 NYK 03
001 51531322323 NYC 03
003 51531324154 NYB 01
007 51456424154 NYC 04
007 51531345454 NY3 04
007 51531345454 NYC 04
007 51545645644 NYC 04
Could nyone pls help me out on this.... Thanks in Advance!!
Back to top
bipinpeter Active User Joined: 18 Jun 2007Posts: 213 Location: Cochin/Kerala/India
Hi pavanchandana,
Here is one way.I dont know any other better way than this.We can do this by two steps.
STEP1
------
//SORTIN DD DSN=infile1
//SORTOUT DD DSN=temfile1
//SYSIN DD *
SORT FIELDS=(17,3,CH,A)
INREC OVERLAY=(21:SEQNUM,3,ZD)
SUM FIELDS=(21,3)
OUTREC FIELDS=(17,7)
/*
STEP2
-------
//SORTJNF1 DD DSN=infile1
//SORTJNF2 DD DSN=tempfile1
//SORTOUT DD DSN=outfile
//SYSIN DD *
SORT FIELDS=(17,3,CH,A)
JOINKEYS FILE=F1,FIELDS=(17,3,A)
JOINKEYS FILE=F2,FIELDS=(1,3,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,80,F2:5,3)
/*
Bipin Peter
Back to top
Escapa Senior Member Joined: 16 Feb 2007Posts: 1399 Location: IL, USA
Hi pavanchandana,
Can you please clarify which sort product you are using?
SYCSORT OR DFSORT?
I suppose DFSORT as it is not in JCL forum.
BIPIN your solution looks like it is for syncsort.
Back to top
pavanchandana New User Joined: 05 Sep 2008Posts: 15 Location: Hyderabad
Hi Sambhaji,
We are using both SYNCSORT and DFSORT products ... so any solution may go fine...
Thank You.
Back to top
Escapa Senior Member Joined: 16 Feb 2007Posts: 1399 Location: IL, USA
Quote:
We are using both SYNCSORT and DFSORT products
quite unusual.......
Back to top
genesis786 Active User Joined: 28 Sep 2005Posts: 210 Location: St Katherine's Dock London
Code:
SORT FIELDS=(17,3,CH,A)
INREC OVERLAY=(21:SEQNUM,3,ZD)
SUM FIELDS=(21,3)
OUTREC FIELDS=(17,7)
if i understand right, pavanchandana's requirement says summing based on the key of the record which is first 3 chars. so the frist sort statement should come somewhat like:
Code:
SORT FIELDS=(1,3,CH,A)
INREC OVERLAY=(21:C'001')
SUM FIELDS=(21,3,ZD)
OUTREC FIELDS=(1,23)
and the second step
Code:
SORT FIELDS=(1,3,CH,A)
JOINKEYS FILE=F1,FIELDS=(1,3,A)
JOINKEYS FILE=F2,FIELDS=(1,3,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,20,F2:21,3)
Back to top
pavanchandana New User Joined: 05 Sep 2008Posts: 15 Location: Hyderabad
Hi all.... Thank you so much for ur response .... Ive got the expected solution from these replies... Thanks again!!
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
If the order of records within a group is not important, then the following DFSORT 1 pass JCL will give you the desired results.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
001 51531324154 NYC
001 51531346454 NYK
001 51531322323 NYC
003 51531324154 NYB
007 51456424154 NYC
007 51531345454 NY3
007 51531345454 NYC
007 51545645644 NYC
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,2,ZD,RESTART=(1,3)))
SORT FIELDS=(1,3,CH,A,81,2,CH,D)
OUTREC IFOUTLEN=82,
IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,2,ZD,RESTART=(1,3))),
IFTHEN=(WHEN=GROUP,BEGIN=(83,2,ZD,EQ,1),PUSH=(81:81,2))
/*
If the order of records within the group is important then the following DFSORT/ICETOOL JCL will give the desired results
Code:
//STEP0200 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
001 51531324154 NYC
001 51531346454 NYK
001 51531322323 NYC
003 51531324154 NYB
007 51456424154 NYC
007 51531345454 NY3
007 51531345454 NYC
007 51545645644 NYC
//T1 DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SORT FROM(T1) USING(CTL2)
//CTL1CNTL DD *
OUTFIL FNAMES=T1,REMOVECC,BUILD=(1,80,3X),
SECTIONS=(1,3,TRAILER3=(1,3,81:COUNT=(M11,LENGTH=2),C'D'))
//CTL2CNTL DD *
SORT FIELDS=(1,3,CH,A,81,2,CH,D)
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(81,2,CH,NE,C' '),PUSH=(81:81,2))
OUTFIL FNAMES=OUT,OMIT=(83,1,CH,EQ,C'D'),BUILD=(1,82)
/*
Back to top
Please enable JavaScript!