Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to count the number of records in file

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

New User


Joined: 05 Jun 2004
Posts: 43

PostPosted: Fri Jul 16, 2010 2:39 pm    Post subject: How to count the number of records in file
Reply with quote

I need to count the a records in a file base on my sort criteria. I have the input file as below

AAAA 1234
AAAA 2345
BBBB 2345
BBBB 4556
BBBB 5566

I need to get an output as below

AAAA 2
BBBB 3

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

ssmukul

New User


Joined: 22 Jan 2008
Posts: 19
Location: India

PostPosted: Fri Jul 16, 2010 3:28 pm    Post subject: Reply to: How to count the number of records in file
Reply with quote

Hi Shriya,

Please try below jcl.

Code:
//ICETOOL1 EXEC PGM=ICETOOL                                     
//TOOLMSG  DD SYSOUT=*                                           
//DFSMSG   DD SYSOUT=*                                           
//INFILE   DD *                                                 
AAAA 1234
AAAA 2345
BBBB 2345
BBBB 4556
BBBB 5566                                                       
//OUFILE   DD SYSOUT=*                                           
//TOOLIN   DD *                                                 
  OCCURS FROM(INFILE) LIST(OUFILE) NOHEADER ON(1,4,CH) ON(VALCNT)
/*                     


Thanks
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Fri Jul 16, 2010 3:40 pm    Post subject:
Reply with quote

Hi,

The other way to do it is -
Code:

  SORT FIELDS=COPY                             
  INREC OVERLAY=(10:C'01')                     
  OUTFIL REMOVECC,NODETAIL,                   
   BUILD=(1,13),                               
    SECTIONS=(01,04,                             
     TRAILER3=(01,05,06:TOT=(10,02,ZD,LENGTH=08)))


Thanks,
Anshul.[/quote]
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Fri Jul 16, 2010 8:55 pm    Post subject:
Reply with quote

Anshul,

You don't need to "set up" your own counter like that - you can use DFSORT's built-in COUNT function like this:

Code:

  OPTION COPY                               
  OUTFIL REMOVECC,NODETAIL,                 
    SECTIONS=(1,4,                           
      TRAILER3=(1,5,COUNT=(EDIT=(IIT))))     
Back to top
View user's profile Send private message
himanshupant

New User


Joined: 21 Mar 2007
Posts: 46
Location: India

PostPosted: Wed Jul 21, 2010 3:31 pm    Post subject: Reply to: How to count the number of records in file
Reply with quote

Hello

If in the same example if we want the output as

AAAA,3579,2
BBBB,12467,3

How would we do this ? Furthermore if the numric fields were in COMP-3 (packed format) and we wanted the output in simple numeric format( which can be uploaded to an excel file) how would we do this ?
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Wed Jul 21, 2010 3:46 pm    Post subject:
Reply with quote

Hi,

You can do using below sort card -

Code:
OPTION COPY                                                     
OUTFIL REMOVECC,NODETAIL,                                       
SECTIONS=(01,04,                                               
TRAILER3=(01,05,TOT=(06,04,ZD,LENGTH=08),COUNT=(EDIT=(IIT))))   


Frank,
Hope I am correct this time. icon_smile.gif correct if there is a better way.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Jul 21, 2010 10:46 pm    Post subject:
Reply with quote

No, you're not correct. If you had run your job you would see that it produces this output:

Code:

AAAA    3579   2
BBBB   12467   3


whereas the original poster asked for this output:

Code:

AAAA,3579,2
BBBB,12467,3


Do those look the same to you?

Please spend a little more time understanding what is wanted and checking your result vs what was asked for before posting.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Jul 21, 2010 10:50 pm    Post subject:
Reply with quote

Shriya,

What is the RECFM and LRECL of your input file?

Quote:
Furthermore if the numric fields were in COMP-3 (packed format) and we wanted the output in simple numeric format( which can be uploaded to an excel file) how would we do this ?


Please give the starting position and length of the CH key field. Please give the starting position and length of the PD amount field.

Do you want the output as CSV (comma delimited value) records as you show in your post - can that be uploaded to an excel file? If not, show exactly what you want the output records to look like.
Back to top
View user's profile Send private message
himanshupant

New User


Joined: 21 Mar 2007
Posts: 46
Location: India

PostPosted: Thu Jul 22, 2010 1:27 am    Post subject:
Reply with quote

Frank Yaeger wrote:
Shriya,

What is the RECFM and LRECL of your input file?

Quote:
Furthermore if the numric fields were in COMP-3 (packed format) and we wanted the output in simple numeric format( which can be uploaded to an excel file) how would we do this ?


Please give the starting position and length of the CH key field. Please give the starting position and length of the PD amount field.

Do you want the output as CSV (comma delimited value) records as you show in your post - can that be uploaded to an excel file? If not, show exactly what you want the output records to look like.


The starting position of CH key field is 1 and length is 4.

The starting position of PD field is 5 and length is 4.
I want the output file in csv format as I have shown in output and the sum fields in zoned decimal format which can be uploaded to excel document.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Thu Jul 22, 2010 2:13 am    Post subject:
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB)
//SORTOUT DD DSN=...  output file (FB)
//SYSIN DD *
  INREC OVERLAY=(9:C'00001')
  SORT FIELDS=(1,4,CH,A)
  SUM FIELDS=(5,4,PD,9,5,ZD)
  OUTREC IFOUTLEN=18,
   IFTHEN=(WHEN=INIT,
     BUILD=(1,4,X,5,4,PD,EDIT=(IIIIIIT),X,9,5,ZD,EDIT=(IIIIT))),
   IFTHEN=(WHEN=INIT,BUILD=(1,18,SQZ=(SHIFT=LEFT,MID=C',')))
/*
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Thu Jul 22, 2010 11:25 am    Post subject:
Reply with quote

Frank,

Will keep in mind. icon_redface.gif
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 column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us