---
title: "COBOL Tricky Interview Question: Processing of 2 Files"
description: "In COBOL you can process two files by comparing key field. While coding you can follow different methods to process files. This is one the tricky question asked in recently in many interviews."
url: https://srinimf.com/2014/08/05/cobol-tricky-interview-question/
date: 2014-08-05
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2014/08/pexels-photo-3765030.jpeg?fit=1880%2C1253&ssl=1
categories: ["COBOL"]
tags: ["COBOL - Tricky Interview Question", "COBOL Tips and Tricks"]
type: post
lang: en
---

# COBOL Tricky Interview Question: Processing of 2 Files

Here are **COBOL scenario based [interview question](https://srinimf.com/2016/02/04/cobol-mostly-asked-interview-question-on-files/)s**. If the domain is Banking, surely this question you can expect in interview. Click to read on[Banking domain knowledge](http://bit.ly/2iodeWf).

---

32 Complex SQL queries

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

$1.00

---

## 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**

- [7 Tricky Micro Focus COBOL Questions](https://srinimf.com/2016/03/04/these-areas-need-more-focus-in-cobol-language/)DateMarch 4, 2016
- [COBOL PERFORM Until Vs Times](https://srinimf.com/2017/01/17/cobol-logic-with-complex-question-newly-asked/)DateJanuary 17, 2017
- [COBOL mostly asked Interview Question on Files](https://srinimf.com/2016/02/04/cobol-mostly-asked-interview-question-on-files/)DateFebruary 4, 2016

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2014%2F08%2F05%2Fcobol-tricky-interview-question%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2014%2F08%2Fpexels-photo-3765030.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=COBOL%20Tricky%20Interview%20Question%3A%20Processing%20of%202%20Files)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2014/08/05/cobol-tricky-interview-question/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2014/08/05/cobol-tricky-interview-question/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2014/08/05/cobol-tricky-interview-question/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2014/08/05/cobol-tricky-interview-question/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20COBOL%20Tricky%20Interview%20Question%3A%20Processing%20of%202%20Files&body=https%3A%2F%2Fsrinimf.com%2F2014%2F08%2F05%2Fcobol-tricky-interview-question%2F&share=email)
-

### Like this:

Like Loading…
