COBOL SELECT CLUASE



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

COBOL SELECT CLUASE

Postby rajufis_01 » Thu Feb 21, 2013 2:48 pm

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
rajufis_01
 
Posts: 17
Joined: Thu Nov 24, 2011 4:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL SELECT CLUASE

 

Re: COBOL SELECT CLUASE

Postby BillyBoyo » Thu Feb 21, 2013 3:10 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: COBOL SELECT CLUASE

Postby dick scherrer » Fri Feb 22, 2013 11:48 am

Hello,

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

Possibly i misunderstand.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: COBOL SELECT CLUASE

Postby tonysam » Fri Feb 22, 2013 8:50 pm

How about calling the program from a clist or rexx exec that first issues an allocation statement?
tonysam
 
Posts: 3
Joined: Fri Feb 22, 2013 8:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL SELECT CLUASE

Postby rosh8129 » Tue Feb 26, 2013 12:05 pm

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
rosh8129
 
Posts: 2
Joined: Mon Feb 25, 2013 10:47 am
Has thanked: 1 time
Been thanked: 0 time

Re: COBOL SELECT CLUASE

Postby rajufis_01 » Tue Feb 26, 2013 9:04 pm

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
rajufis_01
 
Posts: 17
Joined: Thu Nov 24, 2011 4:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL SELECT CLUASE

Postby Robert Sample » Tue Feb 26, 2013 9:14 pm

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.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: COBOL SELECT CLUASE

Postby rosh8129 » Tue Feb 26, 2013 9:36 pm

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.
rosh8129
 
Posts: 2
Joined: Mon Feb 25, 2013 10:47 am
Has thanked: 1 time
Been thanked: 0 time

Re: COBOL SELECT CLUASE

Postby NicC » Wed Feb 27, 2013 6:07 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: COBOL SELECT CLUASE

Postby rajufis_01 » Thu Feb 28, 2013 1:15 pm

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.
rajufis_01
 
Posts: 17
Joined: Thu Nov 24, 2011 4:54 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post