View previous topic :: View next topic
|
Author |
Message |
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
Back to top |
|
|
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
I guess below part of the text in the linked post by Rob explains much clear of OPTIONAL clause.
Quote: |
Bottom line is that OPTIONAL is a reserved word and when coded into the program SELECT statement it treats that file as that, optional. If the file is not physically present when the program executes it does not cause the program to abend. If present it processes the file. |
It can be used based on requirements. |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
muthuvel wrote: |
I guess below part of the text in the linked post by Rob explains much clear of OPTIONAL clause.
Quote: |
Bottom line is that OPTIONAL is a reserved word and when coded into the program SELECT statement it treats that file as that, optional. If the file is not physically present when the program executes it does not cause the program to abend. If present it processes the file. |
It can be used based on requirements. |
Muthuvel Thanks for the reply.
Do you mean that if we code the file in JCL which does not exist, the program will not abend if we use OPTIONAL. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Why not try and see what happens.
I believe that if the dataset is coded in the JCL and the dataset does not exist ........................... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
The use of OPTIONAL applies to files in COBOL which may or may not be used by the program; its use says absolutely nothing about whether or not the file referenced by the DD statement exists. If your JCL references a file that does not exist, depending on the DISP the file will be created or the job will be flushed -- totally independently of whether or not the COBOL program actually uses the file. |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
expat wrote: |
Why not try and see what happens.
I believe that if the dataset is coded in the JCL and the dataset does not exist ........................... |
Hi expact i have tried it.
I have coded the optional clause in the program and in the JCL i have given a file which does not exist as Disp=shr.
Then i got JCL Error .
Then i have added the all the parametser for teh creation of the file in the JCL.
Now the program went fine.New input file was created and program went fine as it goes for an EMPTY file.
But program behaved in the same manner even i did not specify OPTIONAL.
That is the reason i raised this question |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
the issue is not about the file existing/being present ( tht' s taken care by jcl )
but about the DDNAME being there or not
flow...
file without OPTIONAL....
jcl error if file not there ( for disp=shr ) and DDNAME present
cobol abend if DDNAME not there
file with OPTIONAL
cl error if file not there ( for disp=shr ) and DDNAME present
cobol processing by manual if DDNAME not there |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Try the OPTIONAL in the program without defining the file in the JCL...
IIRC, if defined in the JCL, the system tries to enqueue the dataset and if it doesn't exist, the JCL will fail.... |
|
Back to top |
|
|
|