Page 1 of 2

COBOL SELECT CLUASE

PostPosted: Thu Feb 21, 2013 2:48 pm
by rajufis_01
Hi,
I have one File-A declared with select clause(assign to DD name)... in the JCL I am not giving DD name of File-A
the job should run without fail, how we can achieve this?? is there any special registers while declaring the file in select clause

Re: COBOL SELECT CLUASE

PostPosted: Thu Feb 21, 2013 3:10 pm
by BillyBoyo
Dig out the manuals for your version of Cobol and look at the SELECT clause, specifically with OPTIONAL, and see if that might be what you want.

Re: COBOL SELECT CLUASE

PostPosted: Fri Feb 22, 2013 11:48 am
by dick scherrer
Hello,

If you are not gving the file-a ddname, make sure the code does not open the file.

Possibly i misunderstand.

Re: COBOL SELECT CLUASE

PostPosted: Fri Feb 22, 2013 8:50 pm
by tonysam
How about calling the program from a clist or rexx exec that first issues an allocation statement?

Re: COBOL SELECT CLUASE

PostPosted: Tue Feb 26, 2013 12:05 pm
by rosh8129
Hi,
You can use [Optional] Clause in Select statement like :

Select Optional File-1 assign to dd-name

It will make your file optional. If u will not use dd name for this file in JCL. It will take as empty file. JCl will not be abend.

Hope it helps,
Roshan

Re: COBOL SELECT CLUASE

PostPosted: Tue Feb 26, 2013 9:04 pm
by rajufis_01
thanks for your reply Rosh....
I have declared like this in the Cobol program
SELECT OPTIONAL File-1 assign to DD-name

but when I am running my JCL I am getting open error even tough I have opened in OPEN INPUT FILE-1

I have declared in the JCL in the below

// DD DSN=File-1,DISP=SHR


In the JCL what needs to be given to overcome this scenario, I mean JCL should not be abended.

Thanks in advance,
Raj

Re: COBOL SELECT CLUASE

PostPosted: Tue Feb 26, 2013 9:14 pm
by Robert Sample
Raj, if your select looks like
SELECT OPTIONAL FILE-A ASSIGN TO FILEA
then there will be two cases:
1) FILEA DD name is not present in the JCL. The OPTIONAL clause will keep COBOL from recognizing this as an error. Note that this is referring to the DD name, NOT THE DATA SET NAME.
2) FILEA DD name is present in the JCL. The data set will be opened by COBOL and processed normally.

In no circumstances can you submit JCL that references a data set that does not exist and have the JCL ignore that file. If you reference a data set in your JCL, and you are indicating that the file already exists (DISP=MOD or DISP=SHR or DISP=OLD) then that data set must exist when the job goes through converter/interpreter processing or you will get a JCL error. The SELECT OPTIONAL clause in COBOL is not designed to prevent JCL errors, it is designed to allow a program to run to normal completion whether or not a given DD statement is present in the JCL.

Re: COBOL SELECT CLUASE

PostPosted: Tue Feb 26, 2013 9:36 pm
by rosh8129
Raj,
It seems somthing your JCl issue. I am hoping you are not confusing in DD-name in Select clause & JCL DD-name.
but as per your previous concern, i think you can try to omit this File-1 DD-name from the JCL it shouldn't be abend now.

Re: COBOL SELECT CLUASE

PostPosted: Wed Feb 27, 2013 6:07 am
by NicC
Perhaps the dataset (not FILE) that you specify in the JCL has different attributes to those that you specified in your program. You have not posted what the OPEN error was - that would be a bit of useful information to help determine the reason behind the error.

Re: COBOL SELECT CLUASE

PostPosted: Thu Feb 28, 2013 1:15 pm
by rajufis_01
Nic,
i am getting 05 return code,when i am trying to run my Job,
i read in one document it says
"SELECT Statement- OPTIONAL Clause
This can be coded only for input files. If OPTIONAL is not coded, then the input file is expected to present in JCL. If not, an execution error will occur.If OPTIONAL is coded, then if the file is not mapped in JCL, it is considered as empty file and the first read results end of file.The file can also be dynamically allocated instead of static allocation in JCL."

so i have given in my cobol program as SELECT OPTIONAL FILE-A ASSGIN TO DD01
according to the above statement(that i read from the document) In the JCL,i did not given DD01. then it throws return code 05.