Page 1 of 1

Count duplicates

PostPosted: Tue Sep 04, 2012 3:23 pm
by JorenWillems
Hi

I want to count the duplicates and put them in an output file.

Input file = VB, RECL=30713
Pos 97,9
LASNF008A   
LISNN007C   
LISNN007C   
LISNN014C   
LISNN014C   
LLSNF069B   
LLSNF069B   
LIPNF009B   
LIPNF009B 
LIPNF009B 
LASNF021A   
LASNF021A   


Wanted output FB:

LISNN007C     2
LISNN014C     2
LLSNF069B     2
LIPNF009B     3   
LASNF021A     2


I tried this but it doens't work. Help me please.

SORT FIELDS=(97,9,CH,A)                       
OUTFIL REMOVECC,NODETAIL,                     
       BUILD=(104X),                           
       OUTREC=(97,104),                       
       SECTIONS(97,9,                         
          TRAILER3=(97,9,COUNT=(EDIT(TTTTT))))

Re: Count duplicates

PostPosted: Tue Sep 04, 2012 3:52 pm
by BillyBoyo
Can you show in which particular way it doesn't work?

I assume it is the keys which are duplicat?

Re: Count duplicates

PostPosted: Tue Sep 04, 2012 3:55 pm
by JorenWillems
I have following abend when executing the jcl:

ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 11:53 O
               SORT FIELDS=(97,9,CH,A)                                 
               OUTFIL REMOVECC,NODETAIL,                               
                      BUILD=(104X),                                     
                      OUTREC=(97,104),                                 
                      $                                                 
ICE214A 0 DUPLICATE, CONFLICTING, OR MISSING OUTFIL STATEMENT OPERANDS 
                      SECTIONS(97,9,                                   
                      $                                                 
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY   
                         TRAILER3=(97,9,COUNT=(EDIT(TTTTT))))           
                         $                                             
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY

Re: Count duplicates

PostPosted: Tue Sep 04, 2012 4:28 pm
by BillyBoyo
What are you trying to do with BUILD and OUTREC?

You have huge records. I don't know how many, but if there is only a small sub-set of data you need, you should cut down the record to that data as soon as you can.

  INREC BUILD=(97,9,C'0000001')
  SORT FIELDS=(1,9,CH,A)
  SUM FIELDS=(10,7,ZD)


By adding a constant of value 1, and summing on that field, you get the keys and counts on the output.

Re: Count duplicates

PostPosted: Tue Sep 04, 2012 10:17 pm
by skolusu
JorenWillems,

Here is a DFSORT JCL which will give you the desired results. The output will be a 80 byte FB file. I also assumed that your input key is at position 97 including the RDW.

//STEP0100 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD DISP=SHR,DSN=Your input VB file
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                               
  INREC BUILD=(1,4,97,9)                     
  SORT FIELDS=(5,9,CH,A)                     
  OUTFIL VTOF,REMOVECC,NODETAIL,BUILD=(80X), 
  SECTIONS=(5,9,TRAILER3=(5,9,COUNT))         
//*     


Billy boyo,

Since his input is a VB file , you need to have the RDW on the build statement or else you will get an ICE251A about missing RDW.

Re: Count duplicates

PostPosted: Tue Sep 04, 2012 10:24 pm
by BillyBoyo
Sorry, slack of me. Must have copied the wrong JCL... Problem with having "identical" file names except for FB or VB. Not so much to change, but have to remember to actually change it... :-)