Count number of duplicate records

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
go4romel
Member
Posts: 7
Joined: Thu Sep 22, 2011 11:25 pm

Count number of duplicate records

Post by go4romel » Fri Sep 23, 2011 6:16 am

Hi,

I have a file with following records:

S00000 E30000 ABCDE RPP50
S00000 E30001 ABCDE RPP48
S00000 E30001 ABCDE RPP49
S00001 C30000 ABCDE RPP62
S00001 C30000 ABCDE RPP63
S00001 E30000 ABCDE RPP51
S00001 E30001 ABCDE RPP44
S00001 E30001 ABCDE RPP45
S00001 E30001 ABCDE RPP46
S00001 H30000 ABCDE RPP57
S00001 H30000 ABCDE RPP58
S00001 H30000 ABCDE RPP59
S00001 H30000 ABCDE RPP60
S00001 H30000 ABCDE RPP61
S00001 H30001 ABCDE RPP52
S00001 H30001 ABCDE RPP53
S00001 H30001 ABCDE RPP54
S00001 H30001 ABCDE RPP55
S00001 H30001 ABCDE RPP56

I need to get the count in output file as follows:

S00000 E30000 1
S00000 E30001 2
S00001 C30000 2
S00001 E30000 1
S00001 E30001 3
S00001 H30000 5
S00001 H30001 5

please help!!

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Sep 23, 2011 8:01 pm

What have you tried? What happened? Where are you stuck?

What are the recfm and lrecl of the files?
Have a good one

go4romel
Member
Posts: 7
Joined: Thu Sep 22, 2011 11:25 pm

Post by go4romel » Fri Sep 23, 2011 8:27 pm

I used the following but dont what the results in the header and trailer format.
in this case i have to add one more step to remove the headers and trailers,but i want to make it in a single step.

Code: Select all

                               
//STEP10   EXEC PGM=ICETOOL                                          
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//OUTFILE  DD DSN=...(FB\50)                                           
//INFILE   DD DSN=...(FB\279)                     
//TOOLIN   DD   *                                                    
  OCCUR FROM(INFILE) LIST(OUTFILE) -                                 
      HEADER('CAMP') ON(7,12,CH) -                                   
      HEADER('LANG') ON(19,1,CH) -                                   
      HEADER('ZIP')  ON(20,10,CH) -                                  
      HEADER('COUNT') ON(VALCNT,N05)                                 
/*

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Sep 23, 2011 10:31 pm

If you don't want the headers, you can suppress them:

Code: Select all

  OCCUR FROM(INFILE) LIST(OUTFILE) -     
      NOHEADER NOCC-                    
      ON(7,12,CH) -                      
      ON(19,11,CH) -                     
      ON(VALCNT,N05)                     
However, this will result in an output file with RECFM=FB and LRECL=120. If you really need your output to be RECFM=FB and LRECL=50, let me know.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

go4romel
Member
Posts: 7
Joined: Thu Sep 22, 2011 11:25 pm

Post by go4romel » Fri Sep 23, 2011 11:20 pm

Is is possible to have a LRECL = 28 for the output so that it is readable through a copybook?
12+1+10+5 = 28

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Sat Sep 24, 2011 2:47 am

You can use a DFSORT job like the following:

Code: Select all

//S1   EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN  DD DSN=...  input file (FB/279)
//SORTOUT DD DSN=...  output file (FB/28)
//SYSIN    DD   *
  SORT FIELDS=(7,23,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(28X),
    SECTIONS=(7,23,
      TRAILER3=(7,23,COUNT=(EDIT=(IIIIT))))
/*
Last edited by Frank Yaeger on Sat Sep 24, 2011 5:04 am, edited 1 time in total.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

go4romel
Member
Posts: 7
Joined: Thu Sep 22, 2011 11:25 pm

Post by go4romel » Mon Sep 26, 2011 6:59 pm

Thanks a lot Frank!!.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others