View previous topic :: View next topic
|
Author |
Message |
Raghavendra P K
New User
Joined: 24 Aug 2007 Posts: 24 Location: bangalore
|
|
|
|
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 |
|
|
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
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 |
|
|
Raghavendra P K
New User
Joined: 24 Aug 2007 Posts: 24 Location: bangalore
|
|
|
|
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 |
|
|
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
Raghavendra P K,
Remove the OPTION COPY and give SORT FIELDS=(p,m,f,o) |
|
Back to top |
|
|
Raghavendra P K
New User
Joined: 24 Aug 2007 Posts: 24 Location: bangalore
|
|
|
|
hi Shankar,
i have used another step its working fine.
thanks,
Raghav |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
|