View previous topic :: View next topic
Author
Message
Absinthia New User Joined: 10 Jan 2008Posts: 36 Location: CHINA
Hello,everyone,I just met with a very delicate problem.
Input file is below.
The key column is from 1 to 7.(in this file,the key is NA94T21 and NA95T23)
I just want to extract the first 11 records with the same key.
Could anyone help me to do it?
Thanks in advance.
Code:
NA94T21 333QSPP 359 ¯*07001200
NA94T21 444QSHP 330 06001200
NA94T21 555QNLS -
NA94T21 NR46SPP 359 ¯*07001200
NA94T21 NR54SPP 330 06001200
NA94T21 NR7GSPP 330 *06001200
NA94T21 AAA0000 330 ¢*06001200
NA94T21 BBB1111 330 ª*06001200
NA94T21 CCC2222 -
NA94T21 GA7GUNB 330 01000000
NA94T21 GB7HUNB 330 ¢<01000000
NA94T21 GD80UN2 330 ½%01000000
NA94T21 GE22UNB 330 Â 01000000
NA94T21 444QSHP 330 06001200
NA94T21 555QNLS -
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Absintia,
Check the below JCL
Code:
//STEPS200 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
NA94T21 333QSPP
NA94T21 444QSHP
NA94T21 555QNLS
NA95T23 555QNLS
NA95T23 555QNLS
/*
//TEMP1 DD DSN=&&WERP1,DISP=(MOD,PASS),
// DSORG=PS,RECFM=FB
//TOOLIN DD *
COPY FROM(IN1) TO(TEMP1) USING(SRT1)
SORT FROM(TEMP1) TO(OUT1) USING(SRT2)
/*
//SRT1CNTL DD *
SORT FIELDS=(1,7,CH,A)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(41:SEQNUM,6,ZD,RESTART=(1,7))),
IFTHEN=(WHEN=(41,6,ZD,LT,2),OVERLAY=(61:C'1'))
/*
//SRT2CNTL DD *
OPTION COPY
INCLUDE COND=(61,1,CH,EQ,C'1')
OUTREC BUILD=(1,40)
/*
//OUT1 DD SYSOUT=*
change this IFTHEN=(WHEN=(41,6,ZD,LT,2 ), to 12 for your reqt. Test and let us know if it works.
output
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Abs,
What if you have less than 11 records for a particular key???
I have assumed that u need all the records, the maximum of which can be 11 for a key.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
this might be another way
Code:
//* ONLY TOP 11 OCCURENCE OF A FIELD
//**********************************************************************
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=INPUT-DSN
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,7,CH,A)
OUTREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,7))
OUTFIL INCLUDE=(81,8,ZD,LE,+11),BUILD=(1,80)
/*
Gerry
Back to top
Absinthia New User Joined: 10 Jan 2008Posts: 36 Location: CHINA
Thanks a lot .It works.but there is a small problem.
Code:
//TEMP1 DD DSN=&&WERP1,DISP=(MOD,PASS),
// DSORG=PS,RECFM=FB
This step,the space parameter should be added.
I thought about the method before.However,
I didn't know RESTART parameter before.
It is so tricky.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Abs,
Quote:
This step,the space parameter should be added.
Do add that step, If your shop requires SPACE parameter to be added for all output datasets.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Absinthia,
If you have z/OS DFSORT V1R5 PTF UK90013 (July, 2008) you can do this more easily with the DFSORT/ICETOOL job below. If you don't have this PTF, ask your System Programmer to install it (it's free).
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=... output file
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,7,CH) FIRST(11)
/*
For complete details on the new SELECT FIRST(n) function and the other new functions available with PTF UK90013, see:
Use [URL] BBCode for External Links
Back to top
Absinthia New User Joined: 10 Jan 2008Posts: 36 Location: CHINA
Frank,thanks a lot.that function is so good.I tried it ,our shop has not installed it yet.I will later advise our system programmer to install it.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
I'm glad you like DFSORT's new SUBSET function. Note that PTF UK90013 is available for installation now.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Frank,
Quote:
I'm glad you like DFSORT's new SUBSET function.
Had a look at the links for the new operators introduced. I am pretty much sure that it is going to make our work even more easier. Great work.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Aaru,
Thanks. I'm glad you like the new DFSORT/ICETOOL functions. We aim to please.
Back to top
Please enable JavaScript!