| IBM MAINFRAME HELP & SUPPORT FORUMS Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
|
| View previous topic :: View next topic |
| Author |
Message |
Absinthia
Joined: 10 Jan 2008
Posts: 26
Location: CHINA
|
| Posted: Fri Aug 01, 2008 1:30 pm Post subject: Extract the first 11 records with the same key |
|
|
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
Joined: 03 Jul 2007
Posts: 1148
Location: Mumbai - India
|
| Posted: Fri Aug 01, 2008 2:23 pm Post subject: Reply to: Extract the first 11 records with the same key |
|
|
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
Joined: 03 Jul 2007
Posts: 1148
Location: Mumbai - India
|
| Posted: Fri Aug 01, 2008 2:30 pm Post subject: Reply to: Extract the first 11 records with the same key |
|
|
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
Joined: 28 Jul 2006
Posts: 664
|
| Posted: Fri Aug 01, 2008 3:08 pm Post subject: |
|
|
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
Joined: 10 Jan 2008
Posts: 26
Location: CHINA
|
| Posted: Fri Aug 01, 2008 3:24 pm Post subject: |
|
|
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. :D |
|
| Back to top |
|
Aaru
Joined: 03 Jul 2007
Posts: 1148
Location: Mumbai - India
|
| Posted: Fri Aug 01, 2008 3:39 pm Post subject: Reply to: Extract the first 11 records with the same key |
|
|
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
Joined: 15 Feb 2005
Posts: 4613
Location: San Jose, CA
|
| Posted: Fri Aug 01, 2008 8:46 pm Post subject: |
|
|
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:
www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/ |
|
| Back to top |
|
Absinthia
Joined: 10 Jan 2008
Posts: 26
Location: CHINA
|
| Posted: Sat Aug 02, 2008 5:40 pm Post subject: |
|
|
| 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
Joined: 15 Feb 2005
Posts: 4613
Location: San Jose, CA
|
| Posted: Sun Aug 03, 2008 1:56 am Post subject: |
|
|
| I'm glad you like DFSORT's new SUBSET function. Note that PTF UK90013 is available for installation now. |
|
| Back to top |
|
Aaru
Joined: 03 Jul 2007
Posts: 1148
Location: Mumbai - India
|
| Posted: Wed Aug 06, 2008 11:40 am Post subject: Reply to: Extract the first 11 records with the same key |
|
|
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
Joined: 15 Feb 2005
Posts: 4613
Location: San Jose, CA
|
| Posted: Wed Aug 06, 2008 9:52 pm Post subject: |
|
|
Aaru,
Thanks. I'm glad you like the new DFSORT/ICETOOL functions. We aim to please. :D |
|
| Back to top |
|
| |
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM
|