Count numbers of records



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

Count numbers of records

Postby pulcinella » Thu Aug 18, 2011 2:25 pm

Helo.

First of all, I sorry if this question has been answered. I have seen most answer but i could not found it.

I need to do two JCL's

FIRST

I need a JCL that count number of records of a file. I need count the numbers of recors that have 'S' in more positions. I would like the output file had: "Number of records that have 'S' at position 15 is 124", "Number of records that have 'S' at position 20 is 262",... The record may have several (the records have many 'S' at different colums.

Only for you help: The key is position 15-25 and it's not duplicates. I think that is not important. My input file has 479 position (>= 15.000.000 records).

The position that I want count 'S' is: 36,46,47,65,66,84,102,120,138,156,174,175,176,188,200,218,219,231,243,255,267,
279,291,303,321,322,323,324,325,326,348,349,350

I have the next jcl but i would changed.

//STEP032 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=&&,DISP=SHR
//TOOLIN DD *
COUNT FROM(IN1) USING(CTL1)
COUNT FROM(IN1) USING(CTL2)
...
/*
//CTL1CNTL DD *
INCLUDE COND=(36,1,CH,EQ,C'S')
//CTL2CNTL DD *
INCLUDE COND=(46,1,CH,EQ,C'S')
...

In my example I hace repeat label CNTL 32 or more times. Can I have only label CNTL with clausule 'IFTHEN' por example? Can I have write he header "Number of records that have 'S' at position xx is xxxx"? (xx = "position 36, 46) (xxxx = total records with 'S')

SECOND

I have a file at 71 position and I need count a number of records of a file. My record's has:

AAAA;X;CVT002;2011-09-13
AAAA;X;CVT001;2011-09-13
AAAA;X;CVT002;2011-09-20
AAAA;X;CVT001;2011-09-20
AAAA;X;CVT002;2011-09-27
AAAA;X;CVT001;2011-09-27
AAAA;X;CVT002;2011-10-04
AAAA;X;CVT001;2011-10-04
AAAA;X;CVT002;2011-10-11
AAAA;X;CVT001;2011-10-11

(AAAA;X is the same)
(CVT001;2011-09-13 - CVT002;2011-09-13 Has 2 records always. One with CVT001; two with CVT002 and the same date)

I want count number of records of a file (I don't need to know numbers of AAAA repeat or numbers of date repeat). This file haven't fixed number of records. The file can be 8 records, 10 records, xxx records. For this I want obtain an output file only with the last 8 records (most current date is the last records; the old date is the first)

In my example, my output file has:

AAAA;X;CVT002;2011-09-20
AAAA;X;CVT001;2011-09-20
AAAA;X;CVT002;2011-09-27
AAAA;X;CVT001;2011-09-27
AAAA;X;CVT002;2011-10-04
AAAA;X;CVT001;2011-10-04
AAAA;X;CVT002;2011-10-11
AAAA;X;CVT001;2011-10-11

(the first 2 records "2011-09-13" I don't need). As I can have xx records, I need count the records automatically and I obtain a file with only 8 last records always

- count records
- If count > 8
write the last 8 records
- else
write all records (because i have not 8 records and i need work with this records)
- end if

Thank you very much
Pulcinella
pulcinella
 
Posts: 114
Joined: Mon Dec 10, 2007 10:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count numbers of records

Postby NicC » Thu Aug 18, 2011 6:06 pm

Sorry - but JCL does not count things it simply tells the system what programs you want to execute in a job and what resources they need. What you mean is that you want, if possible, sort control cards to do the following blah blah blah. After almost 4 years you should know this by now.

Next, you have two questions so you should start 2 topics - now the answers are going to be muddled up. Hopefully a moderator will split the second question into a seperate topic.

Third - for your second question hve you looked at the DFsort tricks document?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Count numbers of records

Postby Ed Goodman » Thu Aug 18, 2011 6:22 pm

For your second thing, try sorting the file in reverse date sequence, then taking the first 8. Then sort it back. For a small file, that wouldn't be so bad, kinda clunky, but not so bad.

For your first thing, try reformatting the record coming in so that if a given field has an 's', you put a binary 1, but if it's not 's', you put a binary 0. Then sum the fields.

as a small example:
input:
plan a S  plan B  plan C

becomes
----+----+----+----+
00004000040000
00010000000001

Then, sum those fields
SUM FIELDS=(1,4,BI,6,4,BI,11,4,BI)

Then, you can format it however you want:
OUTREC=(c'PLAN A TOTAL:',1,4,BI,EDIT=(TTT,TTT,TTT),C' PLAN B TOTAL:',6,4,BI,EDIT=(TTT,TTT,TTT))
Ed Goodman
 
Posts: 341
Joined: Thu Feb 24, 2011 12:05 am
Has thanked: 3 times
Been thanked: 17 times

Re: Count numbers of records

Postby pulcinella » Thu Aug 18, 2011 8:48 pm

Ed Goodman thanks for your help

Edited for consistency
pulcinella
 
Posts: 114
Joined: Mon Dec 10, 2007 10:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count numbers of records

Postby skolusu » Thu Aug 18, 2011 9:47 pm

pulcinella,

The second q is quite easy. Use the following DFSORT JCL . I assumed that '2011-09-13' are the first 2 records and you want to skip them.
//STEP0100 EXEC PGM=SORT               
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD *                         
AAAA;X;CVT002;2011-09-13               
AAAA;X;CVT001;2011-09-13               
AAAA;X;CVT002;2011-09-20               
AAAA;X;CVT001;2011-09-20               
AAAA;X;CVT002;2011-09-27               
AAAA;X;CVT001;2011-09-27               
AAAA;X;CVT002;2011-10-04               
AAAA;X;CVT001;2011-10-04               
AAAA;X;CVT002;2011-10-11               
AAAA;X;CVT001;2011-10-11               
AAAA;X;CVT001;2011-10-12               
AAAA;X;CVT001;2011-10-13               
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD *                         
  OPTION SKIPREC=2                     
  SORT FIELDS=(15,10,CH,A),EQUALS       
  OUTFIL ENDREC=8                       
//*


The first q is also an easy one except that you have to code 33 IFTHEN statements and total them on the trailer . Use the following DFSORT control cards.

//STEP0100 EXEC PGM=SORT           
//SYSOUT   DD SYSOUT=*             
//SORTIN   DD DSN=Your Input FB file,DISP=SHR   
//SORTOUT  DD SYSOUT=*             
//SYSIN    DD *                   
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=INIT,                                       
  BUILD=(036,1,046,1,047,1,065,1,066,1,084,1,102,1,120,1,138,1, 
         156,1,174,1,175,1,176,1,188,1,200,1,218,1,219,1,231,1, 
         243,1,255,1,267,1,279,1,291,1,303,1,321,1,322,1,323,1, 
         324,1,325,1,326,1,348,1,349,1,350,1,35:33C'0')),       
  IFTHEN=(WHEN=(01,1,CH,EQ,C'S'),OVERLAY=(35:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(02,1,CH,EQ,C'S'),OVERLAY=(36:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(03,1,CH,EQ,C'S'),OVERLAY=(37:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(04,1,CH,EQ,C'S'),OVERLAY=(38:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(05,1,CH,EQ,C'S'),OVERLAY=(39:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(06,1,CH,EQ,C'S'),OVERLAY=(40:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(07,1,CH,EQ,C'S'),OVERLAY=(41:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(08,1,CH,EQ,C'S'),OVERLAY=(42:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(09,1,CH,EQ,C'S'),OVERLAY=(43:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(10,1,CH,EQ,C'S'),OVERLAY=(44:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(11,1,CH,EQ,C'S'),OVERLAY=(45:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(12,1,CH,EQ,C'S'),OVERLAY=(46:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(13,1,CH,EQ,C'S'),OVERLAY=(47:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(14,1,CH,EQ,C'S'),OVERLAY=(48:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(15,1,CH,EQ,C'S'),OVERLAY=(49:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(16,1,CH,EQ,C'S'),OVERLAY=(50:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(17,1,CH,EQ,C'S'),OVERLAY=(51:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(18,1,CH,EQ,C'S'),OVERLAY=(52:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(19,1,CH,EQ,C'S'),OVERLAY=(53:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(20,1,CH,EQ,C'S'),OVERLAY=(54:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(21,1,CH,EQ,C'S'),OVERLAY=(55:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(22,1,CH,EQ,C'S'),OVERLAY=(56:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(23,1,CH,EQ,C'S'),OVERLAY=(57:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(24,1,CH,EQ,C'S'),OVERLAY=(58:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(25,1,CH,EQ,C'S'),OVERLAY=(59:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(26,1,CH,EQ,C'S'),OVERLAY=(60:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(27,1,CH,EQ,C'S'),OVERLAY=(61:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(28,1,CH,EQ,C'S'),OVERLAY=(62:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(29,1,CH,EQ,C'S'),OVERLAY=(63:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(30,1,CH,EQ,C'S'),OVERLAY=(64:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(31,1,CH,EQ,C'S'),OVERLAY=(65:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(32,1,CH,EQ,C'S'),OVERLAY=(66:C'1'),HIT=NEXT),   
  IFTHEN=(WHEN=(33,1,CH,EQ,C'S'),OVERLAY=(67:C'1'),HIT=NEXT)     
                                                     
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),               
  TRAILER1=('NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 036 IS  :',           
            TOT=(35,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 046 IS  :',           
            TOT=(36,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 047 IS  :',           
            TOT=(37,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 065 IS  :',           
            TOT=(38,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 066 IS  :',           
            TOT=(39,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 084 IS  :',           
            TOT=(40,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 102 IS  :',           
            TOT=(41,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 120 IS  :',           
            TOT=(42,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 138 IS  :',           
            TOT=(43,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 156 IS  :',           
            TOT=(44,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 174 IS  :',           
            TOT=(45,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 175 IS  :',           
            TOT=(46,1,ZD,M10,LENGTH=8),/,             
            'NUMBER OF RECORDS THAT HAVE ''',         
            'S''',' AT POSITION 176 IS  :',   
            TOT=(47,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 188 IS  :',   
            TOT=(48,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 200 IS  :',   
            TOT=(49,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 218 IS  :',   
            TOT=(50,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 219 IS  :',   
            TOT=(51,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 231 IS  :',   
            TOT=(52,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 243 IS  :',   
            TOT=(53,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 255 IS  :',   
            TOT=(54,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 267 IS  :',   
            TOT=(55,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 279 IS  :',   
            TOT=(56,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 291 IS  :',   
            TOT=(57,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 303 IS  :',   
            TOT=(58,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''', 
            'S''',' AT POSITION 321 IS  :',   
            TOT=(59,1,ZD,M10,LENGTH=8),/,     
            'NUMBER OF RECORDS THAT HAVE ''',   
            'S''',' AT POSITION 322 IS  :',     
            TOT=(60,1,ZD,M10,LENGTH=8),/,       
            'NUMBER OF RECORDS THAT HAVE ''',   
            'S''',' AT POSITION 323 IS  :',     
            TOT=(61,1,ZD,M10,LENGTH=8),/,       
            'NUMBER OF RECORDS THAT HAVE ''',   
            'S''',' AT POSITION 324 IS  :',     
            TOT=(62,1,ZD,M10,LENGTH=8),/,       
            'NUMBER OF RECORDS THAT HAVE ''',   
            'S''',' AT POSITION 325 IS  :',     
            TOT=(63,1,ZD,M10,LENGTH=8),/,       
            'NUMBER OF RECORDS THAT HAVE ''',   
            'S''',' AT POSITION 326 IS  :',     
            TOT=(64,1,ZD,M10,LENGTH=8),/,       
            'NUMBER OF RECORDS THAT HAVE ''',   
            'S''',' AT POSITION 348 IS  :',     
            TOT=(65,1,ZD,M10,LENGTH=8),/,       
            'NUMBER OF RECORDS THAT HAVE ''',   
            'S''',' AT POSITION 349 IS  :',     
            TOT=(66,1,ZD,M10,LENGTH=8),/,       
            'NUMBER OF RECORDS THAT HAVE ''',   
            'S''',' AT POSITION 350 IS  :',     
            TOT=(67,1,ZD,M10,LENGTH=8))         
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Count numbers of records

Postby pulcinella » Fri Aug 19, 2011 4:13 am

Great Skolusu !!!

Thank you very much for your help.

The first solution is Ok. Thank you...

The second solution is Ok too but excuse me If i don't explain very well... It's correct when you think that the first 2 records (2011-09-13) has been omitted. I have a JCL that be executed more times. I wrote new dates at file but I want deleted the old date.

The first time that I executed only have 2 dates and I don't want deleted them (the output file must be two records too); the second time that I executed I have 4 records and i don't want deleted them (the output file must be four records too). Only I want deleted the first 2 records if records > 8. The output file must be 2-8 records (2 records, 4 records, 6 records or 8 records) always. I want to say if exist a function similar a LISTCAT command (used to know if exist file; If exist return 0 else...) really. I want to make the same (if records < 8 write all records; if records > 8 (for example 10) deleted the first two records (the old date are the top; the new dates are down). The file has even number always (I don't have odd number)

Thanks a lot of
pulcinella
 
Posts: 114
Joined: Mon Dec 10, 2007 10:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count numbers of records

Postby skolusu » Fri Aug 19, 2011 9:50 pm

pulcinella wrote:I want to make the same (if records < 8 write all records; if records > 8 (for example 10) deleted the first two records (the old date are the top; the new dates are down). The file has even number always (I don't have odd number)


pulcinella,

If you have 12 records do you delete the first 4 and if you have 14 records do you delete the first 6 and so on..? or is it just 2? Do you have to delete variable number of records and always keep the last 8?
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post