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 

Count the number of Characters using SORT

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


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Mon Feb 16, 2009 6:34 am    Post subject: Count the number of Characters using SORT Reply with quote

Is it possible to count the number of characters in a FB file using SORT..
i.e is it possible to calculate recod length * record count?

Thanks
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Feb 16, 2009 11:02 am    Post subject: Reply with quote

edkir98,

Do you want to count spaces within a record or just anything that is not a space? What is the LRECL, RECFM of the dataset?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Mon Feb 16, 2009 12:42 pm    Post subject: Reply with quote

I believe a sort (maybe copy also, but not sure) displays a number of bytes sorted in SYSOUT. Try testing a sort (you can DD DUMMY SORTOUT and look at the output.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Tue Feb 17, 2009 5:27 am    Post subject: Reply with quote

hi Kolusu and Terry, Thanks for your reply.

Kolusu..i would want to count everything..
for eg. if this is the flat file with record length 5
Code:
abcde
1234
l mno


now the output that i would want is record length(5) * count of the number of records(3) = 15
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Feb 17, 2009 11:18 am    Post subject: Reply with quote

edkir98,

If you know the lrecl of the dataset then it is easy to just multiply no: of records with the LRECL

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=Your input file,
//            DISP=SHR                                   
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                           
  INREC BUILD=(SEQNUM,8,PD)                                   
  OUTREC OVERLAY=(10:1,8,PD,MUL,+5,PD,LENGTH=8)               
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                       
  TRAILER1=('CHARACTER COUNT : ',MAX=(10,8,PD,M10,LENGTH=12))
/*


However if you don't know the LRECL and want the program to figure it out then you will need another pass of data. we first convert the fb file into vb file which would store the LRECL in the first 2 bytes.


Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=Your input file,
//            DISP=SHR                                     
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                         
  OUTFIL FTOV                                               
/*                                                         
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=&&T1,DISP=SHR                             
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                         
  INREC BUILD=(1,4,1,2,BI,SUB,+4,BI,LENGTH=4)               
  OUTFIL REMOVECC,NODETAIL,VTOF,BUILD=(80X),               
  TRAILER1=('CHARACTER COUNT : ',TOT=(5,4,BI,M10,LENGTH=12))
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
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