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
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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.
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
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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).
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.