Page 1 of 2

Alternate Record Key

PostPosted: Wed Sep 24, 2014 10:37 am
by sambit_92
Hi All,

I am failry new to this amazing language. Recently I was trying for a program, but I got some unexpected outputs, or at least unexpected to me.
My Requirements are :

1. I have one VSAM file(say, ALTKSD), it has one primary key. I have created another AIX file(say, ALTKSD1), which has an alternate index for the base cluster ALTKSD.
2. I have also build a path between them.
3. Cust-Id is primary index and telephone-no is alternate index
4. As per my cobol program, I am reading a 3rd Input(Sequential) file, which has only one record i.e., telephone-no(Alternate Index) and matching these with my VSAM file, what ever matching records I would get based upon the telephone-no I'll write them into my Report-file.

But, I am not able to open the VSAM file itself, the error code is 35
FILE-CONTROL.
SELECT FILEIN1       ASSIGN  TO IN1
ORAGANIZATION        IS  INDEXED
ACCESS               IS  DYNAMIC
RECORD KEY           IS  USER-ID       
ALTERNATE RECORD KEY IS  TELEPHONE-NO
FILE STATUS  IS WS-STAT0INPUT1


OPEN INPUT FILEIN1

In the JCL, in the DD name I am giving path of the VSAM file(ALTKSD)

Am I going wrong anywhere, any help would be heartly appreciated.

Re: Alternate Record Key

PostPosted: Wed Sep 24, 2014 11:16 am
by BillyBoyo
You need two DD statements, the cluster and the path. Have a look at the Enterprise COBOL Programming Guide which is always useful when you have a task you have not encountered before.

See if you have a message in file three of the spool files for your job.

Re: Alternate Record Key

PostPosted: Wed Sep 24, 2014 7:11 pm
by Terry Heinze
See the chapter on Processing VSAM files:

COBOL provides these ways for you to intercept and handle certain VSAM input
and output errors:
v End-of-file phrase (AT END)
v EXCEPTION/ERROR declarative
v FILE STATUS clause (file status key and VSAM status code)
v INVALID KEY phrase

Re: Alternate Record Key

PostPosted: Wed Sep 24, 2014 7:31 pm
by sambit_92
Hi,

Thanks BillyBoyo & Terry Heinze for your suggestions, I'll definately give that a try.

But the thing that I completely fail to understand is the moemnt I remove the Alternate record Key the program is running fine, but with Alternate record Key, It gives Error 35, i.e, file not found

I have already tried doing what BillyBoyo suggested. In the JCl I gave 3 DD Names, 1 for VSAM file, 1 for Sequential Input file that I am using, and the 3rd for the path that i have build between my VSAM and AIX file.Does the order in which I write them matters?
Well I did used Displays to check the flow, so it is getting into Open , and while opening the VSAM file, it gives ERROR code 35.

Again,thanks a lot for your quick and valuable suggestions. :)

Re: Alternate Record Key

PostPosted: Wed Sep 24, 2014 8:26 pm
by BillyBoyo
The order does not matter, although for anyone looking at the JCL it is good that they always appear together, but what DDnames did you give for the path and the cluster?

Re: Alternate Record Key

PostPosted: Wed Sep 24, 2014 11:18 pm
by Terry Heinze
And take advantage of using the VSAM status code in addition to the file status key. File Status 35 is pretty plain in it's meaning. See Language Reference for info about VSAM function code and feedback code.

Re: Alternate Record Key

PostPosted: Fri Sep 26, 2014 11:22 am
by sambit_92
Thanks a lot Guys.

Though I haven't got the desired output yet but I did found some useful references thanks to you guys.
I'll go through those and try making changes in my codes, and will get back to this.

Regards Sambit.

Re: Alternate Record Key

PostPosted: Fri Oct 31, 2014 11:13 am
by sambit_92
Hi All,

As advised to go for VSAM status codes, I am getting them as all 0's. The problem still exit. I have used the JCL to create all the files and cluster. But even upon using the 2 DD statements, I get FIle open error. Its not able to open the VSAM File itself, which happens to be the first READ of the program.


Any insight to this will be heartily appreciated

Thaks & Regards
Sambit

Re: Alternate Record Key

PostPosted: Fri Oct 31, 2014 11:46 am
by sambit_92
I have given the DD Names as below.
//IN1       DD DSN=SAMPLE.ALTKSD,DISP=SHR
//IN2       DD DSN=SAMPLE.SEQINPUT,DISP=SHR     
//ALTKSD1   DD DSN=SAMPLE.ALTKSD.PATH,DISP=SHR

//OUT1      DD DSN=SAMPLE.OUTPUT,DISP=SHR


Thanks,
Sambit

Re: Alternate Record Key

PostPosted: Fri Oct 31, 2014 6:53 pm
by Robert Sample
Try this:
//IN1       DD DSN=SAMPLE.ALTKSD,DISP=SHR
//IN2       DD DSN=SAMPLE.SEQINPUT,DISP=SHR     
//IN11      DD DSN=SAMPLE.ALTKSD.PATH,DISP=SHR
You cannot assign an arbitrary name to the alternate key DD statement -- you must use what the COBOL manual tells you to use.