Alternate Record Key



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

Alternate Record Key

Postby sambit_92 » Wed Sep 24, 2014 10:37 am

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.
sambit_92
 
Posts: 9
Joined: Mon Sep 15, 2014 12:40 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Alternate Record Key

Postby BillyBoyo » Wed Sep 24, 2014 11:16 am

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.

These users thanked the author BillyBoyo for the post:
sambit_92 (Fri Sep 26, 2014 11:19 am)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Alternate Record Key

Postby Terry Heinze » Wed Sep 24, 2014 7:11 pm

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
.... Terry

These users thanked the author Terry Heinze for the post:
sambit_92 (Fri Sep 26, 2014 11:19 am)
Terry Heinze
 
Posts: 239
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 12 times
Been thanked: 11 times

Re: Alternate Record Key

Postby sambit_92 » Wed Sep 24, 2014 7:31 pm

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. :)
sambit_92
 
Posts: 9
Joined: Mon Sep 15, 2014 12:40 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Alternate Record Key

Postby BillyBoyo » Wed Sep 24, 2014 8:26 pm

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?

These users thanked the author BillyBoyo for the post:
sambit_92 (Fri Sep 26, 2014 11:19 am)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Alternate Record Key

Postby Terry Heinze » Wed Sep 24, 2014 11:18 pm

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.
.... Terry

These users thanked the author Terry Heinze for the post:
sambit_92 (Fri Sep 26, 2014 11:19 am)
Terry Heinze
 
Posts: 239
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 12 times
Been thanked: 11 times

Re: Alternate Record Key

Postby sambit_92 » Fri Sep 26, 2014 11:22 am

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.
sambit_92
 
Posts: 9
Joined: Mon Sep 15, 2014 12:40 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Alternate Record Key

Postby sambit_92 » Fri Oct 31, 2014 11:13 am

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
sambit_92
 
Posts: 9
Joined: Mon Sep 15, 2014 12:40 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Alternate Record Key

Postby sambit_92 » Fri Oct 31, 2014 11:46 am

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
sambit_92
 
Posts: 9
Joined: Mon Sep 15, 2014 12:40 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Alternate Record Key

Postby Robert Sample » Fri Oct 31, 2014 6:53 pm

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

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post