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

what is jcl approach for programming?

4 Answers   IBM,


should I use Go back in the main program ? Yes we can use Go back in main program as well.

2 Answers   Xansa,


Which is not true about evaluate statement

0 Answers  


CAN ANY ONE HELP WHAT IS QTP? why it is nessery AND WEN IT IS USED?

1 Answers  


is this below syntax correct? CALL 'subprg' using A,B Please help

2 Answers  


i Want All cobol ERROR codes?

4 Answers   HCL, IBM,


What are the ways you can generate a copybook?

2 Answers  


What is a subscript ?

3 Answers  


If there are two copybooks which have same variables and we are using both the copybooks in our program. will there be an error and if i move values to the variable which copybook varibales gets the values i move in.

3 Answers   CTS,


what is search and searchall?what is the diffrence between them?give an best example?

3 Answers   BirlaSoft,


How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2 1?please clear my doubt any one

10 Answers   IBM,


hi. This is Ram.i have one doubt.why can't we display comp-3 variables directly? let me answer quickly plez........

1 Answers  


Categories