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

How to count the number of records in file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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 Developer


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

PostPosted: Fri Jul 16, 2010 8:55 pm
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
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
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 Developer


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

PostPosted: Wed Jul 21, 2010 10:46 pm
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 Developer


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

PostPosted: Wed Jul 21, 2010 10:50 pm
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
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 Developer


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

PostPosted: Thu Jul 22, 2010 2:13 am
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
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 All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Format data from multiple records usi... SYNCSORT 4
No new posts IGYPG3178-I when compiling a pgm read... COBOL Programming 6
No new posts count contained values of several col... DB2 5
No new posts FileAid move data from two files to o... Compuware & Other Tools 5
No new posts DB2 Query to get the count of Unique ... DB2 2
Search our Forums:


Back to Top