View previous topic :: View next topic
Author
Message
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
miosne
Check this code with sample example, it sums Horizontal as well as vertical.
Assumed LRECL is 80,modify as per your requirent.
Code:
//********************************************************************
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
AAAAA 11.34 34.45 62.43
AAAAA 14.34 44.45 62.43
AAAAA 12.34 34.45 62.43
AAAAA 12.34 34.55 62.43
ABBBB 32.43 54.24 34.54
ABBBB 32.43 64.23 34.54
ABBBB 32.43 54.23 14.54
/*
//SORTOUT DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//SYSIN DD *
SORT FIELDS=(1,5,CH,A)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,5,
TRAILER3=(1,5,8:TOT=(8,7,UFF,TO=ZD,LENGTH=7),
16:TOT=(16,7,UFF,TO=ZD,LENGTH=7),
24:TOT=(24,7,UFF,TO=ZD,LENGTH=7),80:X))
/*
//********************************************************************
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&TEMP1,DISP=(MOD,PASS)
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(50:(8,7,ZD,ADD,
16,7,ZD,ADD,
24,7,ZD),EDIT=(IIIIT.TT),
8:8,7,ZD,EDIT=(IIIIT.TT),
16:16,7,ZD,EDIT=(IIIIT.TT),
24:24,7,ZD,EDIT=(IIIIT.TT))
/*
SORTOUT
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
AAAAA 50.36 147.90 249.72 447.98
ABBBB 97.29 172.70 83.62 353.61
If still, this not what you wanted then i failed in understanding your requirement
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19243 Location: Inside the Matrix
Hi Krisprems,
Me again Looks good. I believe you are quite close.
I suspect that a "final total" line at the bottom is also needed.
Back to top
miosne Warnings : 1 New User Joined: 13 Mar 2006Posts: 63 Location: italy
Thank you very much for your, the same for the others members, patience!!!!!!!
It works!!!!!!!
I've only one question more:
If the i/p file have occurs-100 field.
I've to write 100 of "8:8,7,ZD,EDIT=(IIIIT.TT)"
Is there any method to do this???
Back to top
miosne Warnings : 1 New User Joined: 13 Mar 2006Posts: 63 Location: italy
dick scherrer wrote:
Hi Krisprems,
Me again :) Looks good. I believe you are quite close.
I suspect that a "final total" line at the bottom is also needed.
yes, dick.
Back to top
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
Quote:
I suspect that a "final total" line at the bottom is also needed.
This is accomplished below
Code:
//********************************************************************
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAAA 11.34 34.45 62.43
AAAAA 14.34 44.45 62.43
AAAAA 12.34 34.45 62.43
AAAAA 12.34 34.55 62.43
ABBBB 32.43 54.24 34.54
ABBBB 32.43 64.23 34.54
ABBBB 32.43 54.23 14.54
/*
//SORTOUT DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//SYSIN DD *
SORT FIELDS=(1,5,CH,A)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,5,
TRAILER3=(1,5,8:TOT=(8,7,UFF,TO=ZD,LENGTH=7),
16:TOT=(16,7,UFF,TO=ZD,LENGTH=7),
24:TOT=(24,7,UFF,TO=ZD,LENGTH=7),80:X))
/*
//********************************************************************
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&TEMP1,DISP=(MOD,PASS)
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(50:(8,7,ZD,ADD,
16,7,ZD,ADD,
24,7,ZD),EDIT=(IIIIT.TT),
8:8,7,ZD,EDIT=(IIIIT.TT),
16:16,7,ZD,EDIT=(IIIIT.TT),
24:24,7,ZD,EDIT=(IIIIT.TT),81:C'1')
OUTFIL REMOVECC,
SECTIONS=(81,1,
TRAILER3=(8:TOT=(8,7,UFF,EDIT=(IIIIT.TT)),
16:TOT=(16,7,UFF,EDIT=(IIIIT.TT)),
24:TOT=(24,7,UFF,EDIT=(IIIIT.TT)))),
BUILD=(1,80)
/*
Hope this is the final SORT JCL required.
SORTOUT contains:
Code:
AAAAA 50.36 147.90 249.72 447.98
ABBBB 97.29 172.70 83.62 353.61
14.75 32.06 33.33
Quote:
Me again Looks good. I believe you are quite close.
Reading this, looks like the bricks have stopped falling on me.
Quote:
I've only one question more:
If the i/p file have occurs-100 field.
I've to write 100 of "8:8,7,ZD,EDIT=(IIIIT.TT)"
Is there any method to do this???
You can do it another way, but if it is just 100, i guess you could repeat the line's and just specify the required offset.
If you really need to do it by another way then let me know the exact offset(positions) of the field to be summed.
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19243 Location: Inside the Matrix
One more time. . . .
I believe i'm now having a "brick attack". . .
Code:
AAAAA 50.36 147.90 249.72 447.98
ABBBB 97.29 172.70 83.62 353.61
14.75 32.06 33.33
How were the values in the last line created? They don't appear to be the sum of the previous detail lines?
Also, does the total need to be "wider" than the individual columns?
Back to top
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
Quote:
How were the values in the last line created? They don't appear to be the sum of the previous detail lines?
Step2 corrected
Code:
//********************************************************************
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&TEMP1,DISP=(MOD,PASS)
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(50:(8,7,ZD,ADD,
16,7,ZD,ADD,
24,7,ZD),EDIT=(IIIIT.TT),
8:8,7,ZD,EDIT=(IIIIT.TT),
16:16,7,ZD,EDIT=(IIIIT.TT),
24:24,7,ZD,EDIT=(IIIIT.TT),81:C'1')
OUTFIL REMOVECC,
SECTIONS=(81,1,
TRAILER3=(8:TOT=(8,8,UFF,EDIT=(IIIIT.TT)),
16:TOT=(16,8,UFF,EDIT=(IIIIT.TT)),
24:TOT=(24,8,UFF,EDIT=(IIIIT.TT)))),
BUILD=(1,80)
/*
SORTOUT
Code:
AAAAA 50.36 147.90 249.72 447.98
ABBBB 97.29 172.70 83.62 353.61
147.65 320.60 333.34
Quote:
Also, does the total need to be "wider" than the individual columns?
Thought that would be better always...
Else the person will come back with Overflow abend
Back to top
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
Since the requirement was understood in bits and pieces, couldn't provide efficient solution with a single try.
Single step/pass SORT solution is provided here
Code:
//********************************************************************
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAAA 11.34 34.45 62.43
AAAAA 14.34 44.45 62.43
AAAAA 12.34 34.45 62.43
AAAAA 12.34 34.55 62.43
ABBBB 32.43 54.24 34.54
ABBBB 32.43 64.23 34.54
ABBBB 32.43 54.23 14.54
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC OVERLAY=(8:8,7,UFF,TO=ZD,LENGTH=7,
16:16,7,UFF,TO=ZD,LENGTH=7,
24:24,7,UFF,TO=ZD,LENGTH=7)
SORT FIELDS=(1,5,CH,A)
SUM FIELDS=(8,7,ZD,16,7,ZD,24,7,ZD)
OUTFIL REMOVECC,
SECTIONS=(80,1,
TRAILER3=(8:TOT=(8,7,ZD,EDIT=(IIIIT.TT)),
16:TOT=(16,7,ZD,EDIT=(IIIIT.TT)),
24:TOT=(24,7,ZD,EDIT=(IIIIT.TT)))),
OVERLAY=(50:(8,7,ZD,ADD,
16,7,ZD,ADD,
24,7,ZD),EDIT=(IIIIT.TT),
08:8,7,ZD,EDIT=(IIIIT.TT),
16:16,7,ZD,EDIT=(IIIIT.TT),
24:24,7,ZD,EDIT=(IIIIT.TT))
/*
SORTOUT
Code:
AAAAA 50.36 147.90 249.72 447.98
ABBBB 97.29 172.70 83.62 353.61
147.65 320.60 333.34
Back to top
Please enable JavaScript!