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
)If there are 10 steps in GDG, if I want to refer the step2 after step5 . what should I do?
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.
How can you get the ksds file records into your cobol program?
What is the use of intialize verb?
Explain how to differentiate call by context by comparing it to other calls?
How do you reference the fixed block file formats from cobol programs
) How do u handle errors in BMS macro?
Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc
i was faced one question- i have value -00001234.56 Suppress the zeroes and the output should be -1234.56 But Not - 1234.56 spaces should not be available after suppressing the zeroes. logic in jcl and cobol?
There are 5 fields and 1000 records in a file. Unload it into an array. Write the syntax for declaration and how will you unload it.
What is the difference between PIC 9.99 and 9v99 in COBOL?
What is the difference between structured cobol programming and object alternativelyiented cobol programming?
how to move the records from file to array table. give with code example
Write the code to count the sum of n natural numbers.
How do you reference the following file formats from cobol programs?