IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sum up different columns in SORT JCL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
priyacm

New User


Joined: 20 Nov 2007
Posts: 2
Location: chennai

PostPosted: Thu Nov 22, 2007 10:41 am
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Nov 22, 2007 10:51 am
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 10:55 am
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Nov 22, 2007 10:58 am
Reply with quote

Priya,

icon_redface.gif 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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 11:10 am
Reply with quote

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
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Nov 22, 2007 3:15 pm
Reply with quote

Aaru
why do you require SFF?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 3:29 pm
Reply with quote

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
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Nov 22, 2007 3:42 pm
Reply with quote

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
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Thu Nov 22, 2007 3:44 pm
Reply with quote

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... icon_wink.gif
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 3:54 pm
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 3:56 pm
Reply with quote

Krisprem,

Quote:
Note: SFF may degrade the performance.
Dont use it untill and unless its really required!


Thanks for the information.
Back to top
View user's profile Send private message
nprathap4u

New User


Joined: 24 Apr 2007
Posts: 15
Location: India

PostPosted: Thu Nov 22, 2007 5:18 pm
Reply with quote

May i know what is EDIT=TTTT..?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 5:22 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Nov 22, 2007 7:10 pm
Reply with quote

I think TS has changed his/her planet..grin..
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Nov 22, 2007 7:14 pm
Reply with quote

Quote:
DFSORT getting sorted pdf
icon_biggrin.gif
Its z/OS V1R8.0 DFSORT: Getting Started"
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Nov 23, 2007 8:30 am
Reply with quote

Krisprem,

Quote:
DFSORT getting sorted pdf
icon_biggrin.gif



Thanks for the link. what is there to be happy about?
Back to top
View user's profile Send private message
kovur

New User


Joined: 15 Nov 2007
Posts: 36
Location: India

PostPosted: Fri Nov 23, 2007 9:25 am
Reply with quote

Aaru,
Kris is pointing to your previous post which says
getting sorted, instead of getting started.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Increase the number of columns in the... IBM Tools 3
Search our Forums:

Back to Top