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
 

 

Simple sort question?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
mikeleibo1

New User


Joined: 23 Jul 2007
Posts: 4
Location: GA

PostPosted: Sat Jan 26, 2008 1:41 am    Post subject: Simple sort question?
Reply with quote

Sorry but I don't have a manual and trying to figure out what to do without it is pretty tough using the online manaual so thanks in advance for your help... Mike

We have variable records coming in with a sort key in columns 5-20. Starting in 21, left justified are numbers that I want to sum on equal keys:
I am not sure of the length of the field to be summed it might be max of 8

i.e.
1234567890123456789012345678901

lnth(-----------------key---------------)29 <== rec 1
lnth(-----------------key---------------)2900 <== rec 2
lnth(-----------------key---------------)290000 <== rec 3

output rec:

lnth(-----------------key---------------)292929 <== sum
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jan 26, 2008 2:07 am    Post subject:
Reply with quote

Hi Mike and welcome to the forums,

If there is no definite length, how do you know when to "stop"? Is there some kind of delimiter? Is the only data after the key, the value to be summed (in all records)?

If you post the lrecl and recfm of the input file, show a more(?) representative sample of some input records, and post what you need for output, we should be able to offer suggestions.

There is a wealth of dfsort info here:
http://www.ibm.com/storage/dfsort/

Much may be downloaded.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Sat Jan 26, 2008 2:32 am    Post subject:
Reply with quote

Mike,

Assuming that lnth is actually the 4-byte RDW and that you want the sum values left-justified, you can use a DFSORT job like this:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT DD DSN=...  output file (VB)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:21,8,UFF,TO=ZD,LENGTH=8))
  SORT FIELDS=(5,16,CH,A)
  OPTION ZDPRINT
  SUM FIELDS=(21,8,ZD)
  OUTREC OVERLAY=(21:21,8,ZD,TO=FS,LENGTH=8,
    21:21,8,JFY=(SHIFT=LEFT))
/*


If that doesn't give you what you need, then please be more specific about what you do need.
Back to top
View user's profile Send private message
mikeleibo1

New User


Joined: 23 Jul 2007
Posts: 4
Location: GA

PostPosted: Sat Jan 26, 2008 2:36 am    Post subject: thanks and...
Reply with quote

The column I'm summing is from total records reflecting the number of records in several files

So i'm trying to create a trailer...

It does have a max length - it may be up 9 long (up to several hundred million records
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Sat Jan 26, 2008 2:55 am    Post subject:
Reply with quote

If the values to be summed can be up to 9 bytes long, then just change the control statements in the job I showed to:

Code:

  INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:21,9,UFF,TO=ZD,LENGTH=9)) 
  SORT FIELDS=(5,16,CH,A)                                       
  OPTION ZDPRINT                                                 
  SUM FIELDS=(21,9,ZD)                                           
  OUTREC OVERLAY=(21:21,9,ZD,TO=FS,LENGTH=9,                     
    21:21,9,JFY=(SHIFT=LEFT))   
Back to top
View user's profile Send private message
mikeleibo1

New User


Joined: 23 Jul 2007
Posts: 4
Location: GA

PostPosted: Sat Jan 26, 2008 2:57 am    Post subject: ha - thanks
Reply with quote

the outrec had a format error - i deleted the last two lines and it works great!

Where are you? you deserve a beer icon_smile.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Sat Jan 26, 2008 3:09 am    Post subject:
Reply with quote

Quote:
the outrec had a format error


Did it flag JFY as the error? If so, you're missing the DFSORT April, 2006 PTF that added the JFY function. Ask your System Programmer to install z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006. For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

The OUTREC statement's purpose is to left justify the sum. If you removed the OUTREC and got what you want, then you obviously don't need the sum left justified.

Quote:
Where are you? you deserve a beer


I'm in San Jose, CA. You can send me a virtual beer. icon_wink.gif
Back to top
View user's profile Send private message
mikeleibo1

New User


Joined: 23 Jul 2007
Posts: 4
Location: GA

PostPosted: Sat Jan 26, 2008 3:23 am    Post subject: I'll do my best...
Reply with quote

This promises to deliver...

www.youtube.com/watch?v=MJZjSHG6tBY

http://www.fotosearch.com/BDX125/bxp27923/
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Sat Jan 26, 2008 4:17 am    Post subject:
Reply with quote

hmmm ... tasty icon_biggrin.gif
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 SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts Db2 load job abending in SORT mistah kurtz DB2 4 Mon Jun 05, 2017 3:58 pm


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