View previous topic :: View next topic |
Author |
Message |
santa Beginner
Joined: 16 Mar 2007 Posts: 3 Topics: 3
|
Posted: Thu Mar 22, 2007 12:00 pm Post subject: Sorting records to another file |
|
|
I have a file like:
Code: |
header
01098009890800z1111187686876876
01453543877895z2222276868767687
01098009890800z3333387686876876
01453543877895z4444476868767687
02z1111187686876876 CAT1
02z2222276868767687 CAT2
02z3333387686876876 CAT2
02z4444476868767687 CAT1
03z11111876868768767866868686yt
03z2222276868767687hffjgfghfghfghf
03z3333387686876876jghjgfu867687
03z4444476868767687bgfyf56868971
trailer
|
z11111,z22222,z33333,z44444 are codes which are present in all record types i.e(01,02,03). these codes could be of CAT1 or CAT2, indicated in record 02. i am interested in extracting all records for codes which belong to CAT2.
desired output:
Code: |
header
01453543877895z2222276868767687
01098009890800z3333387686876876
02z2222276868767687 CAT2
02z3333387686876876 CAT2
03z2222276868767687hffjgfghfghfghf
03z3333387686876876jghjgfu867687
trailer
|
the input file is expected to contain over 30L records. I have tried REXX as solution by first concatenating all CAT2 codes(total CAT2 codes around 80) in a string and then reading input file record by record and serching if code in read record is available in concatenated string. if so, write to a file. It takes a hell lot of time to process complete file . can anyone suggest solution to the problem using JCL or better way of doing it using REXX |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Thu Mar 22, 2007 12:15 pm Post subject: |
|
|
santa,
Please do NOT post the same Question in multiple forums.
1. what is the LRECL and RECFM of the input?
2. What is the position and format of the codes z11111,z22222,z33333,z44444 ? for 01 records it is at a different position and for 02 records it is at different position. is that correct?
3. What is the position of the word "cat2" ?
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Thu Mar 22, 2007 12:44 pm Post subject: |
|
|
Do you have to extract the CAT2 codes from the input file or do you have a separate list of them? Either way, a DFSORT INCLUDE statement (hardcoded or generated) could handle 80 CAT2 strings and 3 records types. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Thu Mar 22, 2007 1:43 pm Post subject: |
|
|
As for rexx, searching a long string may not be the best way to store these. A stem variable may be better. something along the lines of this:
1st pass:
Code: |
keys. = 0
read each record and ...
If substr(record,1,2) = "02" Then
Do
Parse Var record 3 key 9 . cat
If cat = "CAT2" Then
keys.key = 1
End
|
2nd pass
Code: |
start.01 = 13
start.02 = 3
start.03 = 3
read each record and...
Do
Parse Var record rectype 3 .
key = substr(record,start.rectype,6)
If keys.key Then
Say record
End
|
I suspect the record parsing could be tuned better but this is an idea to try if you are so inclined. Also,I didn't count characters in the strings so the numbers are probably off |
|
Back to top |
|
|
santa Beginner
Joined: 16 Mar 2007 Posts: 3 Topics: 3
|
Posted: Thu Mar 22, 2007 11:55 pm Post subject: |
|
|
kolusu wrote: | santa,
Please do NOT post the same Question in multiple forums.
1. what is the LRECL and RECFM of the input?
2. What is the position and format of the codes z11111,z22222,z33333,z44444 ? for 01 records it is at a different position and for 02 records it is at different position. is that correct?
3. What is the position of the word "cat2" ?
Kolusu |
1.LRECL = 208
RECFM = FB
2. 01 record has code starting at 12th char(6 char long)
for 02, 03 rec has code at 3rd char.
3. CAT2 is present only in Record 02 at position starting at char no 205-208 |
|
Back to top |
|
|
|
|