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 Files using DFSORT

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


Joined: 02 Oct 2021
Posts: 17
Topics: 7

PostPosted: Wed Nov 17, 2021 11:01 am    Post subject: Matching Files using DFSORT Reply with quote

Hi Team,

We have the below requirement. There are two input files. Please let me know if this can be achieved using DFSORT/ICETOOL.

- Input File1 has unique records in sorted order. First 20 bytes is the key. Next 5 bytes is the modified value i would like to overlay while writing into output file. Additionally, Records tagged as 'S' need to be skipped while writing into the output file.
- Input File2 can have multiple records per 1 key in Input File 1. These records are also in sorted order on First 20 bytes.
- Output File will have the records from Input file2. Based on the flag 'S' in Input File1, the corresponding records in Input File2 will be skipped. Input File2 has 9 records, where as Output File has only 8 records. For all the selected records, position 21-25 from Input File 1 need to be overlayed in Output file instead of the original values from Input File 2(Position 16-20).

Input File 1
Code:

PART1PROC1MAILA1111111111N
PART1PROC1MAILA2222222222N
PART1PROC1MAILA3333333333N
PART1PROC1MAILA4444444445M
PART1PROC1MAILA5555555555S
PART1PROC1MAILA6666666666N


Input File 2
Code:

PART1PROC1MAILA11111OTHERDATA
PART1PROC1MAILA22222OTHERDATA
PART1PROC1MAILA22222OTHERDATA
PART1PROC1MAILA33333OTHERDATA
PART1PROC1MAILA33333OTHERDATA
PART1PROC1MAILA44444OTHERDATA
PART1PROC1MAILA44444OTHERDATA
PART1PROC1MAILA55555OTHERDATA
PART1PROC1MAILA66666OTHERDATA


Output File
Code:

PART1PROC1MAILA11111OTHERDATA
PART1PROC1MAILA22222OTHERDATA
PART1PROC1MAILA22222OTHERDATA
PART1PROC1MAILA33333OTHERDATA
PART1PROC1MAILA33333OTHERDATA
PART1PROC1MAILA44445OTHERDATA
PART1PROC1MAILA44445OTHERDATA
PART1PROC1MAILA66666OTHERDATA


Thanks
Prashanth
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Nov 17, 2021 8:25 pm    Post subject: Re: Matching Files using DFSORT Reply with quote

erasani wrote:
For all the selected records, position 21-25 from Input File 1 need to be overlayed in Output file instead of the original values from Input File 2(Position 16-20).


erasani,

Your output does not match the above requirement, you simply skipped 1 record.

You need to be clear as to what you want.

what is the LRECL and RECFM of the files involved?

Did you check the following smart DFSORT tricks?

    Join fields from two files on a key
    Join fields from two files record-by-record
    Cartesian join
    Create files with matching and non-matching records

https://www.ibm.com/support/pages/smart-dfsort-tricks
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 02 Oct 2021
Posts: 17
Topics: 7

PostPosted: Thu Nov 18, 2021 6:44 am    Post subject: Reply with quote

Thanks kolusu. Went thru DFSort tricks doc. Below code gave me the expected results.


Code:

  OPTION COPY                                     
  JOINKEYS F1=SORTJNF1,FIELDS=(1,53,A)             
  JOINKEYS F2=SORTJNF2,FIELDS=(1,53,A)             
  REFORMAT FIELDS=(F1:1,704,F2:54,26,?)           
  OUTFIL FNAMES=SORTOUT,INCLUDE=(731,1,CH,EQ,C'B'),
         BUILD=(1,27,705,26,54,651)
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Nov 18, 2021 8:26 pm    Post subject: Reply with quote

erasani,

By default JOINKEYS gives you only matched records. So you don't need to check the match indicator and rebuild the record once again as you can build the desired record using REFORMAT itself.

Code:

  OPTION COPY                                     
  JOINKEYS F1=SORTJNF1,FIELDS=(1,53,A)             
  JOINKEYS F2=SORTJNF2,FIELDS=(1,53,A)             
  REFORMAT FIELDS=(F1:1,27,F2:54,26,F1:54,651)


Btw the control cards you show are drastically different from the original requirement.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
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