View previous topic :: View next topic
|
Author |
Message |
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi,
Thank you very much for your kind support for all the time.
My requirement is I have an input file as
Sample Input:
Code: |
AAA 12 789798
AAA 12 13256
CCC 12 4654
BBB 12 654564
BBB 12 1321
AAA 12 231313
AAA 12 68684
AAA 12 321
AAA 12 0
CCC 12 11
CCC 12 6546
CCC 12 1231
CCC 12 676
BBB 12 2342
BBB 12 34645
BBB 12 457
BBB 12 3
CCC 12 567
AAA 12 69
BBB 12 5668
CCC 12 98
|
Based on the first 3 character I need to copy first 5 records per key to the output file.
I will be running one sort step first to get the data in sorted. Please help/guide me to copy selected count records from the input file.
My desired output is:
Code: |
AAA 12 789798
AAA 12 13256
AAA 12 4654
AAA 12 654564
AAA 12 1321
BBB 12 321
BBB 12 0
BBB 12 11
BBB 12 6546
BBB 12 1231
CCC 12 34645
CCC 12 457
CCC 12 3
CCC 12 567
CCC 12 69 |
Please help in this regard.
Thanks in advance. |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
satish.ms10,
How do you get below records (shown in code tags) in your expected output?They are not present in your input. AAA is replaced with BBB or CCC!!! Is this just typo?
Quote: |
Sample Input:
Code:
AAA 12 789798
AAA 12 13256
CCC 12 4654
BBB 12 654564
BBB 12 1321
AAA 12 231313
AAA 12 68684
AAA 12 321
AAA 12 0
CCC 12 11
CCC 12 6546
CCC 12 1231
CCC 12 676
BBB 12 2342
BBB 12 34645
BBB 12 457
BBB 12 3
CCC 12 567
AAA 12 69
BBB 12 5668
CCC 12 98
|
Code: |
AAA 12 4654 --> How do you get AAA with 4654, in your
AAA 12 654564 --> expected input its present with CCC or BBB
AAA 12 1321
|
Quote: |
I will be running one sort step first to get the data in sorted. Please help/guide me to copy selected count records from the input file. |
You don't need another pass, you can combine your sort and selecting first 3 records in a single pass. Please show us your sort step to get the data sorted.
Also please provide LRECL and RECFM for the input file.
Thanks, |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi,
Thanks for your quick response. It is a typo only. Do not see the rest of the values. My requirement is need to copy first 5 records based on the key to the output file.
My file is a VB file with 400 LRECL.
Below is my sort card to sort the data.
Code: |
SORT FIELDS=(1,3,CH,A)
|
Let me know if you need more details. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Since your input file has VB, the data starts in position 5 after the RDW, not in position 1. Here's a DFSORT/ICETOOL job that will give you the first 5 records with each key (5,3,CH).
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (VB/400)
//OUT DD DSN=... output file (VB/400)
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(5,3,CH) FIRST(5)
|
For your example, OUT will have:
Code: |
AAA 12 789798
AAA 12 13256
AAA 12 231313
AAA 12 68684
AAA 12 321
BBB 12 654564
BBB 12 1321
BBB 12 2342
BBB 12 34645
BBB 12 457
CCC 12 4654
CCC 12 11
CCC 12 6546
CCC 12 1231
CCC 12 676
|
If that's NOT the output you expect, then you need to explain the rules for getting the output you want. |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi Frank,
It worked for me. Thank you very much. |
|
Back to top |
|
|
ksouren007
New User
Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
|
|
|
|
Hi Frank,
I was refering to this sort card for a similar requirement that I have and is using the below sort card.
Code: |
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,25,CH) FIRST
|
I have to tweak this sort card in order to add the below condition.
Code: |
When (107,3,CH,EQ,C'PMP')
SELECT FROM(IN) TO(OUT) ON(1,25,CH) FIRST
|
Could you please let me know if there's any way to combine both?
I am using FB LRECL=275 for both i/p and o/p. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Change your SELECT operator to:
Code: |
SELECT FROM(IN) TO(OUT) ON(1,25,CH) FIRST USING(CTL1)
|
and add:
Code: |
//CTL1CNTL DD *
INCLUDE COND=(107,3,CH,EQ,C'PMP')
|
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:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080 |
|
Back to top |
|
|
ksouren007
New User
Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
|
|
|
|
It worked great!! Thanks Frank. |
|
Back to top |
|
|
|