22. When is a scope terminator mandatory?
Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. For readability, it's recommended coding practice to always make scope terminators explicit.
23. Can you use REDEFINES clause in the FILE SECTION?
24. Can I redefine an X(100) field with a field of X(200)?
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.
25. How will you define your record descriptions in the FILE SECTION if you want to use three different record descriptions for the same file?
DATA RECORDS ARE rd01, rd02, rd03.
01 rd01 PIC X(n).
01 rd02 PIC X(n).
01 rd03 PIC X(n).
26. When will you open a file in the EXTEND mode?
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.
27. What does a CLOSE WITH LOCK statement do?
The statement closes an opened file and it prevents the file from further being opened by the same program.
28. Which mode of opening is required when REWRITE is used?
29. Why is it necessary that the file be opened in I-O mode for REWRITE?
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.
30. Which clause can be used instead of checking for FILE STATUS = 10?
FILE STATUS 10 is the end of file condition. Hence AT END clause can be used.
31. 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?
START filename KEY IS EQ/GT/LT.. dataname
INVALID KEY ...
32. What are the access mode requirements of START statement?
Access mode must be SEQUENTIAL or DYNAMIC.
33. What is the LINKAGE SECTION used for?
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.
34. If you were passing a table via linkage, which is preferable - a subscript or an index?
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.
35. 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.
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. What is COMP-1? COMP-2?
COMP-1 - Single precision floating point. Uses 4 bytes.
COMP-2 - Double precision floating point. Uses 8 bytes.
38. How do you define a variable of COMP-1? COMP-2?
No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.
39. How many bytes does a S9(7) COMP-3 field occupy ?
Will take 4 bytes. Sign is stored as hex value in the last nibble.
General formula is INT((n/2) + 1)), where n=7 in this example.
40. How many bytes does a S9(7) SIGN trailing separate field occupy ?
Will occupy 8 bytes (one extra byte for sign).
41. What is the maximum value that can be stored in S9(8) COMP?
42. What is COMP SYNC?
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 computational field is faster.
43. What is the maximum size of a 01 level item in COBOL I? in COBOL II?
44.What is the difference between PIC 9.99 and 9v99?
PIC 9.99 is a FOUR-POSITION field that actually contains a decimal point where as PIC 9v99 is THREE-POSITION numeric field with implied or assumed decimal position.
45.How is PIC 9.99 is different from PIC 9v99?
PIC 9.99 is a four position field that actually contains a decimal point where as 9v99 is a three position numeric field with an implied or assumed decimal point.
46.What does PIC 9v99 Indicate?
PICTURE 9v99 is a three position Numeric field with an implied or assumed decimal point after the first position; the v means an implied decimal point.
47. What happens when we move a comp-3 field to an edited ( say z(9).zz-)
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.
48. What are the causes for S0C1, S0C4, S0C5, S0C7, S0CB abends ?
S0C1 - May be due to
· Missing or misspelled DD name
· Read/Write to unopened dataset
· Read to dataset opened output
· Write to dataset opened input
· Called subprogram not found.
S0C4 may be due to
· 1.Missing Select statement(during compile)
· Bad Subscript/index
· Protection Exception
· Missing parameters on called subprogram
· Read/Write to unopened file
· Move data from/to unopened file.
S0C5 May be due to
· Bad Subscript/index
· Close an unopen dataset
· Bad exit from a perform
· Access to I/O area(FD) before read.
S0C7 may be due to
· Numeric operation on non-numeric data
· Un-initialize working-storage
· Coding past the maximum allowed sub script.
49. What is the difference between an External and a Global Variable 's?
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.
50. What is PSB & ACB?
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.
51. What's a LDS(Linear Data Set) and what's it used for ?
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.
52. What is the Importance of GLOBAL clause According to new standards of COBOL
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.
53. What is the Purpose of POINTER Phrase in STRING command
The Purpose of POINTER phrase is to specify the leftmost position within receiving field where the first transferred character will be stored
54. How do we get currentdate from system with century?
By using Intrinsic function, FUNCTION CURRENT-DATE
55.How many Sections are there in Data Division?.
SIX SECTIONS 1.'FILE SECTION' 2.'WORKING-STORAGE SECTION' 3.'LOCAL-STORAGE SECTION' 4.'SCREEN SECTION' 5.'REPORT SECTION' 6.'LINKAGE SECTION'
In COBOL II, there are only 4 sections. 1.'FILE SECTION' 2.'WORKING-STORAGE SECTION' 3.'LOCAL-STORAGE SECTION' 4.'LINKAGE SECTION'.
56. What is the difference between a DYNAMIC and STATIC call in COBOL.?
To correct an earlier answer:All called modules cannot run standalone if they require program variables passed to them via the LINKAGE section. Dynamically called modules are those that are not bound with the calling program at link edit time (IEWL for IBM) and so are loaded from the program library (joblib or steplib) associated with the job. 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.
57. How can I tell if a module is being called DYNAMICALLY or STATICALLY?
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 variable, 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 variable. Calling a program name literal (CALL).