Cobolfaq

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 8

366043931.

doc

Question: What is the diffenence between Structured Cobol Programming and


Object Oriented COBOL programming?

Answer: Structured programming is a Logical way of programming, you divide


the functionalities into modules and code logically. OOP is a Natural way of
programming, you identify the objects first, then write fuctions, 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.

Question: what is difference between next sentence and continue

Answer: They appear to be similar, that is, the control goes to the next sentence
in the paragraph. But, Next Sentence would take the control to the sentence after
it finds a fullstop (.). Check out by writing the following code example, one if
sentence followed by 3 display statements (sorry they appear one line here
because of formatting restrictions) If 1 > 0 then next sentence end if display 'line
1' display 'line 2'. display 'line 3'. *** Note- there is a dot (.) only at the end of
the last 2 statements, see the effect by replacing Next Sentence with Continue ***
Hope this helps!

Question: what is difference between next sentence and continue

Answer: i don't know

Question: 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.

Question: which type of sort do you know?

Answer: internal sort and external sort.

Question: What is the diffenence between Structured Cobol Programming and


Object Oriented COBOL programming ?

Answer: ?????????

Page 1 of 8
366043931.doc

Question: I HAVE HEARD ABOUT VSCOBOL AND COBOL II. IS THERE


ANY OTHER CATEGORY/CLASSIFICATION IN COBOL ? KINDLY GIVE
ME A DETAILED EXPLANATION. I WOULD ALSO LIKE TO KNOW WHAT
COBOL 370 IS.

Answer: ?????????????

Question: Can you use INSPECT command under CICS? Is it costly?


Answer:

Question: What is SET Logic TO TRUE?


Answer: ?

Question: PIC S9(4)COMP IS USED INPSPITE OF COMP-3 WHICH


OCCUPIES LESS SPACE.WHY?
Answer: The Q&A submitted by sivakumar on March 24,1998 is absolutely
wrong. Dear Sivakumar, for your kind information: 9(4) COMP uses only 2 bytes
and 2 bytes is not = 4 words. 9(4) COMP-3 uses 3 bytes. 3 bytes is more than 2
bytes. Hence COMP is preferred over COMP-3 in this case.

Question: 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.

Question: Can JUSTIFIED be used for all the data types?


Answer: No,it can be used only with alphabetic and alphanumeric data types.

Question: 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

Page 2 of 8
366043931.doc

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.

Question: 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

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

Question: Question: 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.

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.

Question: WHAT IS THE DIFFERENCE BETWEEN EXTERNAL AND


GLOBAL VARIABLES?

Page 3 of 8
366043931.doc

Answer: 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.

Question: 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 ANE NUMBER OF STATES, AND THE SAME
APPLIES TO STATE AND REGION CODEShOW DO YOU DO YOUR
CHEKING FOR BREAKS AND HOW DO YOU DO ADD TO EACH LEVEL?

Answer: 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 A BREAK.

Question: What is difference between COBOL and VS COBOL II?.

Answer: In using COBOL on PC we have only flat files and the programs can
access only limited storage, whereas in VS COBOL II on M/F the programs can
access upto 16MB or 2GB depending on the addressing and can use VSAM files
to make I/O operations faster.

Question: Why occurs can not be used in 01 level ?

Answer: because, Occurs clause is there to repeat fields with same format, not
the records.

Question: WHAT IS REPORT-ITEM?

Answer: A REPORT-ITEM IS A FIELD TO BE PRINTED THAT CONTAINS


EDIT SYMBOLS

Question: What is PSB & ACB?

Answer: PSB : Program specification block. Infor about how a specific program
is to be access one or more IMS DB. It consist of PCB(Prg Communication
Block). Information to which 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.

Question: Question: What's a LDS(Linear Data Set) and what's it used for ?

Page 4 of 8
366043931.doc

Answer: 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.

Question: answer to anon question for difference between next and continue
cluase

Answer: FOR ANON , Dear friend the difference between the next and continue
verb is that in the continue verb it is used for a situation where there in no eof
condition that is the records are to be accessed again and again in an file ,
whereas in the next verb the indexed file is accessed sequentially ,hence when
index clase is accessed sequentially read next record command is used,i hope that
is satisfactory

Question: What is the Importance of GLOBAL clause According to new


standards of COBOL

Answer: 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 GLOBALFormat of Global Clause is01 data-1 pic 9(5) IS
GLOBAL.

Question: What is the Purpose of POINTER Phrase in STRING command

Answer: The Purpose of POINTER phrase is to specify the leftmost position


whithin Receiving field where the first transfered character will be stored

Question: How do we get currentdate from system with century?

Answer: By using Intrinsic function, FUNCTION CURRENT-DATE

Question: what is the difference between search and search all in the table
handling?

Answer: search is a linear search and search all is a binary search.

Question: What is the maximum length of a field you can define using COMP-3?

Answer: 10 Bytes (S9(18) COMP-3).

Page 5 of 8
366043931.doc

Question: 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.

Answer: The program will go in an infinite loop.

Question: Q.HOW MANY SECTIONS ARE THERE IN DATA DIVISION?.

Answer: SIX SECTIONS1.FILE SECTION2.WORKING-STORAGE


SECTION3.LOCAL-STORAGE SECTION4.SCREEN SECTION5.REPORT
SECTION6.LINKAGE SECTION

Question: 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

Question: What is the difference between a DYNAMIC and STATIC call in


COBOL.

Answer: To correct an earlier answer:All called modules cannot run standalone if


they require program varibles 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 choosen, else the linkage editor will
not generate an executable as it will expect ull 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.

Question: What is the defference between PIC 9.99 and 9v99?

Answer: PIC 9.99is 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.

Question: How is PIC 9.99 is defferent from PIC 9v99?

Answer: 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.

Page 6 of 8
366043931.doc

Question: what is Pic 9v99 Indicates?


Answer: 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.

Question: WHAT GUIDELINES SHOULD BE FOLLOWED TO WRITE A


STRUCTURED COBOL PRG'M?

Answer: 1) USE 'EVALUATE' STMT FOR CONSTRUCTING CASES. 2) USE


SCOPE TERMINATORS FOR NESTING. 3)USE IN LINE PERFORM STMT
FOR WRITING 'DO ' CONTRUCTIONS. 4)USE TEST BEFORE AND TEST
AFTER IN THE PERFORM STMT FOR WRITING DO-WHILE
CONSTRUCTIONS.

Question: read the following code. 01 ws-n pic 9(2) value zero. a-para move 5 to
ws-n. perform b-para ws-n times.b-para. move 10 to ws-n.how many times will b-
para be executed ?

Answer: 5 times only. it will not take the value 10 that is initialized in the loop.

Question: What is the difference between SEARCH and SEARCH ALL? What is
more efficient?

Answer: SEARCH is a sequential search from the beginning of the table.


SEARCH ALL is a binary search, continually dividing the table in two halves
until a match is found. SEARCH ALL is more efficient for tables larger than 70
items.

Question: What are some examples of command terminators?

Answer: END-IF, END-EVALUATE

Question: 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.

Question: Give some advantages of REDEFINES clause.

Answer: 1. You can REDEFINE a Variable from one PICTURE class to another
PICTURE class by using the same memory location.2. By REDEFINES we can
INITIALISE the variable in WORKING-STORAGE Section itself.3. We can
REDEFINE a Single Variable into somany subvariables.(This facility is very
useful in solving Y2000 Problem.)

Question: Why do we code s9(4)comp.Inspite of knowing comp-3 willoccupy less


space.

Page 7 of 8
366043931.doc

Answer: Here s9(4)comp is small integer ,so two words equal to i byteso 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 byteso totally it will
occupy 3 bytes.

Question: The maximum number of dimensions that an array can have in


COBOL-85 is ________.

Answer: SEVEN in COBOL - 85 and THREE in COBOL - 84

Question: What is the LINKAGE SECTION used for?

Answer: The linkage section is used to pass data from one program toanother
program or to pass data from a PROC to a program.

Page 8 of 8

You might also like