RSS Feed for This PostCurrent Article

Cobol Interview Questions

1. How do you sort in a COBOL program? Give sort file definition, sort statement syntax and meaning.

Syntax:
SORT file-1 ON ASCENDING/DESCENDING KEY key….
USING file-2
GIVING file-3.
USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2
GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.
file-1 is the sort workfile and must be described using SD entry in FILE SECTION.
file-2 is the input file for the SORT and must be described using an FD entry in FILE SECTION and SELECT clause in FILE CONTROL.
file-3 is the outfile from the SORT and must be described using an FD entry in FILE SECTION and SELECT clause in FILE CONTROL.
file-1, file-2 & file-3 should not be opened explicitly.
INPUT PROCEDURE is executed before the sort and records must be RELEASEd to the sort work file from the input procedure.
OUTPUT PROCEDURE is executed after all records have been sorted. Records from the sort work file must be RETURNed one at a time to the output procedure.

2.How do you define a sort file in JCL that runs the COBOL program?

Use the SORTWK01, SORTWK02,….. dd names in the step. Number of sort datasets depends on the volume of data being sorted, but a minimum of 3 is required.

3.What are the two ways of doing sorting in a COBOL program? Give the formats.

Use the SORTWK01, SORTWK02

4.Give the format of USING and GIVING in SORT statement. What are the restrictions with it?

Restrictions - Cannot massage records, cannot select records to be sorted.

5. What is the difference between performing a SECTION and a PARAGRAPH?

Performing a SECTION will cause all the paragraphs that are part of the section, to be performed.
Performing a PARAGRAPH will cause only that paragraph to be performed.

6.What is the use of EVALUATE statement?

Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no ‘break’ is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made.

7. What are the different forms of EVALUATE statement?
EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS
WHEN A=B AND C=D WHEN 100 ALSO ‘00′
imperative statement imperative statement
WHEN (D+X)/Y = 4 WHEN -305 ALSO ‘32′
imperative statement imperative statement
WHEN OTHER WHEN OTHER
imperative statement imperative statement
END-EVALUATE END-EVALUATE
EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE
WHEN 100 ALSO TRUE WHEN 100 ALSO A=B
imperative statement imperative statement
WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4)
imperative statement imperative statement
END-EVALUATE END-EVALUATE

8. How do you come out of an EVALUATE statement?

After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need of any extra code.

9.In an EVALUATE statement, can I give a complex condition on a when clause?

Yes.

10. What is a scope terminator? Give examples.

Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.

11. How do you do in-line PERFORM?

PERFORM … …
END PERFORM

Trackback URL

Post a Comment