.
10. When is a scope terminator mandatory?
Ans:
Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. For readability, it's recommended coding practice to always make scope terminators explicit.
11. Can you use REDEFINES clause in the FILE SECTION?
Ans:
No
12. How will you define your record descriptions in the FILE SECTION if you want to use three different record descriptions for the same file?
Ans:
FD filename
DATA RECORDS ARE rd01, rd02, rd03.
01 rd01 PIC X(n).
01 rd02 PIC X(n).
01 rd03 PIC X(n).
13. When will you open a file in the EXTEND mode?
Ans:
When an existing file should be appended by adding new records at its end. EXTEND mode opens the file for output, but the file is positioned following the last record on the existing file.
14. What does a CLOSE WITH LOCK statement do?
Ans:
The statement closes an opened file and it prevents the file from further being opened by the same program.
15. Which mode of opening is required when REWRITE is used?
Ans:
I-O mode
16. Why is it necessary that the file be opened in I-O mode for REWRITE?
Ans:
Before the REWRITE is performed, the record must be read from the file. Hence REWRITE includes an input operation and an output operation. Therefore, the file must be opened in I-O mode.
17. Which clause can be used instead of checking for FILE STATUS = 10?
Ans:
FILE STATUS 10 is the end of file condition. Hence AT END clause can be used.
18. What is the format of a simple SORT verb? What kinds of files can be sorted using SORT?
Ans:
SORT workfile ON ASC/DESC KEY key1, ASC/DESC KEY key2 ...
USING inputfile GIVING outputfile
Only sequential files can be sorted in this way.
19. What are the different rules of SORT that needs to be considered?
Ans:
The input and output files must remain closed because SORT opens them and closes during the operation, The work file must have a SELECT clause. The work file must have sort description SD entry in the FILE SECTION. Input and Output files must have FD entries
20. 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.
21. 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
22. 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 ...
23. What are the access mode requirements of START statement?
Ans:
Access mode must be SEQUENTIAL or DYNAMIC
24. What are the opening mode requirements of START statement?
Files must be opened in the INPUT or I-O mode.
25.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.
26. 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.
27. 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.
28. 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.
29. 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.
30. 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
31. 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.
32. 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.
33. What is the significance of 'above the line' and 'below the line'?
Ans:
Before IBM introduced MVS/XA architecture in the 1980's a program's virtual storage was limited to 16 megs. Programs compiled with a 24-bit mode can only address 16 MB of space, as though they were kept under an imaginary storage line. With COBOL II a program compiled with a 31 bit mode can be 'above the 16 Mb line. (This 'below the line', 'above the line' imagery confuses most mainframe programmers, who tend to be a literal minded group.)
34. What was removed from COBOL in the COBOL II implementation?
Ans:
Partial list: REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY, TIME-OF-DAY, STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and RESET TRACE.
35. Explain call by context by comparing it to other calls.
Ans:
The parameters passed in a call by context are protected from modification by the called program. In a normal call they are able to be modified.
36. What is the difference between comp and comp-3 usage? Explain other COBOL usages.
Comp is a binary usage, while comp-3 indicates packed decimal. The other common usages are binary and display. Display is the default. Comp is defined as the fastest/preferred numeric data type for the machine it runs on. IBM Mainframes are typically binary and AS400's are packed.'
37. I understand the possible causes for S0C1 & S0C4 abends, but what are they really?
Ans:
A S0C1 occurs if the CPU attempts to execute binary code that isn't a valid machine instruction; e.g. if you attempt to execute data. A S0C4 is a memory protection violation. This occurs if a program attempts to access storage beyond the areas assigned to it.
38. What happens when we move a comp-3 field to an edited ( say z(9).zz-)
Ans:
The editing characters are to be used with data items with usage clause as display, which is the default. When you try displaying a data item with usage as computational it does not give the desired display format because the data item is stored as packed decimal. So if u want this particular data item to be edited u have to move it into a data item whose usage is display and then have that particular data item edited in the format desired.
39. What are the causes for S0C1, S0C4, S0C5, S0C7, S0CB abends
Ans:
S0C1 - May be due to 1.Missing or misspelled DD name 2.Read/Write to unopened dataset 3.Read to dataset opened output 4.Write to dataset opened input 5.Called subprogram not found.
S0C4 may be due to 1.Missing Select statement(during compile) 2.Bad Subscript/index 3.Protection Exception 4.Missing parameters on called subprogram 5.Read/Write to unopened file 6.Move data from/to unopened file.
S0C5 May be due to 1.Bad Subscript/index 2.Close an unopen dataset 3.Bad exit from a perform 4.Access to I/O area(FD) before read.
S0C7 may be due to 1.Numeric operation on non-numeric data 2.Un-initialize working-storage 3.Coding past the maximum allowed sub script. S0CB may be due to 1.Division by Zero
40. What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL program i.e. a program which is not calling any other program.
Ans:
Both give the same results when a program is not calling any other program.
41. What is the difference between an External and a Global Variable 's?
Ans:
Global variables are accessible only to the batch program whereas external variables can be referenced from any batch program residing in the same system library.
42. WHAT IS REPORT-ITEM?
Ans:
A REPORT-item is a field to be printed that contains EDIT SYMBOLS
43. You are writing report program with 4 levels of totals:city,state,region and country. The codes being used can be the same over the different levels, meaning a city code of 01 can be in any number of states, and the same applies to state and region code show. Do you do your checking for breaks and how do you do add to each level?
Ans:
Always compare on the highest-level first, because if you have a break at a highest level, each level beneath it must also break. Add to the lowest level for each rec but add to the higher level only on break.
44. What is PSB & ACB?
Ans:
PSB : Program specification block. Inform about how a specific program is to be access one or more IMS DB. It consists of PCB(Prg Communication Block). Information to which segment in DB can be accessed, what the program is allowed to do with those segment and how the DB is to be accessed. ACB : Access Control Blocks are generated by IMS as an expansion of information contained in the PSB in order to speed up the access to the applicable DBD's.
45. What's a LDS(Linear Data Set) and what's it used for ?
Ans:
LDS is a VSAM dataset in name only. It has unstructured 4k (4096 bytes) fixed size CIs which do not contain control fields and therefore from VSAM's standpoint they do not contain any logical records. There is no freespace, and no access from Cobol. Can be accessed by DB2 and IMS fast path datasets. LDS is essentially a table of data maintained on disk. The 'table entries' must be created via a user program and can only be logically accessed via a user program. When passed, the entire LDS must be mapped into storage, then data is accessed via base and displacement type processing.
46. What is the Importance of GLOBAL clause According to new standards of COBOL
Ans:
When any data name, file-name , Record-name, condition name or Index defined in an Including Program can be referenced by a directly or indirectly in an included program, Provided the said name has been declared to be a global name by GLOBAL Format of Global Clause is01 data-1 PIC 9(5) IS GLOBAL.
47. What is the Purpose of POINTER Phrase in STRING command
Ans:
The Purpose of POINTER phrase is to specify the leftmost position within receiving field where the first transferred character will be stored
48.How do we get currentdate from system with century?
Ans:
By using Intrinsic function, FUNCTION CURRENT-DATE
49.what is the difference between search and search all in the table handling?
Ans:
Search is a linear search and search all is a binary search.
50.What is the maximum length of a field you can define using COMP-3?
Ans:
10 Bytes (S9(18) COMP-3).