MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Adding Edited Fields

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Fri Aug 29, 2008 7:33 am    Post subject: Adding Edited Fields Reply with quote

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:

Code:

AAAAA    301437.83


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


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri Aug 29, 2008 8:55 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Aug 29, 2008 10:12 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Sat Mar 20, 2010 7:18 pm    Post subject: Reply with quote

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


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Mon Mar 22, 2010 10:58 am    Post subject: Reply with quote

Look up SUM FIELDS.

Here is an example:
SUM FIELDS=(041,5,36,5),FORMAT=PD
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Mar 22, 2010 12:10 pm    Post subject: Reply with quote

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? Question
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Mon Mar 22, 2010 12:21 pm    Post subject: Reply with quote

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


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Mon Mar 22, 2010 12:46 pm    Post subject: Reply with quote

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


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Mon Mar 22, 2010 12:54 pm    Post subject: Reply with quote

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


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Mon Mar 22, 2010 3:02 pm    Post subject: Reply with quote

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


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Mar 22, 2010 3:05 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Mon Mar 22, 2010 3:19 pm    Post subject: Reply with quote

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.

Very Happy
Back to top
View user's profile Send private message
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Mon Mar 22, 2010 3:33 pm    Post subject: Reply with quote

Papadi,

Syncsort version is: SYNCSORT FOR Z/OS 1.3.2.1N
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Mon Mar 22, 2010 4:40 pm    Post subject: Reply with quote

Thanks for the update, but it looks like you're good to go. . . Smile
_________________
All the best,

di
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group