COBOL Tricky Interview Question: Processing of 2 Files

Here is tricky COBOL interview question in many interviews. If the domain is Banking, surely you need to have answer for this question. Here is for you Banking domain knowledge.


32 Complex SQL queries

Top selected Complex SQL queries frequently asked in all interviews of top software companies.

$1.00

Click here to purchase.

How to process 2 files by comparing key fields in COBOL?

Solution-1

  • Read the records in both the first file and the second file. If the key field matches, you can ignore it.
  • Let us say T, M files.
  • T < M means this is a new account so we need to update in the master file
  • T > M means an account is missing in the Master file, so we need to update it

Solution-2

  • If both files are the same number of records. It is good, our work is reduced
  • If T file comes to AT END you need to move HIGH VALUES into the key field
  • If M files come to  AT END you need to move HIGH VALUES into the key field
  • So you need to process till both key fields are equal to HIGH VALUES.

Note: Key fields must be in PIC (X) not numeric

Solution-3

  • To avoid a lot of I/Os, you can read data into a local array table, and you can process the records.

Also Read

Get new content delivered directly to your inbox.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.