Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sum up different columns in SORT JCL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sum up different columns in SORT JCL
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: 1439
Location: Bangalore,India

PostPosted: Thu Nov 22, 2007 10:51 am    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 10:55 am    Post subject: Reply to: Query in SORT JCL
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: 1439
Location: Bangalore,India

PostPosted: Thu Nov 22, 2007 10:58 am    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 11:10 am    Post subject: Reply to: Query in SORT JCL
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 3:29 pm    Post subject: Reply to: Query in SORT JCL
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    Post subject:
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 3:54 pm    Post subject: Reply to: Query in SORT JCL
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: 1288
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 3:56 pm    Post subject: Reply to: Query in SORT JCL
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    Post subject: Reply to: Query in SORT JCL
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: 1288
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 5:22 pm    Post subject: Reply to: Query in SORT JCL
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

Senior Member


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

PostPosted: Thu Nov 22, 2007 7:10 pm    Post subject:
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Fri Nov 23, 2007 8:30 am    Post subject: Reply to: Query in SORT JCL
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: 37
Location: India

PostPosted: Fri Nov 23, 2007 9:25 am    Post subject: Reply to: Query in SORT JCL
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us