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
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 literals?
How arrays can be defined in COBOL?
Write a program that uses move corresponding.
What is the compute verb? How is it used?
How are the next sentence and continue different from each other?
Which mode is used to operate the sequential file?
How do we get current date from system with century in COBOL?
What is rmode(24)
What are the different rules for performing sort operation?
What is static and dynamic call in cobol?
how to convert the recors form vsam file to db2 table tru file aid
How do you get the data to code the BMS macro?
How many sections are there in data division in COBOL?
Program A (Normal COBBAT) calling a B Program (DB2COBOL, COBBATDB which is using a VSAM file. its a dynamic call. How we will handle VSAM file decleration in our from JCL from where we are running A PGM. And should we have PLAN for A pGM also. if possible can some one post a sample JCL. Thanks for help in advance.