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

Counting Number of records for Each Unique Key


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Vigneshwaran S
Warnings : 1

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Tue Jul 28, 2009 11:32 am
Reply with quote

Hi all,

I have Input dataset as shown below,

Code:


A 10
B 20
C 30
D 40
B 40
C 20
A 10
C 25



I would like to display my output report like this,

Code:


TOTAL COUNT FOR A : 20
TOTAL COUNT FOR B : 60
TOTAL COUNT FOR C : 75
TOTAL COUNT FOR D : 40



Can anyone suggest me a solution for this?
Back to top
View user's profile Send private message
Vigneshwaran S
Warnings : 1

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Tue Jul 28, 2009 11:34 am
Reply with quote

HI all,

LRECL = 80, RECFM = FB

First column starts in Position 1.
Second column starts in Position 3.
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Tue Jul 28, 2009 12:29 pm
Reply with quote

Try using the below code:

Code:
//SYSIN DD *
 OPTION ZDPRINT
 SORT FIELDS=(1,1,CH,A)
 SUM FIELDS=(3,2,ZD)
/*



Thanks,
-Kapil.
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Tue Jul 28, 2009 12:35 pm
Reply with quote

use outrec to get the result in desired format.

Code:

  OUTREC FIELDS=(C'TOTAL COUNT FOR ',1,1,X,C':',X,3,2,80:X)
Back to top
View user's profile Send private message
Vigneshwaran S
Warnings : 1

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Tue Jul 28, 2009 5:54 pm
Reply with quote

Hi,

Im getting S0C7 abend for my below input,

Code:

                 HEADER1
                 HEADER2
                 HEADER3
                 
A   100
B    30
C     3

A   217
B     3
C   100

A 1,234
B     9
C    24



I have never encountered S0C7 abend in DFSORT step.
After making 1,234 as 1234 and removing the header lines the code is working fine.

Can anyone explain why im getting S0C7 abend?and also solution to counter this.

This is my sort step,
Code:


  OPTION ZDPRINT,SKIPREC=3                                           
  INCLUDE COND=(53,7,CH,NE,C'       ')                               
  SORT FIELDS=(53,47,CH,A)                                           
  SUM FIELDS=(124,8,ZD)                                             
  OUTREC FIELDS=(C'TOTAL EXCEPTIONS FOR ',53,47,X,C':',X,124,8,160:X)


My input LRECL = 160 and RECFM=FB
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: Tue Jul 28, 2009 9:14 pm
Reply with quote

You're getting a S0C7 because 1,234 is not a valid ZD value. You could fix the suggested control statements by adding:

Code:

  INREC OVERLAY=(124:124,8,UFF,TO=ZD,LENGTH=8) 


Alternatively, you could use these DFSORT control statements:

Code:

  OPTION ZDPRINT,SKIPREC=3                               
  INCLUDE COND=(53,7,CH,NE,C'       ')                   
  SORT FIELDS=(53,47,CH,A)                               
  OUTFIL REMOVECC,NODETAIL,                             
    SECTIONS=(53,47,                                     
     TRAILER3=(C'TOTAL EXCEPTIONS FOR ',53,47,' : ',     
       TOT=(124,8,UFF,M10,LENGTH=8)))                   
Back to top
View user's profile Send private message
Vigneshwaran S
Warnings : 1

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Thu Jul 30, 2009 4:45 pm
Reply with quote

Hi all,

Thanks for Posting. Could you please suggest me how to include << END OF REPORT >> at the end of my output.

This is the sort step im using,

Code:


OPTION ZDPRINT,SKIPREC=5                                   
  INCLUDE COND=(53,7,CH,NE,C'       ')                     
  SORT FIELDS=(53,47,CH,A)                                 
  OUTFIL REMOVECC,NODETAIL,                               
    SECTIONS=(53,47,                                       
     TRAILER3=(C'TOTAL EXCEPTIONS FOR ',53,47,' : ',       
       TOT=(124,8,UFF,M10,LENGTH=8)))                     

Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Jul 30, 2009 9:10 pm
Reply with quote

Vigneshwaran S,

Just add the trailer1 parm at the end

Use the following control cards

Code:

//SYSIN DD *                                           
  OPTION ZDPRINT,SKIPREC=5                             
  INCLUDE COND=(53,7,CH,NE,C' ')                       
  SORT FIELDS=(53,47,CH,A)                             
  OUTFIL REMOVECC,NODETAIL,                           
  SECTIONS=(53,47,                                     
  TRAILER3=(C'TOTAL EXCEPTIONS FOR ',53,47,' : ',     
            TOT=(124,8,UFF,M10,LENGTH=8))),           
  TRAILER1=(C'<< END OF REPORT >>')
//*
Back to top
View user's profile Send private message
Vigneshwaran S
Warnings : 1

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Fri Jul 31, 2009 11:28 am
Reply with quote

Hi,

Thanks!!! I was trying with Trailer1 parm but i forgot to include comma at the end of Trailer3
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 Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
Search our Forums:

Back to Top