View previous topic :: View next topic |
Author |
Message |
vivek1983 Intermediate
Joined: 20 Apr 2006 Posts: 222 Topics: 24
|
Posted: Fri Aug 29, 2008 7:33 am Post subject: Adding Edited Fields |
|
|
Hi,
I was wondering if we can do this in Sort using a single step. Below is the scenario:
Input data:
Code: |
AAAAA 151,864.74
AAAAA 149,573.09
|
Output:
Can we add numeric edited fields?
I did the following and obtained the result using REXX.
1. Removed the Comma.
2. Right justified the numeric fields.
3. Added the numeric fields.
Can we do this in a simple sort step?
Thanks much. _________________ Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay) |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Fri Aug 29, 2008 8:55 am Post subject: |
|
|
vivek1983,
The following DFSORT JCL will give you desired results
Code: |
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5-
AAAAA 151,864.74
AAAAA 149,573.09
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,5,
TRAILER3=(1,5,2X,
TOT=(28,10,UFF,EDIT=(IIIIIIIIIT.TT))))
/*
|
Hope this helps...
Cheers _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Fri Aug 29, 2008 10:12 am Post subject: |
|
|
Vivek,
Note that Kolusu is assuming you have multiple keys and want a total for each. It's not clear from your input example whether that's what you want or not. If you just want an overall total for all of the records, you could use these DFSORT control statements:
Code: |
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=(1,5,2X,
TOT=(28,10,UFF,EDIT=(IIIIIIIIIT.TT)))
|
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Sat Mar 20, 2010 7:18 pm Post subject: |
|
|
Right, I am also looking for a Syncsort solution to get an overall sum of a column of numbers... (Not asking you specifically, Frank, since I know you're a DFSORT guy ....) |
|
Back to top |
|
|
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Mon Mar 22, 2010 10:58 am Post subject: |
|
|
Look up SUM FIELDS.
Here is an example:
SUM FIELDS=(041,5,36,5),FORMAT=PD _________________ Thanks,
NASCAR9 |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Mon Mar 22, 2010 12:10 pm Post subject: |
|
|
NASCAR9 wrote: | Look up SUM FIELDS.
Here is an example:
SUM FIELDS=(041,5,36,5),FORMAT=PD |
Nascar9,
How did you conclude that the format of the numeric fields is PD format? _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Mon Mar 22, 2010 12:21 pm Post subject: |
|
|
I used one of my current sort examples. I did not mean to imply the data above is packed. This was intended to be only an example.
After looking at the data I see decimal points and commas. Theses would need to be stripped first.
I don't know Syncsort as well as I once did, there may be a better solution I don't know about. _________________ Thanks,
NASCAR9 |
|
Back to top |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Mon Mar 22, 2010 12:46 pm Post subject: |
|
|
I can get the desired result by sorting on another column that contains the same value on every record, like column 3 in the example below, that always contains a space. But I guess I thought there would be a way to do it without actually 'sorting' ......
Code: | //S7 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTWK01 DD UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE)
//SORTIN DD *
02
05
12
15
11
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(3,1,CH,A)
SUM FIELDS=(1,2),FORMAT=ZD
/*
//
Result:
WER052I END SYNCSORT - H2501STT
45
|
|
|
Back to top |
|
|
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Mon Mar 22, 2010 12:54 pm Post subject: |
|
|
tcurrier,
This may work for you, I have userd it many times(I have not tested it yet with a sort sum):
SORT FIELDS=COPY _________________ Thanks,
NASCAR9 |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Mon Mar 22, 2010 3:02 pm Post subject: |
|
|
Quote: |
I am also looking for a Syncsort solution to get an overall sum of a column of numbers
| What release of Syncsort is being used? _________________ All the best,
di
Last edited by papadi on Mon Mar 22, 2010 3:12 pm; edited 1 time in total |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Mon Mar 22, 2010 3:05 pm Post subject: |
|
|
tcurrier,
well I am being generous today , so here is a version which would work with any version of sort
Code: |
//S7 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
02
05
12
15
11
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=(TOT=(1,2,ZD,M10,LENGTH=8))
//* |
NASCAR9,
NASCAR9 wrote: | This may work for you, I have userd it many times(I have not tested it yet with a sort sum):
SORT FIELDS=COPY |
Your SUM statement is ignored once SORT FIELDS=COPY is detected and it would be just a plain copy of input to output without summation. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Mon Mar 22, 2010 3:19 pm Post subject: |
|
|
Thanks, Kolusu... that worked fine....
Now I'll be prepared when our shop gives FILEAID the boot, and
the FILEAID Tally/Accum function is gone.
|
|
Back to top |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Mon Mar 22, 2010 3:33 pm Post subject: |
|
|
Papadi,
Syncsort version is: SYNCSORT FOR Z/OS 1.3.2.1N |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Mon Mar 22, 2010 4:40 pm Post subject: |
|
|
Thanks for the update, but it looks like you're good to go. . . _________________ All the best,
di |
|
Back to top |
|
|
|
|