Cobol Interview Question PDF
Cobol Interview Question PDF
4. What are the steps you go through while creating a COBOL program executable?
A. DB2 pre-compiler (if embedded SQL is used), CICS translator (if CICS program), Cobol
compiler, Link editor. If DB2 program, create plan by binding the DBRMs.
6. What happens when the ON SIZE ERROR phrase is specified on a COMPUTE statement?
A. If the condition occurs, the code in the ON SIZE ERROR phrase is performed, and the
content of the destination field remains unchanged. If the ON SIZE ERROR phrase is not
specified, the assignment is carried out with truncation. There is no ON SIZE ERROR
support for the MOVE statement.
7. How will you associate your files with external data sets where they physically reside?
A. Using SELECT clause, the files can be associated with external data sets. The SELECT
clause is defined in the FILE-CONTROL paragraph of Input-Output Section that is coded
Environment Division. The File structure is defined by FD entry under File-Section of Data
Division for the OS.
IBMMAINFRAMES.com
9. Explain the use of Declaratives in COBOL?
Declaratives provide special section that are executed when an exceptional condition occurs.
They must be grouped together and coded at the beginning of procedure division and the
entire procedure division must be divided into sections. The Declaratives start with a USE
statement. The entire group of declaratives is preceded by DECLARIVES and followed by
END DECLARITIVES in area A. The three types of declaratives are Exception (when
error occurs during file handling), Debugging (to debug lines with 'D' coded in w-s section)
and Label (for EOF or beginning...) declaratives.
IBMMAINFRAMES.com
17. What is the default, passing BY REFERENCE or passing BY CONTENT or passing BY
VALUE?
A. Passing by reference (the caller and the called share the same memory).
18. Where do you define your data in a program if the data is passed to the program from a
Caller program?
A. Linkage Section
21. What is the difference between Structured Cobol Programming and Object Oriented
COBOL programming?
A. Structured programming is a Logical way of programming using which you divide the
functionality's into modules and code logically. OOP is a Natural way of programming in
which you identify the objects, first then write functions and procedures around the
objects. Sorry, this may not be an adequate answer, but they are two different
programming paradigms, which is difficult to put in a sentence or two.
23. How many number of bytes and digits are involved in S9(10) COMP?
8 bytes (double word) and 10 digits. Up to 9(9) comp use full word, up to 9(18) comp needs
double word.
24. Which picture clause will you use to define a hexadecimal item in a VALUE clause?
A. 01 ws-hexitem PIC X(2) value X'020C'.
01 ws-hex redefines PIC S9(3) comp-3.
25. How many numbers of decimal digits are possible, when the amount of storage allocated
for a USAGE COMP item is a) half word b) full word c) double word?
A. 2 bytes (halfword) for 1-4 Digits 4 bytes (fullword) for 5-9
8 bytes (doubleword) for 10-18
IBMMAINFRAMES.com
28. How many subscripts or indexes are allowed for an OCCURS clause?
A. 7
31. Can you specify PIC clause and a VALUE with an OCCURS clause? Will the following
code compile without errors?
01 WS-TABLE.
03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE SPACES.
A. Yes, the code will compile without any errors.
32. What would be the output, when the following code is executed?
01 WS-TABLE.
03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE 'AAAAA'.
A. It cannot be executed because the code will compile with error ' "VALUE" literal "'AAAA'"
exceeded the length specified in the "PICTURE" definition'.
33. 01 WS-TABLE.
03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE 'A'.
03 WS-EX REDEFINES WS-TABLE-EL PIC X(5). What can you expect?
A. Compile error. Direct Redefinition of OCCURS clause is not allowed.
34. 01 WS-TABLE.
03 WS-TABLE-EL OCCURS 5 TIMES.
04 FILLER-X PIC X(1) VALUE 'A'. 04 WS-EX REDEFINES FILLER-X PIC X(1).
What would be the output of DISPLAY WS-TABLE?
A. 'AAAAA'. The code will compile and execute as Redefinition of an item subordinate to
OCCURS clause.
IBMMAINFRAMES.com
37. What would be the output, when the following code is executed?
01 WS-TABLE.
03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE 'A'.
:::
DISPLAY WS-TABLE.
A. The output will display 'AAAAA'
38. Can a SEARCH be applied to a table which does not have an INDEX defined?
A. No, the table must be indexed.
39. What are the different rules applicable to perform a serial SEARCH?
A. The SEARCH can be applied to only a table which has the OCCURS clause and INDEXED
BY phrase,
Before the use of the SEARCH the index must have some initial value. To search from
beginning, set the index value to 1. Use the SEARCH verb without ALL phrase
40. A table has two indexes defined. Which one will be used by the SEARCH verb?
A. The index named first will be used, by Search.
41. What are the different rules applicable to perform a binary SEARCH?
A. The table must be sorted in ascending or descending order before the beginning of the
SEARCH. Use OCCURS clause with ASC/DESC KEY IS dataname1 option
The table must be indexed. There is no need to set the index value. Use SEARCH ALL verb
43. What is the difference between a binary search and a sequential search? What are the
pertinent COBOL commands?
A. 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 Search works well with smaller ones.
SEARCH ALL is used for binary searches; SEARCH for sequential.
44. Explain the difference between an internal and an external sort. The pros & cons &
internal sort syntax ...
A. An external sort is not coded as a COBOL program; it is performed through JCL and
PGM=SORT. One can use IBM utility SYNCSORT for external sort process. 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. 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.
IBMMAINFRAMES.com
• 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.
• .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.
45. Which is the default, TEST BEFORE or TEST AFTER for a PERFORM statement?
TEST BEFORE. By default the condition is checked before executing the instructions under
Perform.
46. What is the difference between PERFORM ... WITH TEST AFTER and PERFORM ...
WITH TEST BEFORE?
A. If TEST BEFORE is specified, the condition is tested at the beginning of each repeated
execution of the specified PERFORM range. If TEST AFTER is specified, the condition is
tested at the end of the each repeated execution of the PERFORM range. With TEST
AFTER, the range is executed at least once.
49. What is the default value(s) for an INITIALIZE and what keyword allows for an override of
the default.
A. INITIALIZE sets spaces to alphabetic and alphanumeric fields. Initialize sets Zeroes to
numeric fields. FILLER, OCCURS DEPENDING ON items are left untouched. The
REPLACING option can be used to override these defaults.
54. How will you count the number of characters in a null-terminated string?
A. MOVE 0 TO char-count
INSPECT null-terminated-string TALLYING char-count FOR CHARACTERS BEFORE
X"00"
55. Which statement will you use to move non-null characters from a null-terminated String?
A. UNSTRING null-terminated-string DELIMITED BY X"00" INTO target-area
COUNT IN char-count. (There are other methods, such as 1) using PERFORM 2) using
SEARCH 3) using INSPECT and MOVE etc...)
IBMMAINFRAMES.com
56. 77 COUNTR PIC 9 VALUE ZERO.
01 DATA-2 PIC X(11). . .
INSPECT DATA-2
TALLYING COUNTR FOR LEADING "0"
REPLACING FIRST "A" BY "2" AFTER INITIAL "C"
If DATA-2 is 0000ALABAMA, what will DATA-2 and COUNTER be after the execution of
INSPECT verb?
A. Counter=4. Data-2 will not change as the Initial
'C' is not found.
62. How will you define your record descriptions in the FILE SECTION if you want to use three
different record descriptions for the same file?
A. FD filename
DATA RECORDS ARE rd01, rd02, rd03.
01 rd01 PIC X(n).
01 rd02 PIC X(n).
01 rd03 PIC X(n).
IBMMAINFRAMES.com
66. Why is it necessary that the file be opened in I-O mode for REWRITE?
A. 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.
67. Which clause can be used instead of checking for FILE STATUS = 10?
A. FILE STATUS 10 is the end of file condition. Hence AT END clause can be used.
68. What is the format of a simple SORT verb? What kinds of files can be sorted using
SORT?
A. SORT workfile ON ASC/DESC KEY key1, ASC/DESC KEY key2 ...
USING inputfile GIVING outputfile
Only sequential files can be sorted in this way.
69. What are the different rules of SORT that needs to be considered?
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
71. What is the format of a simple MERGE verb? Can INPUT PROCEDURE and OUTPUT
PROCEDURE can be specified for MERGE verb?
A. 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?
A. Use START
START filename KEY IS EQ/GT/LT.. dataname
INVALID KEY ...
IBMMAINFRAMES.com
76. If you were passing a table via linkage, which is preferable - a subscript or an index?
A. 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?
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, There is no need of any
extra code. EVALUATE can be used in place of the nested IF THEN ELSE statements.
81. Can you use the INSPECT (with TALLYING option) Cobol verb in a CICS COBOL
program?
A. Yes, under COBOL II environment, but not OS/VS COBOL.
83. What is the significance of 'above the line' and 'below the line'?
A. 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
IBMMAINFRAMES.com
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.)
87. I understand the possible causes for S0C1 & S0C4 abends, but what are they really?
A. 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.
88. What happens when we move a comp-3 field to an edited ( say z(9).zz-)
A. 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.
89. What are the causes for S0C1, S0C4, S0C5, S0C7, S0CB abends
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
90. 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.
Both give the same results when a program is not calling any other program.
91. What is the difference between an External and a Global Variable 's?
A. 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.
93. 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?
IBMMAINFRAMES.com
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.
96. What is the Importance of GLOBAL clause According to new standards of COBOL
A. 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.
99.what is the difference between search and search all in the table handling?
A. Search is a linear search and search all is a binary search.
100.What is the maximum length of a field you can define using COMP-3?
A. 10 Bytes (S9(18) COMP-3).
IBMMAINFRAMES.com
For DYNAMIC calling of a module the DYNAM compiler option must be chosen, else the
linkage editor will not generate an executable as it will expect null address resolution of all
called modules. A STATICally called module is one that is bound with the calling module
at link edit, and therefore becomes part of the executable load module.
110.What care has to be taken to force program to execute above 16 Meg line?
A. Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should
never have SIZE(MAX).BUFSIZE can be 2K, efficient enough.
112.Why do we code s9(4)comp. Inspite of knowing comp-3 will occupy less space.
A. Here s9(4)comp is small integer ,so two words equal to 8 bytes. Totally it will occupy 2
bytes(4 words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2 bytes
and sign will occupy 1/2 bytes totally it will occupy 3 bytes.
113.The maximum number of dimensions that an array can have in COBOL-85 is ________.
Answer: SEVEN in COBOL - 85 and THREE in COBOL - 84
IBMMAINFRAMES.com
115.What are the different data types available in COBOL?
A. Alpha-numeric (X), alphabetic (A) and numeric (9).
120.My program has an array defined to have 10 items. Due to a bug, I find that even if the
program access the 11th item in this array, the program does not abend. What is wrong with
it?
A. Must use compiler option SSRANGE if you want array bounds checking. Default is
NOSSRANGE.
IBMMAINFRAMES.com
127.How is sign stored in Packed Decimal fields and Zoned Decimal fields?
A. Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the
storage. Zoned Decimal fields: As a default, sign is over punched with the numeric value
stored in the last bite.
134.How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?
A. Will occupy 8 bytes (one extra byte for sign).
B. 135.What is the maximum size of a 01 level item in COBOL I? in COBOL II?
In COBOL II: 16777215
136.What is COMP SYNC?
A. Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or
RIGHT.
For binary data items, the address resolution is faster if they are located at word boundaries in
the memory. For example, on main frame the memory word size is 4 bytes. This means that
each word will start from an address divisible by 4. If my first variable is x(3) and next one is
s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start from byte 3 (
assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from
address 4. You might see some wastage of memory, but the access to this comp field is
faster.
137.How do you reference the following file formats from COBOL programs?
Fixed Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,
BLOCK CONTAINS 0.
Fixed Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,
do not use BLOCK CONTAINS.
Variable Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V,
BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD. i.e. JCL record
length will be max record length in program + 4
Variable Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS
V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec
length will be max rec length in pgm + 4.
ESDS VSAM file - Use ORGANISATION IS SEQUENTIAL.
KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, Alternate Record
Key Is
RRDS File - Use ORGANISATION IS RELATIVE, RELATIVE KEY IS
Printer File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK
CONTAINS 0. (Use RECFM=FBA in JCL DCB).
IBMMAINFRAMES.com
138.What are different file OPEN modes available in COBOL? In which modes are the files
Opened to write.
A. Different Open modes for files are INPUT, OUTPUT, I-O and EXTEND. Of which Output
and Extend modes are used to write new records into a file.
139.In the JCL, how do you define the files referred to in a subroutine?
A. Supply the DD cards just as you would for files referred to in the main program.
140.Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?
A. Can rewrite(record length must be same), but not delete.
148.How do you set a return code to the JCL from a COBOL program?
A. Move a value to RETURN-CODE register. RETURN-CODE should not be declared in
your program.
IBMMAINFRAMES.com
//xxxxxxx SYSOUT=(A,INTRDR) where 'A' is output class, and dataset should be opened for
output in the program. Define a 80 byte record layout for the file.
I understand the possible causes for S0C1 & S0C4 abends, but what are they really?
Answer: 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.
IBMMAINFRAMES.com
What divisions,sections and paragraphs are mandatory for a COBOL program?
Answer: IDENTIFICATION DIVISION and PROGRAM-ID paragraph are mandataory for a
compilation error free COBOL program.
Ans we to bala s bandlas question what happens when we move a comp-3 field to an edited ( say
z(9).zz-)
Answer: the edititing characters r to be used with data items with usage clause as display which
is the default.when u try displaying a data item with usage as computational it does not give the
desired display format becoz 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 diplay and then have that
particular data item edited in the format desired.
What are the causes for S0C1, S0C4, S0C5, S0C7, S0CB abends
Answer: 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
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.
IBMMAINFRAMES.com
Answer: Both give the same results when a program is not calling any other program. The answer
given by Mr.Krishnan that when go back is coded the program goes into infinite loop is not
correct. Goback will give the control to the system even though it is a single program.
What is the maximum length of a field you can define using COMP-3?
Answer: 10 Bytes (S9(18) COMP-3).
IBMMAINFRAMES.com
How can I tell if a module is being called DYNAMICALLY or STATICALLY?
Answer: The ONLY way is to look at the output of the linkage editor (IEWL)or the load module
itself. If the module is being called DYNAMICALLY then it will not exist in the main module, if
it is being called STATICALLY then it will be seen in the load module.Calling a working
storage varible, containing a program name, does not make a DYNAMIC call. This type of
calling is known as IMPLICITE calling as the name of the module is implied by the contents of
the working storage varible. Calling a program name literal (CALL
What care has to be taken to force program to execute above 16 Meg line?
Answer: Make sure that link option is AMODE=31 and RMODE=ANY.Compile option should
never have SIZE(MAX).BUFSIZE can be 2K, effecient enough.
The maximum number of dimensions that an array can have in COBOL-85 is ________.
Answer: SEVEN in COBOL - 85 and THREE in COBOL - 84
IBMMAINFRAMES.com
What are the differences between COBOL and COBOL II?
There are at least five differences: COBOL II supports structured programming by using in line
PERFORMs and explicit scope terminators, it introduces new features (EVALUATE, SET ..
TO TRUE, CALL .. BY CONTEXT, etc), it permits programs to be loaded and addressed above
the 16 megabyte line, it does not support many old features (READY TRACE, REPORT-
WRITER, ISAM, etc.), and it offers enhanced CICS support.
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.
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.
NEXT SENTENCE gives control to the verb following the next period. CONTINUE gives
control to the next verb after the explicit scope terminator. (This is not one of COBOL II's finer
implementations). It's safest to use CONTINUE rather than NEXT SENTENCE in COBOL II.
What is the significance of 'above the line' and 'below the line'?
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.)
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.
The linkage section 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.
IBMMAINFRAMES.com
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 incremented or decremented 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.
If you were passing a table via linkage, which is preferable - a subscript or an index?
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.
Explain the difference between an internal and an external sort, the pros and cons, internal sort
syntax etc.
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. 3/28/00 Dave Herrmann: 'I was reading your FAQ on
Cobol, as an fyi 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.'
Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. For
readability, it's recommended coding practice to always make scope terminators explicit.
In a COBOL II PERFORM statement, when is the conditional tested, before or after the perform
execution?
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.
Absolutely. Evaluation of the WHEN clauses proceeds from top to bottom and their sequence
can determine results.
What is the default value(s) for an INITIALIZE and what keyword allows for an override of the
default.
INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. The
REPLACING option can be used to override these defaults.
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.)
IBMMAINFRAMES.com
What is LENGTH in COBOL II?
LENGTH acts like a special register to tell the length of a group or elementary item.
What is the difference between a binary search and a sequential search? What are the pertinent
COBOL commands?
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.
REPLACING allows for the same copy to be used more than once in the same code by changing
the replace value.
Use TEST to produce object code that can be executed with VSCOBOL II batch or interactive
debug. When you specify TEST, thefollowing options go into effect: RES, NOFDUMP,
NOOPTIMIZE, andOBJECT. Use OPTIMIZE to reduce the run time of your object
program;optimization may also reduce the amount of main storage your objectprogram uses.
Since OPTIMIZE increases compile time, it should notbe used when debugging.The OPTIMIZE
option is turned off in the case of a severe-levelerror or higher. OPTIMIZE and TEST are
mutually exclusive. If youuse both, OPTIMIZE is ignored.
IBMMAINFRAMES.com
A subscript is an occurrence value. An index is adisplacement value. For example if you have a
list of month nameseach occupying 9 bytes, then the value of a subscript for the month of May
would be 5, but the index would be 36. A formula to calculateindex value when the occurrence
and item length are known is:Index-Value = (Occurrence -1) * Item-Length
IBMMAINFRAMES.com