Page 1 of 1

Help producing a sort with two exec statements

PostPosted: Wed May 14, 2008 4:08 pm
by e66n06
Hello, I'm am working on learning JCL, I have a number of excercies I am working on, but now I've gotten stuck.

I have a data setof the following format:

Location (Column range 1,17)
Year (Column range, 19,4)
Month (Column range 24,2)
Item 1 Sales (Column range 27,7)
Item 2 Sales (Column range 35,7)

I've done the first few exercises and managed to use JCL to sort the data into:

• something that lists each month+year combination and sums up all of the sales

• something that shows the location of the shops and then produces an overall sum of the sales for each month across all the years..

The next thing I am trying to do is to work out what is the best performing location for each month of the year,

I cannot figure out how to code this, because I think I need two sort statements, in one JCL file but I don't know how to do this, and I keep reading the DFSORT getting started guide and I'm not getting anywhere.

Re: Help producing a sort with two exec statements

PostPosted: Wed May 14, 2008 8:49 pm
by Frank Yaeger
The screen shots you showed were very difficult to read, so I deleted them.

Please post an example of your input records and what you expect for output as plain text, not screenshots. Use code tags around your records. Explain the "rules" for getting from input to output.

Give the RECFM and LRECL of your input file. Give the starting position, length and format of each relevant field.

Re: Help producing a sort with two exec statements

PostPosted: Sun May 18, 2008 4:28 pm
by e66n06
Ok, sorry about that, i thought the screenshots of my x3270 session would be ok. Anyhow, here's my JCL:

My input record is of this format:

Location (Column range 1,17)
Year (Column range, 19,4)
Month (Column range 24,2)
Item 1 Sales (Column range 27,7)
Item 2 Sales (Column range 35,7)

I then wrote this jcl to sort the record:

//ASH2A JOB 1
//ASHSORT EXEC PGM=SORT
//*
//SORTIN DD DSN=SURMSTR.TRDATA2,DISP=SHR
//SORTOUT DD STSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
  SORT FIELDS(1,17,CH,A,24,2,ZD,A)
  SUM FIELDS(27,7,ZD)
  OUTREC FIELDS=(2x,1,17,2x,2,2x,27,7,ZD,TO=FS)
/*


The output i get from the sort out is like this:


location           month            sum of item 1 sales for a certain month across all the years

location a           1                     ####
location a           2                     ####
location a           3                     ####
location a           4                     ####
location a           5                     ####
location a           6                     ####
location a           7                     ####
location a           8                     ####
location a           9                     ####
location a           10                   ####
location a           11                   ####
location a           12                   ####
location b           1                     ####
location b           2                     ####
location b           3                     ####

...

and so on for all the locations


so now i want to adapt my jcl so it does two sorts, but i don't know how to do this,

I think what i need to do is get the output from the sort shown above, and then sort it again and get it to list something like this:

location           month            best performing location for a certain month

location a           1                     ####
location b           2                     ####
location a           3                     ####
location b           4                     ####
location a           5                     ####
location a           6                     ####
location c           7                     ####
location c           8                     ####
location a           9                     ####
location c           10                   ####
location b           11                   ####
location b           12                   ####



any help on how to do this would be greatly appriciated :D

Re: Help producing a sort with two exec statements

PostPosted: Sun May 18, 2008 9:18 pm
by Frank Yaeger
You still haven't shown your input records and you still haven't explained clearly what you want to do.

Do you just want to do two different sorts? If so, then use two different PGM=SORT steps, or one PGM=ICETOOL step with two SORT operators.

Or do you want to sort your records into a certain sequence in the most efficient way possible? If that's it, then again, show an example of your input records and expected output records, and explain the "rules" for getting from input to output.

Re: Help producing a sort with two exec statements

PostPosted: Sun May 18, 2008 9:44 pm
by e66n06
I can't show an example of my records, because I don't have them as a normal file, all i have is the stuff on ISPF and i can't copy and paste that.

Also, i think what i want is a really simple, all i want to do is do one sort, take it's ouput and then sort it again, i'm not asking what condidtions I need or how to get to the exact output I want, I just want to know how to write the JCL to do a sort, take it's ouput and then do another sort on it to produce sortout..

I'm new to JCL so i don't know how to do this, I've manged to use dfsort to do one sort and then ouput the result to sortout, but I have no idea how to write the code to get it to do a sort, store it to a tempory dataset and then sort it agin before making the sortout..

Sorry to have been confusing..

Re: Help producing a sort with two exec statements

PostPosted: Mon May 19, 2008 8:25 pm
by Frank Yaeger
You can use a DFSORT/ICETOOL job like the following to do what you asked for.

//S1    EXEC  PGM=ICETOOL                                   
//TOOLMSG   DD  SYSOUT=*                                     
//DFSMSG    DD  SYSOUT=*                                     
//IN DD *                                                   
AAAA BBBB                                                   
DDDD AAAA                                                   
CCCC DDDD                                                   
BBBB CCCC                                                   
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)   
//OUT DD SYSOUT=*                                           
//TOOLIN DD *                                               
SORT FROM(IN) TO(T1) USING(CTL1)                             
SORT FROM(T1) TO(OUT) USING(CTL2)                           
//CTL1CNTL DD *                                             
  SORT FIELDS=(1,4,CH,A)                                     
//CTL2CNTL DD *                                             
  SORT FIELDS=(6,4,CH,A)                                     


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/servers/storage/supp ... tmpub.html

Re: Help producing a sort with two exec statements

PostPosted: Tue May 20, 2008 5:55 pm
by e66n06
Awesome, thank you, that's exactly what I wanted to know :D

Sorry for being confusing