View previous topic :: View next topic
|
Author |
Message |
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
This is my requirement -
Input data - FB 80
It has multiple lines, but only few pairs as shown below -
Code: |
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-777
04/13 03/14 Z3 00000
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-888
03/13 02/14 L3 00000
AAAAAA 123456-1234567-123
|
Output expected - FB 160
I need to get only pairs in the output. Like this -
Code: |
AAAAAA 123456-1234567-777 04/13 03/14 Z3 00000
AAAAAA 123456-1234567-888 03/13 02/14 L3 00000
|
|
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
What is your sort product? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
So, from the data you have shown you can just ignore everything that is "-123"?
Or any other way to know which ones you want? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I suspect incomplete test data . . . |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
Pandora-Box wrote: |
What is your sort product? |
It is DFSORT.
Bill Woodger wrote: |
So, from the data you have shown you can just ignore everything that is "-123"?
Or any other way to know which ones you want? |
-123 is just a sample data, it could be any value.
What I need is a pair of records as shown in example:
for record having -777 paired record has values -
04/13 03/14 Z3 00000
similarly record having -888 paired record is-
03/13 02/14 L3 00000
I just need these paired records in output to be merged in to one line.
I hope its clear now! |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
How do you define "paired" records?
Do you mean the last record of the group has spaces in the first 3 bytes and you need to pick the record prior to that as a pair?
If that is indeed true
1. Use ICETOOL SELECT operator with LASTDUP on the sequence number
2. Use when=init to append a sequence number at position 161.
3. Use when=group with END=(1,3,CH,EQ,C' ') and RECORDS=2 and push the contents on to pos 81.
4. Use When=(1,3,CH,EQ,C' ') subtract 1 from the sequence number to make it a duplicate record.
5. Using OUTFIL build the first 160 bytes removing the sequence number |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Kolusu,
Instead of this why cant we just do something like this
1.GROUP 1,3 when not equal to space and adding SEQ and pushing data
2.OUTFIL INCLUDE only for number 2 and BUILD to reformat |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, experiment.
Remember to turn off the SORT for SELECT. OPTION COPY in the USING(xxxx) xxxxCNTL file.
Give yourself 50m input records. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Bill & Kolusu,
Code: |
//S1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-777
04/13 03/14 Z3 00000
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-888
03/13 02/14 L3 00000
AAAAAA 123456-1234567-123
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,NE,C' '),
PUSH=(35:SEQ=1,1,25))
OUTFIL INCLUDE=(35,1,ZD,EQ,02),BUILD=(1:36,25,26:1,33) |
This will give the output
Code: |
AAAAAA 123456-1234567-777 04/13 03/14 Z3 00000
AAAAAA 123456-1234567-888 03/13 02/14 L3 00000 |
I am not sure what is the disadvantage of this method |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
pandora,
There are "n" different ways to get the desired results. My choice was to use SELECT to pick the Last Duplicate via ICETOOL and you chose the traditional method. There wouldn't be a difference in performance either method. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Ok fine :-)
Thanks |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
Kolusu, Pandora...
Thanks a lot to both of you for providing the solution. I really do appreciate. |
|
Back to top |
|
|
|