View previous topic :: View next topic
|
Author |
Message |
antonrino.b
New User
Joined: 10 Jan 2006 Posts: 76 Location: Germany
|
|
|
|
Hi,
I need to group the records by a particular field, and get the no. of records per group.
For eg.
I have the input file with layout as below:
Code: |
SER-NO PIC 9(3).
FILLER PIC X(1).
DEP-ID PIC 9(3).
FILLER PIC X(1).
SUB-DIV PIC 9(3).
001 111 100
002 111 100
003 111 110
004 222 100
005 222 100
006 222 110 |
The output, i would like to have is
Code: |
111 100 2 (no. of records with 111 100)
111 110 1 (no. of records with 111 110)
222 100 2
222 110 1 |
Is this possible with DFSORT? |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
antonrino.b,
Use the following DFSORT JCL
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
001 111 100
002 111 100
003 111 110
004 222 100
005 222 100
006 222 110
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(5,7,CH,A)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(5,7,TRAILER3=(5,7,X,COUNT=(M10,LENGTH=3)))
/* |
|
|
Back to top |
|
|
antonrino.b
New User
Joined: 10 Jan 2006 Posts: 76 Location: Germany
|
|
|
|
Hi kolusu,
Thanks for your instant reply. it worked fine. :-) |
|
Back to top |
|
|
Sachinrethin
New User
Joined: 12 Oct 2007 Posts: 21 Location: Chennai
|
|
|
|
Hi ,
I tried the below piece of control card and got the output.
Code: |
INREC OVERLAY=(81:C'1')
SORT FIELDS=(5,7,CH,A)
SUM FIELDS=(81,1,ZD)
OUTREC FIELDS=(5,7,X,81,1)
|
|
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Sachinrethin,
This works, but I think it's not as efficient as Kolusu's since he does n't have an INREC pass. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
sachinretin,
what happens if you have more than 9 duplicates? you are just summing on 1 byte field. Run your job using this input and see if you got the results correctly. Run the same job using the control cards I provided and notice the difference.
Code: |
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
002 111 100
003 111 110
004 222 100
005 222 100
006 222 110
|
|
|
Back to top |
|
|
Sachinrethin
New User
Joined: 12 Oct 2007 Posts: 21 Location: Chennai
|
|
|
|
Hi,
I agree with your point. so it is always better to have the counter as 9 digits. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Sachinrethin,
Apart from the count being 9 bytes , you are doing an additional pass with INREC. For FB files it is ok but for variable block files adding a counter at the end of every record would be nullifying the whole variable block concept. |
|
Back to top |
|
|
|