MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Conditionally Create a file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
rajeshkoratti
Beginner


Joined: 14 Feb 2006
Posts: 42
Topics: 22

PostPosted: Thu Mar 16, 2006 4:31 am    Post subject: Conditionally Create a file Reply with quote

Hi
I have a cobol program which writes into an output file.

In the JCL i have given DISP(NEW,CATLG,DELETE) as the Disp params for the output file.

Now my program writes into the output file only under certain conditions.

My requirement is like this :

If the program is not writing into the output file, the file should not be created at all. In simpler terms i dont want an empty file to be created.
Is there any means i can handle this in the JCL?
_________________
Thanks and Regards..
Rajesh
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Mar 16, 2006 4:58 am    Post subject: Reply with quote

Let the DISP be as is. After your program step is over, code a step to count the number of records in the empty file. If empty, some RC would be set. Test that RC using IF statement of JCL and code a step to delete the file.

If you want to get more stylish, call IDCAMS from your program to delete the file. You can search for an example in this helpboard (I think, Kolusu posted an example.) This approach has a disadvantage that, the DSN would be hard-coded in the program. Deleting a file via DD name using IDCAMS has not worked for me before.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Jaya
Beginner


Joined: 02 Sep 2005
Posts: 77
Topics: 10
Location: Cincinnati

PostPosted: Thu Mar 16, 2006 5:13 am    Post subject: Reply with quote

Rajesh,

Quote:
My requirement is like this :

If the program is not writing into the output file, the file should not be created at all. In simpler terms i dont want an empty file to be created.
Is there any means i can handle this in the JCL?


All the files mentioned in JCL are allocated to either SMS or JES prior to program execution.Hence you cannot control file allocation in JCL based on your program output(i.e dynamic file creation).

The only way to dynamically allocate file based on your condition is to handle them in your application program by calling the dynamic allocation routines like BPXWDYN.

Please check this link for the cute sample COBOL code to allocate dynamic files using BPXWDYN.

http://www.mvsforums.com/helpboards/viewtopic.php?t=4572&highlight=bpxwdyn

You can also search for 'BPXWDYN' in all forums to know more information about dynamic file allocation.

Hope it helps..

Thanks,
Jaya.
_________________
"Great spirits have always encountered violent opposition from mediocre minds."
-Albert Einstein
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group