Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Count occuprance of | in a row

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
shuklas

New User


Joined: 21 Dec 2006
Posts: 20
Location: London

PostPosted: Fri Mar 13, 2009 2:39 pm    Post subject: Count occuprance of | in a row
Reply with quote

Hi,

I have a requirement where I need to find the count for number of occurance of | in a single row.

Ex.

"asdsf"|1234|2009-09-01|"asdr"

The result of count should be: 3

Can Parse be used for this requirement.
Back to top
View user's profile Send private message

vpalanivelu

New User


Joined: 24 Feb 2009
Posts: 14
Location: chennai

PostPosted: Fri Mar 13, 2009 4:24 pm    Post subject: Re: Reply to: Count occuprance of | in a row
Reply with quote

Assuming there are no numbers in the characters for which you want to count x's, you can use this DFSORT job to do what you asked for:
Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
aaaaxxaaaaaxxxx
aaaaaaffdfxmm
dddddxxxdddddd
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
* Change 'x' to '1'
  ALTSEQ CODE=(A7F1)
* Copy 1-15 to 21-35 and change each 'x' to a '1' in 21-35.
  INREC FIELDS=(1,15,21:1,15,TRAN=ALTSEQ)
* Get total of 1s in 21-35 (with FS, letters will be treated as 0).
  OUTREC FIELDS=(1,15,X,
    21,1,FS,ADD,22,1,FS,ADD,23,1,FS,ADD,24,1,FS,ADD,25,1,FS,ADD,
    26,1,FS,ADD,27,1,FS,ADD,28,1,FS,ADD,29,1,FS,ADD,30,1,FS,ADD,
    31,1,FS,ADD,32,1,FS,ADD,33,1,FS,ADD,34,1,FS,ADD,35,1,FS,
    TO=FS,LENGTH=3)
/*
 


SORTOUT will have:

Code:


aaaxxaaaaaxxxx   6
aaaaaffdfxmm     1
ddddxxxdddddd    3
 


If there are numbers in the characters for which you want to count x's, change the ALTSEQ statement to:

Code:


  ALTSEQ CODE=(A7F1,F1F0,F2F0,F3F0,F4F0,F5F0,F6F0,F7F0,F8F0,F9F0) 
 


This will ensure that numbers are counted as 0s and only x's are counted as 1s
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Mar 14, 2009 1:26 am    Post subject: Reply to: Count occuprance of | in a row
Reply with quote

shuklas,

Here is a DFSORT JCL which will give you the desired results. Using FINDREP we eliminate all character A thru Z and 0 thru 9 and ", - . By doing this we are only left with the character which you want to count. And now we convert this to VB file so that we get the accurate count of the characters. It also eliminates records without the | character

FINDREP function of DFSORT is available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008)

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                   
"ASDSF"|1234|2009-09-01|"ASDR"                                     
"ASDSF"|1234                                                       
"ASDSF"                                                           
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)         
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC FINDREP=(IN=(C'A',C'B',C'C',C'D',C'E',C'F',C'G',C'H',C'I',
                     C'J',C'K',C'L',C'M',C'N',C'O',C'P',C'Q',C'R',
                     C'S',C'T',C'U',C'V',C'W',C'X',C'Y',C'Z',C'0',
                     C'1',C'2',C'3',C'4',C'5',C'6',C'7',C'8',C'9',
                     C'"',C'-'),OUT=C'')                           
  OUTFIL FTOV,VLTRIM=C' ',OMIT=(1,1,CH,NE,C'|')                   
//*                                                               
//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=&&T1,DISP=SHR                                   
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  OUTFIL VTOF,BUILD=(5,1,C' COUNT = ',1,2,BI,SUB,+4,M10,LENGTH=5) 
/*                                                                 


The output from this job is
Code:

| COUNT =     3 
| COUNT =     1 

If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).

For complete details on the new FINDREP and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Mar 14, 2009 1:37 am    Post subject:
Reply with quote

Hello,

Suggest if the file has 100 million records some other solution would be a far better use of the system.

To simply count the |'s, there will be 100 million "writes" and then another 100 million reads to actually get the count. . .

This to get around 5 minutes of writing code? (read, inspect/tallying, add to total - at eof display the total) . . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts CICS Transaction attach count of supp... lind sh CICS 1 Wed Jun 21, 2017 1:33 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Display FTP Session Count within TSO Yolanda Harvey TSO/ISPF 3 Fri Mar 10, 2017 10:31 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us