Suppose, file A has 100 records and file B has 500 records. We
want to write records common to both A and B into file C and
records which are present only in either A or B into another file D.
What should be the logic of Cobol program to achieve this?
Answer Posted / karan
If we do not want to go with cobol then it can be easily
done with SORT, ICETOOL( Splice option) which i feel is
faster and simpler instead of writing a compare program.
If there is a compultion to use a cobol pgm then soln will
be -
PERFORM untill (EOF A and EOF B)
if f1 = f2
move file1-rec to file3-rec. write file3-rec
read f1 & f2.
if f1 < f2
move file1-rec to file4-rec. write file4-rec.
read f1.
if f1 > f2
move file2-rec to file4-rec. write file4-rec
read f2.
END PERFORM
IF EOF A and not EOF B
PERFORM until EOF B
move move file2-rec to file4-rec.
write file4-rec
read f2.
END PERFORM
ElSE
IF EOF B and not EOF A
PERFORM until EOF A
move move file1-rec to file4-rec.
write file4-rec
read f1.
END PERFORM
END
note: files should be in sorted order ASC before program
runs.
This is a generic solution to al such compare programs.
| Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
What rules are to be followed while using the corresponding options?
how do you reference the rrds file formats from cobol programs
Write a cobol program making use of the redefine clause.
How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?
What happens when we move a comp-3 field to an edited (say z (9). Zz-)?
Write down the divisions of cobol program?
how do you reference the ksds vsam file formats from cobol programs
System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..
how do you reference the variable block file formats from cobol programs
For rewrite, why is it mandatory that file needs to be opened?
i want to learn mainframe..any websites and material to learn from basic..? my mail id : rajeswaribe2010@gmail.com
how do you reference the esds vsam file formats from cobol programs
I have to write to a outfile where the number of records in that file should be the header of that file using IMS.. can anyone help me in this issue
What are the cobol coding sheets?
How do u write test cases?