Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DFSORT SUM and COUNTing records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: DFSORT SUM and COUNTing records
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 Moderator


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

PostPosted: Fri Oct 16, 2009 9:18 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Fri Oct 16, 2009 10:33 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Mon Oct 26, 2009 9:02 pm    Post subject:
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:

http://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    Post subject:
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    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 Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us