Page Two Advanced COBOL

Q11. If you were passing a table via linkage, which is preferable – a subscript or an index?

A11. Wake up – you haven’t been paying attention! It’s not possible to pass an index via linkage. The index is not part of the calling programs working storage. Those of us who’ve made this mistake, appreciate the lesson more than others.

Q12. Explain the difference between an internal and an external sort, the pros and cons, internal sort syntax etc.

A12. An external sort is not COBOL; it is performed through JCL and PGM=SORT. It is understandable without any code reference. An internal sort can use two different syntaxes: 1.) USING, GIVING sorts are comparable to external sorts with no extra file processing; 2) INPUT PROCEDURE, OUTPUT PROCEDURE sorts allow for data manipulation before and/or after the sort.

Q13. What is the difference between comp and comp-3 usage? Explain other COBOL usages.

A13. Comp is a binary usage, while comp-3 indicates packed decimal. The other common usages are binary and display. Display is the default.

Q14. When is a scope terminator mandatory?

A14. Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. For readability, it’s recommended coding practice to always make scope terminators explicit.

Q15. In a COBOL II PERFORM statement, when is the conditional tested, before or after the perform execution?

A15. In COBOL II the optional clause WITH TEST BEFORE or WITH TEST AFTER can be added to all perform statements. By default the test is performed before the perform.

Q16. In an EVALUTE statement is the order of the WHEN clauses significant?

A16. Absolutely. Evaluation of the WHEN clauses proceeds from top to bottom and their sequence can determine results.

Q17. What is the default value(s) for an INITIALIZE and what keyword allows for an override of the default.

A17. INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. The REPLACING option can be used to override these defaults.

Q18. What is SET TO TRUE all about, anyway?

A18. In COBOL II the 88 levels can be set rather than moving their associated values to the related data item. (Web note: This change is not one of COBOL II’s better specifications.)

Q19. What is LENGTH in COBOL II?

A19. LENGTH acts like a special register to tell the length of a group or elementary item.

Q20. What is the difference between a binary search and a sequential search? What are the pertinent COBOL commands?

A20. In a binary search the table element key values must be in ascending or descending sequence. The table is ‘halved’ to search for equal to, greater than or less than conditions until the element is found. In a sequential search the table is searched from top to bottom, so (ironically) the elements do not have to be in a specific sequence. The binary search is much faster for larger tables, while sequential works well with smaller ones. SEARCH ALL is used for binary searches; SEARCH for sequential.

Q21. What is the point of the REPLACING option of a copy statement?

A21. REPLACING allows for the same copy to be used more than once in the same code by changing the replace value.