MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
coolguy Beginner Joined: 01 Dec 2004 Posts: 82 Topics: 28
Posted: Tue Jun 07, 2005 4:42 am Post subject: Update the total in Master record with Detail records
Hi All
I have file lrecl 80 fb It has master record aswell as detail recoer
I/p
Code:
1223 M 0
1223 D 12
1223 D 24
1224 M 0
1224 D 1
1224 D 4
the o/p
Code:
1223 M 36
1223 D 12
1223 D 24
1224 M 5
1224 D 1
1224 D 4
Cna we do in in Sort pls help me
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue Jun 07, 2005 7:42 am Post subject:
The following DFSORT/ICETOOL JCL will give you the desired results. If you have syncsort at your shop then change the pgm name to synctool.
I assumed that following layout for the input data.
Code:
01 Account-no pic x(05).
01 filler pic x(01).
01 account-type pic x(01).
01 amount pic 9(09) With leading zeroes supressed.
A brief explanation of the job. The first sort step takes in the input file and add an indicator at the end of every record which changes all the detail(D) record type to Master(M) record type and sort on the account-no and account-type. when you do like that the master record will be at last for each account-no.
Now we use the sections parm along with trailer parm to get the totals for each account and create a file t1.
The next step takes in this file eliminates the unwanted records and re-sorts on the indicator at the end along with the account-no to achieve the desired results.
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
1223 M 0
1223 D 12
1223 D 24
1224 M 1
1224 D 0
1224 D 4
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) USING(CTL2)
//CTL1CNTL DD *
INREC FIELDS=(1,15,
16:6,1,CHANGE=(1,C'D',C'M'),NOMATCH=(6,1),
8,9,FS,ZD,LENGTH=9)
SORT FIELDS=(1,5,CH,A,6,1,CH,A)
OUTFIL FNAMES=T1,REMOVECC,
SECTIONS=(1,5,16,1,
TRAILER3=(1,15,C'A',TOT=(17,9,ZD,M11,LENGTH=9)))
//CTL2CNTL DD *
OMIT COND=(6,1,CH,EQ,16,1,CH)
SORT FIELDS=(01,05,CH,A,
16,01,CH,A)
OUTFIL FNAMES=OUT,
OUTREC=(1,7,17,9,ZD,M10,LENGTH=9)
/*
Hope this helps...
Cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
coolguy Beginner Joined: 01 Dec 2004 Posts: 82 Topics: 28
Posted: Tue Jun 07, 2005 9:10 am Post subject:
Hi Kolusu
I am getting only 2 records all other are elemented any oter idea
1223 D 36
1224 D 5
Ravi
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue Jun 07, 2005 9:13 am Post subject:
Coolguy,
Did you run the job posted by me as is? If you are not getting the desired results then post your JOB along with file layout
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
coolguy Beginner Joined: 01 Dec 2004 Posts: 82 Topics: 28
Posted: Tue Jun 07, 2005 9:18 am Post subject:
Code:
//V667499R JOB (P,JTXU,BA3211),'LOG RPT',
// MSGCLASS=T,REGION=0M,NOTIFY=&SYSUID,TIME=1
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
1223 M000000000
1223 D000000012
1223 D000000024
1224 M000000001
1224 D000000000
1224 D000000004
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) USING(CTL2)
//CTL1CNTL DD *
INREC FIELDS=(1,15,
16:6,1,CHANGE=(1,C'D',C'M'),NOMATCH=(6,1),
8,9,FS,ZD,LENGTH=9)
SORT FIELDS=(1,5,CH,A,6,1,CH,A)
OUTFIL FNAMES=T1,REMOVECC,
SECTIONS=(1,5,16,1,
TRAILER3=(1,15,C'A',TOT=(17,9,ZD,M11,LENGTH=9)))
//CTL2CNTL DD *
OMIT COND=(6,1,CH,EQ,16,1,CH)
SORT FIELDS=(01,05,CH,A,
16,01,CH,A)
OUTFIL FNAMES=OUT,
OUTREC=(1,7,17,9,ZD,M10,LENGTH=9)
/*
thsi is jcl I run ?
Back to top
coolguy Beginner Joined: 01 Dec 2004 Posts: 82 Topics: 28
Posted: Tue Jun 07, 2005 9:55 am Post subject:
Hi Kolusu
copy book si same as
01 account
03 Account-no pic x(05).
03 filler pic x(01).
03 account-type pic x(01).
03 amount pic 9(09)
This copy book format
coolguy
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue Jun 07, 2005 10:05 am Post subject:
coolguy,
I guess your shop does not have the OPTION EQUALS as default. so I added that as well as fixed a couple of errors in your control cards.
try this job.
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
1223 M000000000
1223 D000000012
1223 D000000024
1224 M000000001
1224 D000000000
1224 D000000004
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) USING(CTL2)
//CTL1CNTL DD *
INREC FIELDS=(1,15,
16:6,1,CHANGE=(1,C'D',C'M'),NOMATCH=(6,1))
SORT FIELDS=(1,5,CH,A,6,1,CH,A)
OUTFIL FNAMES=T1,REMOVECC,
SECTIONS=(1,5,16,1,
TRAILER3=(1,6,TOT=(7,9,ZD,M11,LENGTH=9),C'A'))
//CTL2CNTL DD *
OPTION EQUALS
OMIT COND=(6,1,CH,EQ,16,1,CH)
SORT FIELDS=(01,05,CH,A,
16,01,CH,A)
OUTFIL FNAMES=OUT,
OUTREC=(1,6,7,9,ZD,M10,LENGTH=9)
/*
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
coolguy Beginner Joined: 01 Dec 2004 Posts: 82 Topics: 28
Posted: Wed Jun 08, 2005 3:57 am Post subject:
Thanks it is working fine
Back to top
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