View previous topic :: View next topic
Author
Message
TizMe New User Joined: 05 Jan 2006Posts: 72
Hi,
I have an input file that has approx 6,000 records.
Starting at Col 27 is field VOLSER (length 6),
Starting at Col 119 is field AGE (length 4),
Code:
IE:
<snip> V00001 <snip> 235
<snip> V02001 <snip> 35
<snip> V60001 <snip> 5
<snip> V00701 <snip>1235
etc.
I would like to process these records and create an output file that looks like this:
Code:
EJECT VOLSER(V00002, -
V01007, -
V02007, -
V03007, -
V04007, -
V05007, -
V06007, -
V07007, -
V08007, -
V09007)
The output file should be sorted in VOLSER order, but only contain the 10 records with the highest AGE.
Back to top
guptae Moderator Joined: 14 Oct 2005Posts: 1208 Location: Bangalore,India
yes it is possible using sort. U just need to sort the record on Volser descending order & stopafter 10 record
Sort fields = (119,4,CH,D,27,6,CH,A)
STOPAFT=10
Correction r welcome
Back to top
TizMe New User Joined: 05 Jan 2006Posts: 72
No, that wont produce the desired results. The output would be still sorted by descending AGE. The output should be in ascending VOLSER order. (but contain the 10 records with the highest AGE)
I guess that I'll have to actually sort it twice, but can it all be done in one sort step?
And how do I get OUTREC to perform slightly different for the first and last records?
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Tizme,
Here's a DFSORT/ICETOOL job that will do what you asked for:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) USING(CTL2)
/*
//CTL1CNTL DD *
INREC BUILD=(1:27,6,7:119,4)
SORT FIELDS=(7,4,ZD,D)
OUTFIL FNAMES=T1,ENDREC=10
/*
//CTL2CNTL DD *
SORT FIELDS=(1,6,CH,A)
OUTFIL FNAMES=OUT,
IFOUTLEN=80,
IFTHEN=(WHEN=INIT,OVERLAY=(7:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(7,8,ZD,EQ,+1),
BUILD=(C' EJECT VOLSER(',1,6,C', -')),
IFTHEN=(WHEN=(7,8,ZD,EQ,+10),
BUILD=(17:1,6,C')')),
IFTHEN=(WHEN=NONE,
BUILD=(17:1,6,C', -'))
/*
Back to top
TizMe New User Joined: 05 Jan 2006Posts: 72
Thats great, thanks for your input.
I am falling in love with DFSORT, "Don't tell the wife"
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Quote:
I am falling in love with DFSORT, "Don't tell the wife"
Just tell her it's a pet. (Everyone knows which pet I prefer.)
Back to top
Please enable JavaScript!