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

How to add two column values in Sort.


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

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Tue Aug 28, 2007 1:06 pm
Reply with quote

Hi,
I have a Flat file in which i have 4 columns A,B,C and D.
I want to add values of COlumn B and Column C . Can this be done using Sort utility.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Tue Aug 28, 2007 1:25 pm
Reply with quote

Code:
// EXEC PGM=SORT                                 
//SORTIN DD *                                   
1111111111 9999999.99 9999999.99                 
2222222222-8888888.88 8888888.88                 
3333333333 7777777.77-7777777.77                 
4444444444-6666666.66-6666666.66                 
5555555555+5555555.55 5555555.55                 
6666666666 4444444.44+4444444.44                 
7777777777+3333333.33+3333333.33                 
8888888888 2222222.22 2222222.22                 
9999999999 1111111.11 1111111.11                 
/*                                               
//SORTOUT DD SYSOUT=*                           
//SYSOUT DD SYSOUT=*                             
//SYSIN DD *                                     
 OPTION COPY                                     
 INREC OVERLAY=(33:11,11,SFF,ADD,22,11,SFF,     
 EDIT=(STTTTTTTT.TT),SIGNS=(+,-))               
/*                                               
//

Output:
Code:
1111111111 9999999.99 9999999.99+19999999.98
2222222222-8888888.88 8888888.88+00000000.00
3333333333 7777777.77-7777777.77+00000000.00
4444444444-6666666.66-6666666.66-13333333.32
5555555555+5555555.55 5555555.55+11111111.10
6666666666 4444444.44+4444444.44+08888888.88
7777777777+3333333.33+3333333.33+06666666.66
8888888888 2222222.22 2222222.22+04444444.44
9999999999 1111111.11 1111111.11+02222222.22
Back to top
View user's profile Send private message
Raghavendra P K

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Tue Aug 28, 2007 2:49 pm
Reply with quote

Hi Shankar,
Its working . I have one more question ,after adding two columns i want to sort the file. I know that if i use one more sort step i can do that ,is there any way where i can add and sort the files in a single sort step.

thanks,
Raghav
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Tue Aug 28, 2007 2:58 pm
Reply with quote

Raghavendra P K,
Remove the OPTION COPY and give SORT FIELDS=(p,m,f,o)
Back to top
View user's profile Send private message
Raghavendra P K

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Tue Aug 28, 2007 4:06 pm
Reply with quote

hi Shankar,
i have used another step its working fine.

thanks,
Raghav
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Aug 28, 2007 7:49 pm
Reply with quote

Quote:
i have used another step its working fine.


Shankar is correct that INREC is processed before SORT, so you can add the fields and then do the SORT in one step.

Why exactly did you feel you had to use another step? Please explain what you're doing and show the job you used, so we can tell you if you can in fact do it in one step.
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top