IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Compare two files with a key and write a file with adds/chgs


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sreekanth341

New User


Joined: 06 May 2023
Posts: 2
Location: USA

PostPosted: Sat May 06, 2023 9:56 am
Reply with quote

Hi All,

I need to compare two files File 1 & File 2 with a total length of 326 each.

Key is first 11 characters in the two files and the key is unique and dups not allowed and the data to compare is from 12th position to 326th position (315).

If the key is present in both files compare the data from 12th position to 326th position if the data is not equal then write the record from 2nd file with prefix as CH. If the data is same.. then do nothing since there is no change no action needed on that record

If the key is present in file 1 only then write the record from 2nd file with prefix as DE

If the key is present in file 2 only then write the record from 2nd file with prefix as AD

File1: length 326 -- key is first 11 then data 315

12345678912ABCDEF
23456789123ABC
34567891234DEF


File2: length 326 -- key is first 11 then data 315

12345678912ABCDEF
23456789123ABCD
45678912345XYZ

Output expected: length 328 -- first two digit action code then key is first 11 then data 315

CH23456789123ABCD
AD45678912345XYZ
DE34567891234DEF


Thanks in advance.. Anyone can help me achieve this or guide me
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1280
Location: Bamberg, Germany

PostPosted: Sat May 06, 2023 10:20 am
Reply with quote

Please, use code/tags to provide code/data!

Also, what have you tried yourself to achieve the requirement?

Quote:
If the key is present in file 1 only then write the record from 2nd file with prefix as DE

This is not possible as there is no matching data in F2. Maybe you meant F1 (aka 1st DSN)?
Back to top
View user's profile Send private message
Sreekanth341

New User


Joined: 06 May 2023
Posts: 2
Location: USA

PostPosted: Sat May 06, 2023 10:38 am
Reply with quote

Sorry typo error I was referencing file 1 only — Joerg.Findeisen
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1280
Location: Bamberg, Germany

PostPosted: Sat May 06, 2023 10:44 am
Reply with quote

See this sample for FB80 input. Adapt this to your requirement.
Code:
//WHATEVER EXEC PGM=SORT
//F1       DD *                                         
12345678912ABCDEF                                       
23456789123ABC                                           
34567891234DEF                                           
/*                                                       
//F2       DD *                                         
12345678912ABCDEF                                       
23456789123ABCD                                         
45678912345XYZ                                           
/*                                                       
//SYSOUT   DD SYSOUT=*                                   
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  OPTION COPY
  JOINKEYS F1=F1,FIELDS=(1,11,A)                         
  JOINKEYS F2=F2,FIELDS=(1,11,A)                         
  JOIN UNPAIRED                                         
  REFORMAT FIELDS=(?,F1:1,80,F2:1,80)                   
  OUTFIL FNAMES=(SORTOUT),                               
    OMIT=(1,1,CH,EQ,C'B',AND,2,80,CH,EQ,82,80,CH),       
    REMOVECC,                                           
    IFTHEN=(WHEN=(1,1,CH,EQ,C'2'),BUILD=(C'AD',82,80)), 
    IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),BUILD=(C'DE',2,80)),   
    IFTHEN=(WHEN=NONE,BUILD=(C'CH',82,80))               
  END                                                   
/*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Format Binary file to EBCDIC JCL & VSAM 4
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files and write Matched/Unm... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
Search our Forums:

Back to Top