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

Difference between array and sub-script ?

0 Answers   HCL,


What is comp-1 and comp-2?

0 Answers  


The hierarchy of the execution of logical operators is (a) NOT AND OR (b) AND OR NOT (c) OR AND NOT (d) OR NOT AND

10 Answers   Huawei, IBM, TCS,


How to increase the logical record length of existing PS file?

7 Answers  


db2 variable decimal(15,2) what is the equalent size of cobol variable

2 Answers   Syntel,


how to code in cobol while using variable block file?

1 Answers  


What is the difference between write & move in COBOL?

3 Answers   CSC, HHB,


9(2).99 how many bytes take? Why . consider as a byte?

2 Answers  


How is sign stored in a comp-3 field?

7 Answers  


I have 100 records in a file.. i want to sort the records from 5 to 5o... give the syntax...

2 Answers   CTS, DSRC,


hai friends ,i have HSBc exam on this sunday,my platform is Mainframe,i have 1 year exp,pls any one send me placement papers of Hsbc and technical questions on mainframe

6 Answers   Citi Bank, CitiGroup, HSBC, iNautix, Wipro,


What will happen if a variable is declared as below.. Explain with an example? Working storage section:- 01 WS-VARX PIC X(10) VALUE 'ABCDEFGHIJ'. 01 WS-VARN REDEFINES WS-VARX PIC 9(5) VALUE '12345'. What will happen I want Display WS-VARX and WS-VARN?

3 Answers   Xansa,


Categories