MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

total on all records

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
murali
Beginner


Joined: 21 Apr 2004
Posts: 12
Topics: 9

PostPosted: Sun May 02, 2004 11:15 am    Post subject: total on all records Reply with quote

I have a similar requirement which was posted in this topic

http://www.mvsforums.com/helpboards/viewtopic.php?t=2126

But my requirement is slightly different. I want the total on all the records. my file contains Account number in first 11 bytes.The account
number can be duplicates. I want the account number total to be present on all records. My file has lrecl of 425 and the count should be in 421 byte for 5 bytes

ABCDEFGHIJK........................
ABCDEFGHIJK........................
ABCDEFGHIJK........................
LMNOPQRSTUW........................
LMNOPQRSTUW........................
LMNOPQRSTUW........................
LMNOPQRSTUW........................
XYZABCDEFGH........................
XYZABCDEFGH........................


Account number count
------------ -----
ABCDEFGHIJK........................3
ABCDEFGHIJK........................3
ABCDEFGHIJK........................3
LMNOPQRSTUW........................4
LMNOPQRSTUW........................4
LMNOPQRSTUW........................4
LMNOPQRSTUW........................4
XYZABCDEFGH........................2
XYZABCDEFGH........................2


Can this be done using any utilities?

Tia

murali
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sun May 02, 2004 9:57 pm    Post subject: Reply with quote

Murali,

This is a little bit tricky as you want the count on all the records. I am aware that DFSORT'S splice operator can be used to get the desired results. My shop does not have DFSORT , so I solved it using sort/file-aid combination , easytrieve.

A brief explanation of the job. We first add a constant of '00001' at the end of every account number using INREC. then we sort on the account number and sum on the constant this will get unique records with the total count at the end.

Now we generate file-aid replace cards to copy the total for all records. I used file-aid as it allows 999999 entries for control cards. However you need to fiddle with the region size to make it to work.the control cards generated will look as follows:
Code:

REPL=(1,EQ,C'ABCDEFGHIJK',421,C'003'),
REPL=(1,EQ,C'LMNOPQRSTUW',421,C'004'),
...


Code:

//STEP0100  EXEC PGM=SORT                 
//SYSOUT    DD SYSOUT=*                   
//SORTIN    DD DSN=YOUR INPUT FILE,
//             DISP=SHR                         
//SORTOUT   DD DSN=&T1,
//             DISP=(NEW,PASS),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y,),RLSE)                   
//SYSIN     DD *
  OPTION ZDPRINT
  INREC FIELDS=(1,11,C'00001')                                         
  SORT FIELDS=(1,11,CH,A)                                 
  SUM FIELDS=(12,5,ZD)                                   
  OUTREC FIELDS=(12X,C'REPL=(1,EQ,C''',1,11,C''',421,C''',
                 12,5,C'''),',80:X)                       
/*
//STEP0200 EXEC PGM=FILEAID     
//SYSLIST  DD SYSOUT=*           
//SYSPRINT DD SYSOUT=*
//DD01     DD DSN=YOUR INPUT FILE,
//            DISP=SHR                         
//DD01O    DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y,),RLSE)           
//SYSIN    DD *                                             
$$DD01 COPY REPL=(1,EQ,C'           ',421,C'   '),           
//         DD DSN=&T1,DISP=OLD                               
//         DD *                                             
            REPL=(1,EQ,C'99999999999',421,C'999'),OUT=0       
//*


Easytrieve Solution:

Code:

//STEP0100 EXEC PGM=EZTPA00                           
//STEPLIB  DD DSN=EASYTREV.LOADLIB,         
//            DISP=SHR                                 
//SYSPRINT DD SYSOUT=*                                 
//SYSOUT   DD SYSOUT=*                                 
//SYSSNAP  DD SYSOUT=*                                 
//SYSUDUMP DD SYSOUT=*                                 
//FILEIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR                                       
//FILEOUT  DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE),                               
//            DCB=(RECFM=FB,LRECL=425,BLKSIZE=0)       
//*                                                   
//SYSIN    DD *                                       
                                                       
  FILE FILEIN                                         
     FILEIN-REC            001 425 A                     
     ACCNT-NO              001 011 A                     
                                                       
  FILE FILEOUT                                         
     FILEOUT-REC           001 425 A                     
     POLICY-COUNT          421 005 N 0                   
                                                       
  FILE TEMPA FB (0 0) VIRTUAL RETAIN                   
     TEMP-KEY        1   11 A                         
     TEMP-COUNT      12  10 P  0                       
                                                       
  JOB INPUT (FILEIN KEY (ACCNT-NO))
                                             
   PRINT RPT                                 
   REPORT RPT SUMMARY SUMFILE TEMPA           
   SEQUENCE ACCNT-NO                     
   CONTROL ACCNT-NO                       
   LINE ACCNT-NO TALLY                   
                                             
  JOB INPUT (TEMPA  KEY (TEMP-KEY)    +       
             FILEIN KEY (ACCNT-NO))         
   IF MATCHED                                 
      FILEOUT-REC  = FILEIN-REC               
      POLICY-COUNT = TEMP-COUNT               
      PUT FILEOUT                             
   END-IF                                     
/*                                                             



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon May 03, 2004 10:26 am    Post subject: Reply with quote

Here's a DFSORT/ICETOOL solution. You'll need R14 PTF UQ90053 (Feb, 2003) to use SPLICE. For complete information on the SPLICE operator of DFSORT's ICETOOL, see:

http://www.storage.ibm.com/software/sort/mvs/uq90053/online/srtmutol.html#spl

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.IN,VOL=REF=*.IN,DISP=(OLD,PASS)
//OUT DD DSN=...  output file
//TOOLIN DD *
* Get count for each set of duplicates
  SORT FROM(IN) USING(CTL1)
* Add count to records
  SPLICE FROM(CON) TO(OUT) ON(1,11,CH) WITHALL WITH(1,420)
/*
//CTL1CNTL DD *
  SORT FIELDS=(1,11,CH,A)
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,
    SECTIONS=(1,11,
      TRAILER3=(1,11,421:COUNT=(M11,LENGTH=5)))
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group