IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Count of particular characters in a record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Musab Razeen Ahmed

New User


Joined: 24 Feb 2011
Posts: 16
Location: India

PostPosted: Fri Oct 28, 2011 5:36 pm
Reply with quote

Hi All,

I have a FB dataset lrecl = 80. sample i/o is as follows.

q,werty
poi,uyt
asdf,g,h

Is it possible to count the number of ',' in each record and display it?

If yes could you please let me know?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 28, 2011 5:59 pm
Reply with quote

look for the inspect tallying format 3.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Oct 28, 2011 6:16 pm
Reply with quote

Yes. 1, 1, 2.

What language do you want to use? I'm not sure it can be done with DFSORT if that is what you wanted, but we'll get a confirmation later.

What do you want to know for? Knowing what you want may remove your need to actually count...
Back to top
View user's profile Send private message
Musab Razeen Ahmed

New User


Joined: 24 Feb 2011
Posts: 16
Location: India

PostPosted: Fri Oct 28, 2011 6:20 pm
Reply with quote

I was looking or a DFSORT Code. (for the sake of simplicity)

I was looking over manuals, but couldn't figure out a logic to do this. That's why posted the same.
Back to top
View user's profile Send private message
Musab Razeen Ahmed

New User


Joined: 24 Feb 2011
Posts: 16
Location: India

PostPosted: Fri Oct 28, 2011 6:22 pm
Reply with quote

Any ways the INSPECT TALLYING link provided by Dick Brenholtz was helpful for the time being.

But I would like to work on DFSORT to achieve the same.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 28, 2011 6:43 pm
Reply with quote

Sorry,
my bad, did not notice that it was the dfsort forum.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Oct 28, 2011 6:47 pm
Reply with quote

The Cobol would be simple. rexx would be simple. I can't see anything springing out of DFSORT, but you'lll find out later.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Fri Oct 28, 2011 7:16 pm
Reply with quote

Musab Razeen Ahmed,
Is there a limit to max. number of occurrences for comma ','?

What is your DFSort function level?

Thanks,
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Nov 02, 2011 2:30 am
Reply with quote

Musab,

You can do what you want with a DFSORT job like the following. I assumed you have a maximum of 10 commas in one record and that you want to display the count in positions 81-85 of each record.

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
q,werty
poi,uyt
asdf,g,h
a,b,,,,c,,d,,x,y
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
        PARSE=(%01=(STARTAT=C',',FIXLEN=1),
               %02=(STARTAT=C',',FIXLEN=1),
               %03=(STARTAT=C',',FIXLEN=1),
               %04=(STARTAT=C',',FIXLEN=1),
               %05=(STARTAT=C',',FIXLEN=1),
               %06=(STARTAT=C',',FIXLEN=1),
               %07=(STARTAT=C',',FIXLEN=1),
               %08=(STARTAT=C',',FIXLEN=1),
               %09=(STARTAT=C',',FIXLEN=1),
               %10=(STARTAT=C',',FIXLEN=1)),
        OVERLAY=(81:%01,%02,%03,%04,%05,%06,%07,%08,%09,%10)),
    IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=81,IN=C',',OUT=C'1')),
    IFTHEN=(WHEN=INIT,
      BUILD=(1,80,81,1,ZD,ADD,82,1,ZD,ADD,83,1,ZD,ADD,84,1,ZD,ADD,
             85,1,ZD,ADD,86,1,ZD,ADD,87,1,ZD,ADD,88,1,ZD,ADD,
             89,1,ZD,ADD,90,1,ZD,TO=ZD,LENGTH=5))
/*


SORTOUT would have:

Code:

q,werty                                                                         00001
poi,uyt                                                                         00001
asdf,g,h                                                                        00002
a,b,,,,c,,d,,x,y                                                                00010


If that's not what you want, then you need to do a better job of explaining what you do want.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
Search our Forums:

Back to Top