Page 1 of 2

sorting in reverse and keep header and trail record

PostPosted: Tue Jul 21, 2009 8:05 am
by leon
Hi Friends,

I need your help about sorting in JCL, my input file :
header record
1
2
3
4
5
trailer record.

how to sorting using JCL, I can get the output like following:(keep header and
trailer, reverse for others.)

header record
5
4
3
2
1
trailer record.

anybody have sample code or good surggestion, thank you very much!

Re: sorting in reverse and keep header and trail record

PostPosted: Tue Jul 21, 2009 8:25 am
by dick scherrer
Hello,

Which sort product and which release of that sort product are used on your system?

If you are not sure, run any sort and the product/release will be shown in the informational output.

Re: sorting in reverse and keep header and trail record

PostPosted: Tue Jul 21, 2009 8:23 pm
by Frank Yaeger
Leon,

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 DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
  SORT FIELDS=(1,1,CH,D)
/*

Re: sorting in reverse and keep header and trail record

PostPosted: Wed Jul 22, 2009 2:43 am
by leon
thanks for your good idea, for my case, I can describe detail as following:

input file:

12251 486 mike 78.3
12394 876 gordon 66.5
12394 324 lili 56.9
12394 445 lin 67.3
12393 768 toto 77.3
12394 1043 tina 90.4
12394 23 zheng 67.5
12393 887 liny 56.9
12394 543 linda 76.85
12394 777 shang 67.4
12394 65 yua 76.32
12393 653 lana 632.1
12392 542 song 431.7
12394 442 yuping 53.7
12394 335 limei 65.9
12393 234 linge 76.9
12394 768 laohqo 65.7
12394 799 heling 90
12393 555 fei 77.76
12392 124 zhao 99.93
12620 1543 tina 88.34

after sorting(output file):

12251 486 mike 78.3
12392 124 zhao 99.93
12393 555 fei 77.76
12394 799 heling 90
12394 768 laohqo 65.7
12393 234 linge 76.9
12394 335 limei 65.9
12394 442 yuping 53.7
12392 542 song 431.7
12393 653 lana 632.1
12394 65 yua 76.32
12394 777 shang 67.4
12394 543 linda 76.85
12393 887 liny 56.9
12394 23 zheng 67.5
12394 1043 tina 90.4
12393 768 toto 77.3
12394 445 lin 67.3
12394 324 lili 56.9
12394 876 gordon 66.5
12620 1543 tina 88.34

as you see, after sorting, just keep the first and the last record, the othes records all in reverse.
could you give me the further help? by the way, I sorting using both dfsort and prodsort in my computer.
thanks again!

Re: sorting in reverse and keep header and trail record

PostPosted: Wed Jul 22, 2009 4:06 am
by Frank Yaeger
Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD)
  SORT FIELDS=(81,8,ZD,D)
  OUTFIL FNAMES=OUT,BUILD=(1,80)
/*

Re: sorting in reverse and keep header and trail record

PostPosted: Wed Jul 22, 2009 7:43 pm
by leon
thank you sooooooo much! I learn a lots from you, by the way,
my in/output file has RECFM=vB and LRECL=(2000+4), can I just change "FB/80"
to "vb/2004". is header and trailer parameter in your jcl datasort statement?
thanks, thanks, thanks, Master Frank Yaeger! :D

Re: sorting in reverse and keep header and trail record

PostPosted: Wed Jul 22, 2009 8:39 pm
by Frank Yaeger
It's a little tricker for VB, but this DFSORT/ICETOOL job should do it:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file (VB/2004)
//OUT DD DSN=...  output file (VB/2004)
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(2005:SEQNUM,8,ZD)
  SORT FIELDS=(2005,8,ZD,D)
  OUTFIL FNAMES=OUT,IFTHEN=(WHEN=INIT,BUILD=(1,2004)),
    VLTRIM=C' '
/*

Re: sorting in reverse and keep header and trail record

PostPosted: Thu Jul 23, 2009 7:58 pm
by leon
Hi, Frank,
I'm sorry, when I tried to run the jcl, I found I can't
use ICETOOL FOR SORTING, I just can use PRODSORT. I just work for 5 months in mainframe.
do you know if i need change something for the JCL or how to translate ICETOOL TO PRODSORT
for your above jcl code.
anyway, I'm appreciate for your time.
the best wish to you!!!

Re: sorting in reverse and keep header and trail record

PostPosted: Thu Jul 23, 2009 9:27 pm
by Frank Yaeger
If your site is licensed for DFSORT, then as shipped, PGM=SORT or PGM=ICEMAN would invoke DFSORT and PGM=ICETOOL would invoke DFSORT's ICETOOL.

I don't know what PRODSORT is. It sounds like something local your site has put in that affects the use of PGM=ICETOOL. You need to talk to your System Programmers about that what PRODSORT is and what it does vs the standard DFSORT and ICETOOL shipped by IBM.

Just out of curiosity, what messages do you get when you run a simple job using PRODSORT?

Re: sorting in reverse and keep header and trail record

PostPosted: Sat Aug 08, 2009 9:49 am
by leon
I'm sorry, Frank. I come back till now because I have been sick almost 2 weeks.
right now I got the name of my sort production from my output. it called SYNCSORT.
its syntax is different with DFSORT/ICETOOL. could you help me translate your jcl
code as above to the SYNCSORT? thank you very much!
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(2005:SEQNUM,8,ZD)
  SORT FIELDS=(2005,8,ZD,D)
  OUTFIL FNAMES=OUT,IFTHEN=(WHEN=INIT,BUILD=(1,2004)),
    VLTRIM=C' '
/*