MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Matching fields in the same file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Fri Aug 31, 2007 2:59 am    Post subject: Matching fields in the same file Reply with quote

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
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Aug 31, 2007 4:05 am    Post subject: Reply with quote

psmadhusudhan,

try this untested code

Code:

//SYSIN    DD *                         
  SORT FIELDS=COPY                       
  INCLUDE COND=(01,03,CH,EQ,51,03,CH,OR,
                01,03,CH,EQ,52,03,CH,OR,
                01,03,CH,EQ,53,03,CH,OR,
                01,03,CH,EQ,54,03,CH,OR,
                01,03,CH,EQ,55,03,CH,OR,
                01,03,CH,EQ,56,03,CH,OR,
                01,03,CH,EQ,57,03,CH,OR,
                01,03,CH,EQ,58,03,CH,OR,
                01,03,CH,EQ,59,03,CH,OR,
                01,03,CH,EQ,60,03,CH,OR,
                01,03,CH,EQ,61,03,CH,OR,
                01,03,CH,EQ,62,03,CH,OR,
                01,03,CH,EQ,63,03,CH,OR,
                01,03,CH,EQ,64,03,CH,OR,
                01,03,CH,EQ,65,03,CH,OR,
                01,03,CH,EQ,66,03,CH,OR,
                01,03,CH,EQ,67,03,CH,OR,
                01,03,CH,EQ,68,03,CH,OR,
                01,03,CH,EQ,69,03,CH,OR, 
                01,03,CH,EQ,70,03,CH,OR, 
                01,03,CH,EQ,71,03,CH,OR, 
                01,03,CH,EQ,72,03,CH,OR, 
                01,03,CH,EQ,73,03,CH,OR, 
                01,03,CH,EQ,74,03,CH,OR, 
                01,03,CH,EQ,75,03,CH,OR, 
                01,03,CH,EQ,76,03,CH,OR, 
                01,03,CH,EQ,77,03,CH,OR, 
                01,03,CH,EQ,78,03,CH)     
/*


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Fri Aug 31, 2007 8:08 am    Post subject: Reply with quote

Thanks Kolusu.

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
Back to top
View user's profile Send private message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Fri Aug 31, 2007 9:23 am    Post subject: Reply with quote

psmadhusudhan,

I have a suggestion:

1. Consider 2 steps to get the desired output.
2. In the first step write FIELD1 to a temporary file (say &&T1) using
Code:

       //SYSIN    DD *       
        SORT FIELDS=COPY   
        OUTREC FIELDS=(1,3)
     /*

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.

Regards,
Vivek G
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Aug 31, 2007 10:38 am    Post subject: Reply with quote

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
Code:

//SYSIN    DD *                             
  SORT FIELDS=COPY                           
  INREC OVERLAY=(81:51,29,JFY=(SHIFT=LEFT)) 
  OUTFIL INCLUDE=(1,3,CH,EQ,81,3,CH),       
  OUTREC=(01,80)                             


Vivek,

Your approach will not work as the string to be compared is not a fixed positions

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Mon Sep 03, 2007 12:02 am    Post subject: Reply with quote

Kolusu

Sorry for late reply. I had just checked the code, it is working fine.

Quote:
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


I want to know how to change the code if there are no spaces.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Sep 03, 2007 3:43 pm    Post subject: Reply with quote

Quote:

I want to know how to change the code if there are no spaces.


psmadhusudhan,

AFAIK sort products do NOT have the ability to perform what you asked for.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Sep 03, 2007 5:54 pm    Post subject: Reply with quote

psmadhusudhan,

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:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC PARSE=(%01=(ABSPOS=51,FIXLEN=3,STARTAT=NONBLANK)),
    OVERLAY=(81:%01)
  OUTFIL INCLUDE=(1,3,CH,EQ,81,3,CH),BUILD=(1,80)
/*

_________________
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
View user's profile Send private message Send e-mail Visit poster's website
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Mon Sep 03, 2007 10:46 pm    Post subject: Reply with quote

Frank

I had tried your code with following input file

Code:
----+----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 Crying or Very sad . Could you please help me in this.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Sep 04, 2007 10:13 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group