Count number of records and combine it..



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Count number of records and combine it..

Postby anchal jain » Fri Oct 07, 2011 11:20 am

Hi,
I have a dataset having some records as follows

DEM|JH|I|1234
DEM|JH|I|1235
DEM|JH|O|2115
DEM|FR|I|2536
DEM|FR|O|5264

I want to count the number of records of each type and write them in following format

DEM|JH|2|1
DEM|FZ|1|1

Here the third field is number of records of type 'I' and fourth field is number of records of type 'O'.

I used following JCL

//JBSTEP01 EXEC PGM=SORT                                       
//SORTIN   DD DISP=SHR,DSN=IMAN.FILE1                           
//SORTOUT  DD DSN=IMAN.FILE2,                                   
//         DISP=(NEW,CATLG,DELETE),                                 
//         SPACE=(CYL,(550,500),RLSE),                         
//         UNIT=SYSDA                                           
//SYSOUT   DD SYSOUT=*                                         
//SYSIN    DD *                                                 
 INCLUDE COND=(1,8,CH,EQ,C'DEM|JH|I')                             
 SORT FIELDS=(1,9,CH,A)                                         
 OUTFIL REMOVECC,NODETAIL,                                     
  TRAILER1=('CDEM|JH|',COUNT=(M10,LENGTH=8))                   
//*

This gave me number of records of type 'I' , so I applied same step again for type 'O'.These two different steps output is like
DEM|JH|2
DEM|JH|1
DEM|FZ|1
DEM|FZ|1

but I want both the records to be written in same line as follows the first count should be of type 'I' and second should be of type 'O'.

DEM|JH|2|1
DEM|FZ|1|1

Your help is most appreciated.
Thank you.
anchal jain
 
Posts: 2
Joined: Wed Oct 05, 2011 4:28 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count number of records and combine it..

 

Re: Count number of records and combine it..

Postby Frank Yaeger » Fri Oct 07, 2011 10:32 pm

Your description is very confusing. You are sorting the records but you don't show the output in correct sorted order. You have FR for the input records but you have FZ for the output records.

If I understand what you're trying to do, you can use a DFSORT job like the following:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DEM|JH|I|1234
DEM|JH|I|1235
DEM|JH|O|2115
DEM|FR|I|2536
DEM|FR|O|5264
EEE|XX|I|1111
EEE|XX|I|2222
EEE|XX|I|3333
EEE|XX|O|4444
EEE|XX|O|4444
FFF|BB|I|5555
GGG|BB|O|5555
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'00')),
        IFTHEN=(WHEN=(8,1,CH,EQ,C'I'),OVERLAY=(81:C'1')),
        IFTHEN=(WHEN=(8,1,CH,EQ,C'O'),OVERLAY=(82:C'1'))
  SORT FIELDS=(1,6,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(80X),
    SECTIONS=(1,6,
      TRAILER3=(1,7,TOT=(81,1,ZD,EDIT=(TTTTT)),C'|',
                    TOT=(82,1,ZD,EDIT=(TTTTT))))
/*


SORTOUT would have:

DEM|FR|00001|00001
DEM|JH|00002|00001
EEE|XX|00003|00002
FFF|BB|00001|00000
GGG|BB|00000|00001


If that's not what you want, then you need to do a better job of explaining what you do want.
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

These users thanked the author Frank Yaeger for the post:
ChrisChadwick (Wed Nov 13, 2013 7:38 pm)
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Count number of records and combine it..

Postby anchal jain » Mon Oct 10, 2011 3:35 pm

Thanks a lot Frank. I apologize to make it confusing I will take care of it next time that I sound clear to everyone. That 'FR' was typo mistake it is 'FZ' everywhere, but you answered exect what I was looking for. It's rally a great help for me.

Thank you very much.
anchal jain
 
Posts: 2
Joined: Wed Oct 05, 2011 4:28 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post