100% found this document useful (1 vote)
182 views4 pages

COBOL Scenario Interview Questions

The document provides a series of COBOL scenario-based interview questions and answers, covering topics such as removing duplicates from files, handling variable-length records, reading files backwards, merging sorted files, debugging SOC7 abends, implementing pagination in CICS-COBOL, counting records in VSAM files, handling file status, performance tuning tips, and using CALL to pass variables to subprograms. Each question includes a brief explanation and example code where applicable. This serves as a practical guide for COBOL programming scenarios commonly encountered in interviews.

Uploaded by

manishkrnanand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
182 views4 pages

COBOL Scenario Interview Questions

The document provides a series of COBOL scenario-based interview questions and answers, covering topics such as removing duplicates from files, handling variable-length records, reading files backwards, merging sorted files, debugging SOC7 abends, implementing pagination in CICS-COBOL, counting records in VSAM files, handling file status, performance tuning tips, and using CALL to pass variables to subprograms. Each question includes a brief explanation and example code where applicable. This serves as a practical guide for COBOL programming scenarios commonly encountered in interviews.

Uploaded by

manishkrnanand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

COBOL Scenario-Based Interview Questions and Answers

1. How do you remove duplicates from a file using COBOL?

You can remove duplicates by sorting the input file and comparing current and previous records.

Example Code:

```cobol

READ IN-FILE

AT END MOVE 'Y' TO EOF-FLAG

NOT AT END

IF EMP-ID NOT = WS-PREV-EMP-ID

WRITE OUT-REC FROM IN-REC

MOVE EMP-ID TO WS-PREV-EMP-ID

END-IF

END-READ

```

Assumes input is sorted by EMP-ID.

2. How do you handle a file that has variable-length records in COBOL?

Use RECORD IS VARYING clause.

```cobol

FD EMP-FILE

RECORD IS VARYING IN SIZE FROM 10 TO 100

DEPENDING ON WS-REC-LEN

```

Allows reading variable-length records.


3. How to read a file backwards in COBOL?

COBOL can't read sequential files backward directly.

Workaround:

1. Store records in an array.

2. Process array in reverse order.

4. How to merge two sorted files without duplicates?

Compare keys of both files, write the smaller one.

```cobol

IF A-KEY < B-KEY

WRITE A

ELSE IF A-KEY > B-KEY

WRITE B

ELSE

WRITE A

READ BOTH

```

5. How do you debug a SOC7 abend in COBOL?

SOC7 = Data exception (usually numeric).

Steps:

- Check dump offset

- Match with source line

- Use DISPLAYs before numeric moves

- Use NUMVAL to validate alphanumeric data


6. How to implement pagination (Page In/Page Out) in CICS-COBOL?

Use Temporary Storage (TSQ) to store all records. Maintain current page index using EIBCALEN or

COMMAREA.

7. How to count the number of records in a VSAM file?

Use a simple loop with READ and counter increment.

```cobol

ADD 1 TO REC-COUNT

READ VSAM-FILE UNTIL EOF

```

8. How do you handle file status in COBOL?

Always declare FILE STATUS in FILE-CONTROL.

```cobol

IF WS-FILE-STAT = '00'

CONTINUE

ELSE DISPLAY ERROR

```

9. What are some performance tuning tips for COBOL programs?

- Use COMP/COMP-3 for arithmetic fields

- Avoid unnecessary file access

- Use binary counters

- Minimize SORTs

10. How to use CALL and pass variables to subprograms?

Use CALL with USING clause.


```cobol

CALL 'SUBPROG' USING VAR1 VAR2

LINKAGE SECTION.

01 VAR1 PIC X(10).

01 VAR2 PIC 9(4).

```

You might also like