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
In COBOL programming, what is PERFORM? What is VARYING?
How do you reference the following file formats from cobol programs?
How many bytes S(8) comp field occupy and its maximum value?
how we sort two input files based on a common column and giving one o/p file please send me the coding logic?
Hi pls anybody tell me about " ANALYSIS DOCUMENT PREPARATION AND ESTIMATION OF TASK " (in real time project)."I want to update a sequential file in my project" for that purpose i need both structures i mean analysis document and estimation of task.
What are the different rules of SORT operation?
Can we redefine the field of x(200) to less than 200?
if we display var1 then what will b displayed in below condition. 77 var1 pic s9(2) value -10. 77 var1 pic s9(2) value -11. " " " -12. " " " -13. -14 ... ... -19.
Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?
write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc
What are INPUT PROCEDURE and OUTPUT PROCEDURE?
Define static linking and dynamic linking.
Why occurs cannot be used in 01 level in COBOL?
Write a program that uses move corresponding.
Write the code implementing the perform … varying.