a. Can the OPTIONAL clause in COBOL only be coded for input
files?
b. If it is coded for files opened in OUTPUT, I-O or EXTEND
mode, will it give a compilation error?
c. If there are no compilation errors and if such files are
not coded in the JCL, will the OPEN statement run fine when
these files are opened?
d. How will a WRITE statement work for the above files?

Answers were Sorted based on User's Feedback



a. Can the OPTIONAL clause in COBOL only be coded for input files? b. If it is coded for files o..

Answer / kb

An OPTIONAL file is being opened as EXTEND or I-O. Optional
files are files that are not necessarily present each time
the program is run. You can define files opened in INPUT,
I-O, or EXTEND mode as optional by using the SELECT OPTIONAL
phrase in the FILE-CONTROL paragraph.

Is This Answer Correct ?    4 Yes 1 No

a. Can the OPTIONAL clause in COBOL only be coded for input files? b. If it is coded for files o..

Answer / sandy

OPTIONAL clause can be specified for files opened INPUT,
OUTPUT, I-O and EXTEND modes. It will not give any
compilation error.
If we do not have DD statements for such files during
execution, the following file status code would be obtained
when we open the file.
INPUT (JCL RC = 0)
------
Open statement will give file status of '05'. Open is
successfule but file is not present.

EXTEND (JCL RC = 0)
------
Open statement give file status of '96'. No DDNAME present.

I-O (JCL RC = 0)
------
Open statement give file status of '96'. No DDNAME present.

WRITE (JCL SOC4 ABEND)

Is This Answer Correct ?    5 Yes 2 No

Post New Answer

More COBOL Interview Questions

if a>b continue display x. dispaly y. end-if display 1 display 2. display 3. what should be my output ?

3 Answers  


Write the code implementing the perform … varying.

0 Answers  


maximum of how many screens we can open in emulator

2 Answers  


Which is not true about evaluate statement

0 Answers  


What is Control Break processing ?

1 Answers   iGate,






What divisions, sections and paragraphs are mandatory for a COBOL program?

8 Answers   Arigo Infotech,


Can we put move statement in COBOL copybook

3 Answers   Global Logic,


How many sections are there in data division in COBOL?

0 Answers   B-Ways TecnoSoft,


What is binary search?

3 Answers  


State the various causes of s0c1, s0c5 and s0c7.

0 Answers  


there is a file whose ORGANISATION is INDEXED.you want to read the records from the file in RANDOM fashion as well as sequentially.then which of the access mode would you specify? a.SEQUENTIAL b.RANDOM c.DYNAMIC D.ACCESS MODE has nothing to do with it

3 Answers   TCS,


Differentiate between structured cobol programming and object-oriented cobol programming.

0 Answers  


Categories