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 

MATCH & UNMATCH

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


Joined: 27 May 2010
Posts: 29
Topics: 13

PostPosted: Fri Feb 04, 2011 1:20 am    Post subject: MATCH & UNMATCH Reply with quote

hi,

I've two flat files. LRECL for file1 is 100 & LRECL for file2 is 10.
I need to compare these two files on the first 10 bytes.
if they are matching, write the 10 bytes to the output file with an extra 1byte flag 'M' (denoting matching) as suffix to the output.
if the record exist in file1 and doesn't exist in file2 then, write the 10bytes to output file with 1byte extra flag 'D' (deleted from file1) as suffix to the output.
if the record doesn't exist in file1 and exists in file2 then, write the 10bytes to output file with 1byte extra flag 'I' (Insert in file2) as suffix to the output.

eg:
file1(LRECL=100)
1111111111 *************
2222222222 *************
4444444444 *************
5555555555 *************

file2(LRECL=10)

1111111111
3333333333
4444444444
6666666666

outputfile(LRECL=11)
1111111111M
2222222222D
3333333333I
4444444444M
5555555555D
6666666666I

Is there any way to accomplish this without writing a cobol pgm?

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


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

PostPosted: Fri Feb 04, 2011 11:36 am    Post subject: Reply with quote

koolspark.

Use the following DFSORT JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//INA      DD DSN=Your input Fb 100 byte file,DISP=SHR
//INB      DD DSN=Your input Fb 10 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                     
  OPTION COPY                                       
  JOINKEYS F1=INA,FIELDS=(1,10,A)                   
  JOINKEYS F2=INB,FIELDS=(1,10,A)                   
  JOIN UNPAIRED                                     
  REFORMAT FIELDS=(F1:1,10,?,F2:1,10)               
  INREC IFOUTLEN=11,                                 
  IFTHEN=(WHEN=(11,1,CH,EQ,C'B'),OVERLAY=(11:C'M')),
  IFTHEN=(WHEN=(11,1,CH,EQ,C'1'),OVERLAY=(11:C'D')),
  IFTHEN=(WHEN=(11,1,CH,EQ,C'2'),BUILD=(12,10,C'I'))
//JNF1CNTL DD *                                     
  INREC BUILD=(1,10)                                 
//*

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


Joined: 27 May 2010
Posts: 29
Topics: 13

PostPosted: Tue Feb 08, 2011 4:34 am    Post subject: Reply with quote

Kolusu,

I'm not getting the flag(M, D,I) in the 11th position. The outputfile is created with 10bytes lenth only. Also, Is it possible to sort the output file on the first 10bytes?

Thanks,
Back to top
View user's profile Send private message
koolspark
Beginner


Joined: 27 May 2010
Posts: 29
Topics: 13

PostPosted: Tue Feb 08, 2011 5:34 am    Post subject: Reply with quote

I'm sorry. I gave wrong LRECL for the SORTOUT file. Your sort works fine.
If I want to sort the sortout file based on the first 10 bytes, where/how should i specify the SORT FIELDS ?

Thank you very much for your support.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Feb 08, 2011 11:18 am    Post subject: Reply with quote

koolspark wrote:
I'm sorry. I gave wrong LRECL for the SORTOUT file. Your sort works fine.


Why are you specifying the LRECL? DFSORT can automatically calculate the output LRECL.

koolspark wrote:

If I want to sort the sortout file based on the first 10 bytes, where/how should i specify the SORT FIELDS ?


What makes you think the output is NOT sorted on the first 10 bytes? Since the matching is done by the key on the first 10 bytes in both files , the output is indeed sorted on that.
_________________
Kolusu
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