Posted: Fri Aug 31, 2007 2:59 am Post subject: Matching fields in the same file
I have one input file of record length 80.
Treat first 3 bytes as Field1. Treat 51-80 bytes as Field2.
First 3 bytes will surely be occupied.
Now this Field1 will be present anywhere in Field2 for example at
51-53 or 67-69 or 78-80 or any 3bytes in 51-80 bytes.
Now my output file should contain all the input records
in which Field1 is present in Field2.
For example
Input File:
Code:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| | | |
Field1 -------------Field2--------------
POL POL
COV COV
CLT
MED MED
Output File:
Code:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| | | |
Field1 -------------Field2--------------
POL POL
COV COV
MED MED
Can anybody please help me in achieving this using DFSORT/ICETOOL. _________________ Thanks
Madhu Sudhan
This code is working. I want to know can it be shortened using anyother logic as I have restriction on line of code and also my field lengths may change regularly. _________________ Thanks
Madhu Sudhan
3. In the second step you can compare this temparory file with the original file and write the matched records. There are number of techniques used and can be searched in this forum.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Fri Aug 31, 2007 10:38 am Post subject:
Quote:
This code is working. I want to know can it be shortened using anyother logic as I have restriction on line of code and also my field lengths may change regularly.
psmadhusudhan,
Hmm You can use SYMNAMES to specify the relative positions and use them in the include conditions. If your field-2 data is all spaces with embedded strings then we can use SQZ/JFY functions and get the string to a constant position and compare that string.
For ex: if your field-2 had all spaces with strings POL, COV & MED somewhere in between then you can use these control cards to get the desired results
_________________ 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
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
POL POL TR0236589549 WENTER
COV RAKESH MISHRA FN 01 COV
CLT ASF 22-37374-MFJBF-
MED MED DFKUGE97823B0
But my output is coming as
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
POL POL TR0236589549 WENTER
MED MED DFKUGE97823B0
The record with COV in Field1 is missing in the output . Could you please help me in this. _________________ Thanks
Madhu Sudhan
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue Sep 04, 2007 10:13 am Post subject:
Madhu Sudhan,
Did you miss the part where I said
Quote:
If the input is really as described with at most one 3-byte field2 value in each record, then you can use this DFSORT job to do what you want
Your original input only has one 3-byte value in 51-80 with blanks around it. The DFSORT job I gave you works for that case or for any case where the target value is the first value in 51-80. In your "new" input, COV is NOT the first value in 51-80 which is an entirely different case for which the job won't work. I can't think of anything that would work for that case.
If you had showed the more complete input in your first post, you would have saved us all a lot of time. _________________ 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
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum