70. What are INPUT PROCEDURE and OUTPUT PROCEDURE?
Ans: Sometimes, it is necessary that the records must be edited before or after the sorting. In such cases,
SORT workfile ASC/DESC KEY key1, ...
INPUT PROCEDURE IS ipproc
OUTPUT PROCEDURE is outproc
Is used. In the INPUT PROCEDURE the input file is opened, records are read and edited and then are released to the sorting operation. Finally the file is closed. RELEASE sortrecname FROM inp-rec.
In the OUTPUT PROCEDURE, output file is opened, the sorted record is returned to the Output record area and then the record is written. Finally the file is closed. RETURN workfile RECORD into out-rec.
71. What is the format of a simple MERGE verb? Can INPUT PROCEDURE and OUTPUT PROCEDURE can be specified for MERGE verb?
Ans: MERGE work file ON ASC/DESC KEY key1...
USING inputfile1, inputfile2...
GIVING outputfile
INPUT PROCEDURE cannot be specified. Only OUTPUT PROCEDURE can be specified
72. How will you position an indexed file at a specific point so that the subsequent sequential operations on the file can start from this point?
Ans: Use START
START filename KEY IS EQ/GT/LT.. dataname
INVALID KEY ...
73. What are the access mode requirements of START statement?
Ans: Access mode must be SEQUENTIAL or DYNAMIC
74. What are the opening mode requirements of START statement?
Files must be opened in the INPUT or I-O mode.
75.What is the LINKAGE SECTION used for?
Ans: The linkage section is used to pass data from one program to another program or to pass data from a PROC to a program. It is part of a called program that 'links' or maps to data items in the calling program's working storage. It is the part of the called program where these share items are defined.
76. If you were passing a table via linkage, which is preferable - a subscript or an index?
Ans: 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. Indexing uses binary displacement. Subscripts use the value of the occurrence.
77. What is the difference between a subscript and an index in a table definition?
A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then increment or decrement it by ADD TO and SUBTRACT FROM statements. An index is a register item that exists outside the program's working storage. You SET an index to a value and SET it UP BY value and DOWN BY value. Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET. Need to have index for a table in order to use SEARCH, SEARCH ALL Cobol statements.
78. What is an in line PERFORM? When would you use it? Anything else to say about it?
The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs. 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 paraname rather than in-line perform.
79. What is the use of EVALUATE statement? How do you come out of an EVALUATE statement?
Ans: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, There is no need of any extra code. EVALUATE can be used in place of the nested IF THEN ELSE statements.
80. What are the different forms of EVALUATE statement?
Ans: 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
81. Can you use the INSPECT (with TALLYING option) Cobol verb in a CICS COBOL program?
Ans: Yes, under COBOL II environment, but not OS/VS COBOL.
82. What is an explicit scope terminator?
A scope terminator brackets its preceding verb, eg. IF .. END-IF, so that all statements between the verb and its scope terminator are grouped together. Other common COBOL II verbs are READ, PERFORM, EVALUATE, SEARCH and STRING.
No comments:
Post a Comment