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

Simple sort question?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Sat Jan 26, 2008 2:07 am
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 Developer


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

PostPosted: Sat Jan 26, 2008 2:32 am
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
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 Developer


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

PostPosted: Sat Jan 26, 2008 2:55 am
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
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 Developer


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

PostPosted: Sat Jan 26, 2008 3:09 am
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:

Use [URL] BBCode for External Links

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
Reply with quote

This promises to deliver...

Use [URL] BBCode for External Links

www.fotosearch.com/BDX125/bxp27923/
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: Sat Jan 26, 2008 4:17 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
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 JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top