View previous topic :: View next topic |
Author |
Message |
rajeshkoratti Beginner
Joined: 14 Feb 2006 Posts: 42 Topics: 22
|
Posted: Thu Mar 16, 2006 4:31 am Post subject: Conditionally Create a file |
|
|
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 |
|
 |
Cogito-Ergo-Sum Advanced
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
|
Posted: Thu Mar 16, 2006 4:58 am Post subject: |
|
|
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 |
|
 |
Jaya Beginner

Joined: 02 Sep 2005 Posts: 77 Topics: 10 Location: Cincinnati
|
Posted: Thu Mar 16, 2006 5:13 am Post subject: |
|
|
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 |
|
 |
|
|