Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

REPLACE records in file1 based on comparison with file2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
buzzvinodh_chandra

New User


Joined: 15 Jul 2009
Posts: 6
Location: US

PostPosted: Wed Jul 15, 2009 3:42 am    Post subject: REPLACE records in file1 based on comparison with file2
Reply with quote

Hi,

I want to compare 2 files , file1 and file2 based on key and output the matching record key with file1 data in the output file


File1 (first 2 bytes- key)
****
AS ASIA
AZ ARIZONA
NY NEWYORK

File2
*****
AS AMERICAN SAMOA
AZ ARIZONA
NY NEWYORK

outputfile
********
AS ASIA


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

Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Wed Jul 15, 2009 9:24 am    Post subject:
Reply with quote

Hi Vinodh,

These are some of the topics already discussed in the forum before.
Please refer and let us know if you have still were not able to do it...

Topic1
Topic2
Topic3
Topic4
Topic5
Back to top
View user's profile Send private message
buzzvinodh_chandra

New User


Joined: 15 Jul 2009
Posts: 6
Location: US

PostPosted: Wed Jul 15, 2009 11:28 pm    Post subject: Reply to: REPLACE records in file1 based on comparison with
Reply with quote

Hi Binop,

The related posts you gave does not help me.

Can anyone please helpme in getting the required results???

Thanks
Back to top
View user's profile Send private message
buzzvinodh_chandra

New User


Joined: 15 Jul 2009
Posts: 6
Location: US

PostPosted: Wed Jul 15, 2009 11:37 pm    Post subject:
Reply with quote

I actually modified my requirement slightly..

Compare the keys..if keys are matching then compare the next field...if that is not matching, then replace the record in file1 with file2 record

File1 (first 2 bytes- key)
****
AS ASIA
AZ ARIZONA
NY NEWYORK
CA CALIFORNIA

File2
*****
AS AMERICAN SAMOA
AZ ARIZONA
NY NEWYORK
NV NEVADA

outputfile ( ALL THE RECORDS IN FILE1 NEEDS TO BE OUTPUTED WITH MODIFICATIONS)
********
AS ASIA ---- ONLY THE POSITIONS 4 TO 15 NEEDS TO BE MODIFIED WITH FILE2 VALUES AS THE KEY (1-2) ARE MATCHING WITH FILE1
AZ ARIZONA
NY NEWYORK
CA CALIFORNIA
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jul 16, 2009 1:24 am    Post subject:
Reply with quote

Your explanations are quite confusing. You say ALL THE RECORDS IN FILE1 NEEDS TO BE OUTPUTED WITH MODIFICATIONS, but the outputfile you show in your latest post is the same as the original file1 (no modifications). Then you say ONLY THE POSITIONS 4 TO 15 NEEDS TO BE MODIFIED WITH FILE2 VALUES AS THE KEY (1-2) ARE MATCHING WITH FILE1, but the value you show is positions 4-15 is from file1 (ASIA), not from file2 (AMERICAN SAMOA).

I don't know how you expect anyone to help you when you can't explain clearly what you want to do or show an input and output example that makes sense.
Back to top
View user's profile Send private message
buzzvinodh_chandra

New User


Joined: 15 Jul 2009
Posts: 6
Location: US

PostPosted: Thu Jul 16, 2009 3:25 am    Post subject:
Reply with quote

Hi ,

Sorry for the confusion in my previous note..below is the actual need.

File1 (first 2 bytes- key)
****
AS AMERICAN SAMOA
AZ ARIZONA
NY NEWYORK
CA CALIFORNIA

File2
*****
AS ASIA
AZ ARIZONA
NY NEWYORK
NV NEVADA

outputfile ( ALL THE RECORDS IN FILE1 NEEDS TO BE OUTPUTED WITH MODIFICATIONS)
********
AS ASIA ---- ONLY THE POSITIONS 4 TO 15 NEEDS TO BE MODIFIED WITH FILE2 VALUES AS THE KEY (1-2) ARE MATCHING WITH FILE1
AZ ARIZONA
NY NEWYORK
CA CALIFORNIA
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jul 16, 2009 4:15 am    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what I think you asked for. I assumed that your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes. I also assumed that you want the output in the original order of the file1 input records as shown in your example (NY before CA).

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/80)
//IN2 DD DSN=...  input file2 (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN   DD    *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(T2) ON(1,2,CH) KEEPNODUPS WITH(4,15)
SORT FROM(T2) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'1',82:SEQNUM,8,ZD)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'2',82:8X)
/*
//CTL3CNTL DD *
  INCLUDE COND=(81,1,CH,EQ,C'1')
  SORT FIELDS=(82,8,ZD,A)
/*
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Thu Jul 16, 2009 1:43 pm    Post subject:
Reply with quote

If you want to use Syncsort then use Joinkey to get the desired results.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Sat Jul 18, 2009 2:10 am    Post subject: Reply to: REPLACE records in file1 based on comparison with
Reply with quote

Here is a SyncSort for z/OS job that will modify the records:
Code:
//SORT1  EXEC PGM=SORT                                 
//SORTJNF1 DD *                                       
AS AMERICAN SAMOA                                     
AZ ARIZONA                                             
NY NEWYORK                                             
CA CALIFORNIA                                         
//SORTJNF2 DD *                                       
AS ASIA                                               
AZ ARIZONA                                             
NY NEWYORK                                             
NV NEVADA                                             
//SORTOUT  DD SYSOUT=*                                 
//SYSOUT   DD SYSOUT=*                                   
//SYSIN    DD *                                           
   JOINKEYS FILES=F1,FIELDS=(1,2,A)                   
   JOINKEYS FILES=F2,FIELDS=(1,2,A)                   
   JOIN UNPAIRED,F1                                   
   REFORMAT FIELDS=(F1:1,80,F2:1,80),FILL=(X'FF')     
   INREC IFTHEN=(WHEN=(81,1,BI,EQ,X'FF'),BUILD=(1,80)),
         IFTHEN=(WHEN=NONE,BUILD=(1,3,84,15,19,62))   
   SORT FIELDS=COPY     
/*                               

Here is the output produced from the above job:
Code:
AS ASIA       
AZ ARIZONA   
CA CALIFORNIA
NY NEWYORK   

If you need the records in the same order as the original input File 1, let me know.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts CICS NEW SIT PARAMETERS CICS BEHAVIOR... Kyle Carroll CICS 0 Fri Nov 04, 2016 11:55 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us