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

where do u use low-value and high value in cobol

3 Answers   CGI,


In A cobol program , we can use COPY Statement in FILE- SECTION / WORKING-STORAGE SECTION / ENVIRONMENT DIVIION basically what is the difference

3 Answers   IBM,


Why we should use cursor ?

3 Answers  


I've one string with spaces ( I N D I A ). My question is I want remove the spaces & combine in to single string without space (INDIA).How we can write the cobol program & wich options we need to use. Please let me know.

10 Answers   Mascon,


sample code for read a 2nd record from last in flatfile how can do?

4 Answers   iNautix,






There are 5 fields and 1000 records in a file. Unload it into an array. Write the syntax for declaration and how will you unload it.

0 Answers  


.How to add one input & one Out file in existing cobol program. how approach tell me step by step.

2 Answers   Syntel,


What are the pertinent COBOL

0 Answers   IBM,


how can i see junk values in dclgen or in hostvariable of comp ?

0 Answers   DELL,


Why occurs cannot be used in 01 level in COBOL?

0 Answers   Arigo Infotech,


What is the figurative constant in cobol?

1 Answers  


How to retain the Duplicates in the one records?

3 Answers   CS,


Categories