Please let me know how to replace the records using key value (full or partial) in an output file from an input file. Size of both input and output has same.
For Example,
Note : Empno and Deptcode are the full key
Input file:
Empno Deptcode EmpName
10101 1 aa
10103 1 cc
10104 1 as
10105 1 ee
10201 1 dd
10202 1 ee
Output file before execution:
Empno Deptcode EmpName
10101 1 cc
10101 2 bb
10102 1 cc
10104 1 as
10105 1 ee
10201 1 dd
10202 1 ee
Now I have to remove extra records and also have to replace the existing records for the key(Empno) = 10101 which is the part key. I need the below result.
After Execution
Output file:
Empno Deptcode EmpName
10101 1 aa
10102 1 cc
10104 1 as
10105 1 ee
10201 1 dd
10202 1 ee
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
It's not clear what you want to do. It appears you want all of the non-duplicate records from the original "output" file. And you want to replace something in those records with something from the input file. But you haven't explained exactly what it is you want to replace. Do you want to replace the deptcode and empname, or just the deptcode, or just the empname? Only the records with 10101 have a different value for empname in the two files, so it's difficult to figure out what you're trying to do.
Please show a better example of the input files (for clarity, call them "input file1" and "input file2") and the expected output file (call it "output file") with all possible variations you have to handle. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input files. Give the starting position, length and formt of all relevant fields.
THE kEY VALUE WE ARE SPECIFYING IS MAY BE PARTIAL OR FULL KEY.
Requirement:
1. Replace the existing records in the output file from the input using the key value.
2. Also insert the extra records in the output file from the input using the same key value.
3. Delete extra records in the output file for the same key which is not in input file.
Please note another example.
For Example,
Input file1:
Empno Deptcode EmpName
10101 0 xx
10101 1 aa
10101 2 bb
10103 1 cc
Input file2:
Empno Deptcode EmpName
10101 1 cc
10101 2 bb
10101 3 ss
10102 1 cc
10104 1 as
Note : Empno and Deptcode are the full key
Here I want to process with this key (Empno) = 10101 which is the part key. I need the below result.
In output file(which is the input file2),
10101 0 xx -> this record should be add as a new one.
10101 1 cc ->this one to be replace to-> 10101 1 aa
10101 3 ss -> this record should be removed
and if any new
After Execution
Input file2:
Empno Deptcode EmpName
10101 0 xx
10101 1 aa
10101 2 bb
10102 1 cc
10104 1 as
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
To clarify, I believe the rules can be stated like this.
If an Empno in input file2 is found in input file1 (e.g. 10101) just keep the records with that Empno from input file1. If an Empno in input file2 is not found in input file1 (e.g. 10102), keep the records with that Empno from input file2.
If that's the case, then the following DFSORT/ICETOOL job will do what you asked for. I added a few more example records for completeness in testing. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
One thing i forgot to tell you that.. We are using VSAM files and not the sequential one. Sorry Man
As we expect, the above output is same, but I don't want the results in a separate output file and i need the results into Inputfile 2 itself (just like an updating this file and it should not affect the other key value records). Here I need to process only for the particular Key value and not for all the other keys.
Note: It has to be restoring the file using a key value from the backup (say Inputfile1,its a VSAM file).