View previous topic :: View next topic
|
Author |
Message |
Steve Davies
New User

Joined: 15 Oct 2009 Posts: 32 Location: UK
|
|
|
|
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
[email protected]
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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
[email protected]
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 |
|
 |
Steve Davies
New User

Joined: 15 Oct 2009 Posts: 32 Location: UK
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
pradeepgarje
New User
Joined: 08 Apr 2009 Posts: 4 Location: Mumbai
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
Back to top |
|
 |
pradeepgarje
New User
Joined: 08 Apr 2009 Posts: 4 Location: Mumbai
|
|
|
|
Thanks a lot Frank Yaeger !! |
|
Back to top |
|
 |
|
 |
All times are GMT + 6 Hours |
|