View previous topic :: View next topic
|
Author |
Message |
priyacm
New User
Joined: 20 Nov 2007 Posts: 2 Location: chennai
|
|
|
|
HI,
How to sum up different columns in a PS or a VSAM file using sort in a jcl
For example,
If i have a input file like this
A 1 2 3
B 4 5 6
C 7 8 9
The output needs to be like this
A 1 2 3 6
B 4 5 6 15
C 7 8 9 24 |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Priya,
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
A 1 2 3
B 4 5 6
C 7 8 9
/*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL OVERLAY=(15:((1,1,ZD,ADD,5,1,ZD),ADD,7,1,ZD),EDIT=(TTTT))
/* |
o/p:
Code: |
---+----1----+----2----+----3---
********************************
A 1 2 3 6
B 4 5 6 13
C 7 8 9 20
******************************** |
Change the above card to your requirement. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Priya,
Check this JCL.
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A 1 2 3
B 4 5 6
C 7 8 9
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(9:3,1,SFF,ADD,5,1,SFF,ADD,7,1,SFF,
EDIT=(TT))
/*
|
change as per your reqt. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Priya,
ops!!! Change the OUTFIL OVERLAY statement in my prev post to -
Code: |
OUTFIL OVERLAY=(15:((3,1,ZD,ADD,5,1,ZD),ADD,7,1,ZD),EDIT=(TTTT)) |
|
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Priya,
Check this JCL.
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A 1 2 3
B 4 5 6
C 7 8 9
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(9:3,1,SFF,ADD,5,1,SFF,ADD,7,1,SFF,
EDIT=(TT))
/*
|
change as per your reqt. |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
Aaru
why do you require SFF? |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Krisprems,
Quote: |
Aaru
why do you require SFF? |
Actually SFF is not mandatary here, but mentioning it here will not lead to wrong results. This would also work if signs(+ and -) are present in the input.
Priya,
You can also replace SFF by ZD as shown below.
Code: |
INREC OVERLAY=(9:3,1,ZD,ADD,5,1,ZD,ADD,7,1,ZD,
EDIT=(TT))
|
Prem, Is that fine? |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
Quote: |
Actually SFF is not mandatary here, but mentioning it here will not lead to wrong results. This would also work if signs(+ and -) are present in the input.
|
Note: SFF may degrade the performance.
Dont use it untill and unless its really required! |
|
Back to top |
|
|
raak
Active User
Joined: 23 May 2006 Posts: 166 Location: chennai
|
|
|
|
guys, sorry to interfere....one small doubt..
What if I wanna subtract the last field from the sum of all other fields..
i.e. if i/p is
5 5 6
then I want the output as
5 5 6 04
04 comes from 5+5-6..
just curious... |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
raak,
Quote: |
What if I wanna subtract the last field from the sum of all other fields..
|
Use SUB instead of ADD
Code: |
INREC OVERLAY=(9:3,1,ZD,ADD,5,1,ZD,SUB,7,1,ZD,
EDIT=(TT))
|
|
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Krisprem,
Quote: |
Note: SFF may degrade the performance.
Dont use it untill and unless its really required! |
Thanks for the information. |
|
Back to top |
|
|
nprathap4u
New User
Joined: 24 Apr 2007 Posts: 15 Location: India
|
|
|
|
May i know what is EDIT=TTTT..? |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
npratap,
Quote: |
May i know what is EDIT=TTTT..? |
It is an edit mask pattern. Do take a look at the "DFSORT getting sorted pdf" in the manuals section to know more about edit masks. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
I think TS has changed his/her planet..grin.. |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Krisprem,
Quote: |
DFSORT getting sorted pdf
|
Thanks for the link. what is there to be happy about? |
|
Back to top |
|
|
kovur
New User
Joined: 15 Nov 2007 Posts: 36 Location: India
|
|
|
|
Aaru,
Kris is pointing to your previous post which says
getting sorted, instead of getting started. |
|
Back to top |
|
|
|