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

DFSORT SUM and COUNTing records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Steve Davies

New User


Joined: 15 Oct 2009
Posts: 32
Location: UK

PostPosted: Fri Oct 16, 2009 5:53 pm
Reply with quote

Hi... I know there are many posts similar to this one as I've done all the searches, but I haven't found the exact same problem, and I'm not getting the results I expect, hence this post.

I have this sort

Code:

//STP030 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                     
----+----1----+----2----+----3----+----4----+----5----+----
//SORTIN   DD *                                           
AA.?.100..BB...080..MM..1.ZZ                               
AA.@.100..BB...080..MM..2.ZZ                               
AA.£.100..BB...080..MM..3.ZZ                               
AA.".200..BB...010..MM..4.YY                               
/*                                                         
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  SORT FIELDS=(1,2,CH,A,11,2,CH,A,21,2,CH,A,27,2,CH,A)     
  SUM FIELDS=(6,3,ZD,16,3,ZD)                             
  OUTFIL REMOVECC, NODETAIL,                               
    SECTIONS=(1,28,                                       
      TRAILER3=(1,28,X,COUNT=(M11,LENGTH=9)))             
/*                                                         


and it's giving me these results

Code:

AA.".200..BB...010..MM..4.YY 000000001   
AA.?.300..BB...240..MM..1.ZZ 000000001   


What I'm expecting is this

Code:

AA.".200..BB...010..MM..4.YY 000000001   
AA.?.300..BB...240..MM..1.ZZ 000000003


..the first line is OK, but I'm expecting a count of 3 in the second line as there are 3 records that were summed to create the second output record.

Clearly I've not got the syntax correct and I am suspecting it may be something to do with the SECTIONS clause, but I can't find the syntax that gives me the results I need.
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 Oct 16, 2009 9:18 pm
Reply with quote

SUM is performed before OUTFIL, so by the time you get to OUTFIL, you only have two records left. Instead of using SUM, you can use SECTIONS by itself. TRAILER3 takes data from the last record of each set of dups. Since you want data from the first record of each set of dups, you have to do a little more work to make that happen.

Here's a DFSORT job that will do what you asked for:

Code:

//STP030 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
AA.?.100..BB...080..MM..1.ZZ
AA.@.100..BB...080..MM..2.ZZ
AA.£.100..BB...080..MM..3.ZZ
AA.".200..BB...010..MM..4.YY
/*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  INREC OVERLAY=(81:1,2,11,2,21,2,27,2,SEQNUM,8,ZD,RESTART=(81,8))
  SORT FIELDS=(81,8,CH,A,89,8,ZD,D)
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(1,80),
    SECTIONS=(81,8,
      TRAILER3=(1,5,TOT=(6,3,ZD,TO=ZD,LENGTH=3),9,7,
        TOT=(16,3,ZD,TO=ZD,LENGTH=3),19,11,
        COUNT=(M11,LENGTH=9)))
/*
Back to top
View user's profile Send private message
Steve Davies

New User


Joined: 15 Oct 2009
Posts: 32
Location: UK

PostPosted: Fri Oct 16, 2009 9:41 pm
Reply with quote

Thanks Frank, I've just tried your solution and it worked. I won't pretend to understand it, but I'll look in the manuals and figure out how it works!

Many thanks for your solution.
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 Oct 16, 2009 10:33 pm
Reply with quote

Ok, if you can't figure it out, let me know and I'll explain it (or just run INREC alone with COPY, and then just INREC with SORT, to see the intermediate output which should help you figure out what's going on).
Back to top
View user's profile Send private message
pradeepgarje

New User


Joined: 08 Apr 2009
Posts: 4
Location: Mumbai

PostPosted: Mon Oct 26, 2009 6:34 pm
Reply with quote

Hi Frank Yaeger,

Can you please let me about significance of

//
COUNT=(M11,LENGTH=9)
//

I confused on M11. I tried to change the value of M11 to M10 and greater than 11. Alll are excepted. but M09 not worked.
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: Mon Oct 26, 2009 9:02 pm
Reply with quote

M11 is an edit mask with leading zeros, e.g.

Code:

00000000001


M10 is an edit mask with leading blanks for zeros, e.g.

Code:

          1


M09 is not a valid edit mask. M9 is a valid edit mask for a date like 'mm/dd/yy' so I doubt that's one you want to use.

For a Table showing all of the pre-defined edit masks, see:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA40/TBLOFMASKX?SHELF=&DT=20090527161936&CASE=&ScrollTOP=TBLOFMASKX#TBLOFMASKX
Back to top
View user's profile Send private message
pradeepgarje

New User


Joined: 08 Apr 2009
Posts: 4
Location: Mumbai

PostPosted: Tue Oct 27, 2009 9:54 am
Reply with quote

Thanks a lot Frank Yaeger !!
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 DFSORT GUID DFSORT/ICETOOL 3
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 4
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
Search our Forums:

Back to Top