| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		Ram Beginner
  
  Joined: 12 Jan 2004 Posts: 53 Topics: 12
 
  | 
		
			
				 Posted: Thu Jul 07, 2005 12:02 am    Post subject: SELECT OPTIONAL clause in FILE CONTROL SECTION | 
				     | 
			 
			
				
  | 
			 
			
				Hi,
 
 
I was going through one of our programs and saw the OPTIONAL clause in the file control section. I browsed a couple of COBOL manuals and this is what they had to say.
 
 
 	  | Code: | 	 		  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 defining them with the SELECT OPTIONAL phrase in the FILE-CONTROL
 
paragraph of your program. | 	  
 
It was mentioned that if a file does'nt exist, then it will be created with system defined attributes. Now is it similar to having a DUMMY dataset assigned to the file in the JCL ?
 
 
Also could you please let me know what is the use of defining files as OPTIONAL ? 
 
 
Thanks,
 
Ram
 
Whatever you do in this life, it echoes in eternity ! | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		kolusu Site Admin
  
 
  Joined: 26 Nov 2002 Posts: 12395 Topics: 75 Location: San Jose
  | 
		
			
				 Posted: Thu Jul 07, 2005 6:29 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				 	  | Quote: | 	 		  
 
Now is it similar to having a DUMMY dataset assigned to the file in the JCL ? 
 
 | 	  
 
 
Ram, 
 
Nope. Optional files are created each time the program runs. Basically these files are used as temporary files. For ex: if you are doing an internal sort and you want to store the intermediate results of the sort , then you can use an optional file. It will be created and deleted at the end of the job.
 
 
Hope this helps...
 
 
Cheers
 
 
Kolusu _________________ Kolusu 
 
www.linkedin.com/in/kolusu | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Ram Beginner
  
  Joined: 12 Jan 2004 Posts: 53 Topics: 12
 
  | 
		
			
				 Posted: Fri Jul 08, 2005 4:14 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				Kolusu,
 
 
Thank you for the prompt response. The program that I was referring to had a VSAM file defined as Optional and it did not have a corresponding dd statement in the JCL. In this case will it cause any problems if I code a DUMMY dataset against the missing ddname in the JCL? I have understood that the optional file feature is helpful for intermediate storage. But in my case I cant see it serving any purpose.
 
 
Thanks,
 
Ram | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		pzmohanty Beginner
  
  Joined: 20 May 2004 Posts: 97 Topics: 43 Location: hyderabad, India
  | 
		
			
				 Posted: Sun Aug 13, 2006 1:46 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				Hi Kolusu,
 
 
Continuing with OPTIONAL option of SELECT clause, we can have OPTIONAL clause if a file is opened in INPUT / I-O / EXTEND mode and at  the run time file gets created and also get deleted by end of program.
 
I am just curious to know why OPTIONAL option is not allowed with OUTPUT mode whereas it is allowed with I-O & EXTEND mode. What difference does it make.
 
 
Thanks in advance _________________ Priya Ranjan Mohanty
 
Consultant
 
Kanbay Software (I) pvt. Ltd.
 
Hyderabad | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		kolusu Site Admin
  
 
  Joined: 26 Nov 2002 Posts: 12395 Topics: 75 Location: San Jose
  | 
		
			
				 Posted: Sun Aug 13, 2006 7:29 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				 	  | Quote: | 	 		  
 
I am just curious to know why OPTIONAL option is not allowed with OUTPUT mode whereas it is allowed with I-O & EXTEND mode. What difference does it make. 
 
 | 	  
 
pzmohanty, 
 
 
You can open the file  in OUTPUT mode provided that you have the run-time option CBLQDA turned on. CBLQDA(ON) is the setting that dynamically allocates with DISP=(NEW,DELETE,DELETE) file when an output DD name is opened but missing from the TIOT. 
 
 
Hope this helps...
 
 
Cheers
 
 
Kolusu _________________ Kolusu 
 
www.linkedin.com/in/kolusu | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		| 
		
		 | 
	
	
		 |