FAQs(16 to 30)

16) How do you define a sort file in JCL that runs the COBOL program?

A) 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.

17) What is the difference between performing a SECTION and a PARAGRAPH? 

A) 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.

18) What is the use of EVALUATE statement?

A) 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.

19) What are the different forms of EVALUATE statement?

A)

EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS

WHEN A=B AND C=D WHEN 100 ALSO '00'

imperative stmt imperative stmt

WHEN (D+X)/Y = 4 WHEN -305 ALSO '32'

imperative stmt imperative stmt

WHEN OTHER WHEN OTHER

imperative stmt imperative stmt

END-EVALUATE END-EVALUATE

EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE

WHEN 100 ALSO TRUE WHEN 100 ALSO A=B

imperative stmt imperative stmt

WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4)

imperative stmt imperative stmt

END-EVALUATE END-EVALUATE

20) How do you come out of an EVALUATE statement? 

A) 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.

21) In an EVALUATE statement, can I give a complex condition on a when clause?

A) Yes.

22) What is a scope terminator? Give examples.

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

23) How do you do in-line PERFORM?

A) PERFORM ... <UNTIL> ...

<sentences>

END-PERFORM

24) When would you use in-line perform?

A) When the body of the perform will not be used in other paragraphs. If the body of the perform is a generic type of code

(used from various other places in the program), it would be better to put the code in a separate Para and use

PERFORM Para name rather than in-line perform.

25) What is the difference between CONTINUE & NEXT SENTENCE ?

A) They appear to be similar, that is, the control goes to the next sentence in the paragraph. But, Next Sentence would

take the control to the sentence after it finds a full stop (.). Check out by writing the following code example, one if

sentence followed by 3 display statements (sorry they appear one line here because of formatting restrictions) If 1 > 0

then next sentence end if display 'line 1' display 'line 2'. display 'line 3'. *** Note- there is a dot (.) only at the end of

the last 2 statements, see the effect by replacing Next Sentence with Continue ***

26) What does EXIT do ?

A) Does nothing ! If used, must be the only sentence within a paragraph.

27) Can I redefine an X(100) field with a field of X(200)?

A) Yes. Redefines just causes both fields to start at the same location. For example:

01 WS-TOP PIC X(1)

01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).

If you MOVE '12' to WS-TOP-RED,

DISPLAY WS-TOP will show 1 while

DISPLAY WS-TOP-RED will show 12.

28) Can I redefine an X(200) field with a field of X(100) ?

A) Yes.