Posted: Tue Sep 23, 2008 6:52 am Post subject: Sum of the records between group of records
Hi,
I am having a FB file of length 80.The sample input looks like this.
Code:
M01
S225
627 AA bb 84
627 BB bb 05
627 CC zz 06
627 AA bb 05
T225
S225
628 ab cd 12
T225
S225
627 ZZ kk 08
627 XX kk 12
627 ZZ kx 06
T225
Z0000
Here the record type M(position 1) is the main header and
record type Z is the main trailer.Record S and T are of sub
header and trailers.Record type '6' is the detail record.I
want to sum up the values of record type 6 when the second
and third fields are same under the same group.The o/p should look like
Code:
M01
S225
627 AA bb 89
627 BB bb 05
627 CC zz 06
T225
S225
628 ab cd 12
T225
S225
627 ZZ kk 08
627 XX kk 12
627 ZZ kx 06
T225
Z0000
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue Sep 23, 2008 10:58 am Post subject:
bprasanna,
You can do this kind of thing quite easily and efficiently with the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this
Code:
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
M01
S225
627 AA BB 84
627 BB BB 05
627 CC ZZ 06
627 AA BB 05
T225
S225
628 AB CD 12
T225
S225
627 ZZ KK 08
627 XX KK 12
627 ZZ KX 06
T225
Z0000
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS
INREC IFTHEN=(WHEN=INIT,OVERLAY=(89:4X,2C'0')),
IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'S'),END=(1,1,CH,EQ,C'T'),
PUSH=(81:ID=8)),
IFTHEN=(WHEN=(1,1,CH,EQ,C'M'),OVERLAY=(81:8C'0')),
IFTHEN=(WHEN=(1,1,CH,EQ,C'6'),OVERLAY=(89:8,2,11,2,14,2)),
IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),OVERLAY=(89:4C'9')),
IFTHEN=(WHEN=(1,1,CH,EQ,C'Z'),OVERLAY=(81:8C'9'))
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue Sep 23, 2008 12:46 pm Post subject:
Here's another way to do it with DFSORT's new WHEN=GROUP function:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
M01
S225
627 AA bb 84
627 BB bb 05
627 CC zz 06
627 AA bb 05
T225
S225
628 ab cd 12
T225
S225
627 ZZ kk 08
627 XX kk 12
627 ZZ kx 06
T225
Z0000
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS,ZDPRINT
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,SS,EQ,C'MSZ'),
PUSH=(81:ID=8)),
IFTHEN=(WHEN=(1,1,CH,EQ,C'S'),OVERLAY=(89:C'0')),
IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),OVERLAY=(89:C'9')),
IFTHEN=(WHEN=(1,1,CH,EQ,C'6'),OVERLAY=(89:1,1,8,2,11,2))
SORT FIELDS=(81,13,CH,A)
SUM FIELDS=(14,2,ZD)
OUTREC BUILD=(1,80)
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue Sep 23, 2008 2:18 pm Post subject:
Ask your System Programmer to install z/OS DFSORT V1R5 PTF UK90013 (it's free). _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum