View previous topic :: View next topic
|
Author |
Message |
KAUSHIK RANGARAJAN
New User
Joined: 19 Jul 2005 Posts: 22 Location: chennai
|
|
|
|
HI,
Hi,
I have the following two questions:
1.How to define the record size in alternate cluster definition, should it be the same as in the base cluster.(Is there any other criteria)
2.Is it possible to read a vsam file using alternate index. if so plz tell me how to declare alternate key in file control area and use it in the procedure division.
waiting for Ur replies........
Thank u.
|
|
Back to top |
|
|
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi kaushik
1) as per my concern it is same as in base cluster
if any wrong correct me
2) ALTERNATE KEY is keyfeild
that cane use as likeas key feild but in alternate key duplicate records can be possible
thanks
thanooz |
|
Back to top |
|
|
KAUSHIK RANGARAJAN
New User
Joined: 19 Jul 2005 Posts: 22 Location: chennai
|
|
|
|
Hi thanooz,
Can u give me some sample Cobol code. Ur first answer cleared my doubt but my second question remains unanswered.
Bye,
|
|
Back to top |
|
|
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi
select file1 assign to dd1
organiztion is indexed
access is dynamic
record key is key field
alternate key is alternate key field |
|
Back to top |
|
|
KAUSHIK RANGARAJAN
New User
Joined: 19 Jul 2005 Posts: 22 Location: chennai
|
|
|
|
Hi,
What should be assigned to dd1 in jcl:
Path name or base cluster name or the alternate index cluster name.
Bye.
|
|
Back to top |
|
|
Mutthu_talluri
New User
Joined: 16 Jun 2005 Posts: 9
|
|
|
|
Hi,
Its Path name....
//DDname DD DSN=Pathname,disp=()
Automatically path will open Base cluster and Alternate index cluster..
Corrections are welocome.. |
|
Back to top |
|
|
Rameshs
New User
Joined: 15 Jun 2005 Posts: 53 Location: India, Chennai
|
|
|
|
dd1 is the name of Data Definition(DD name) in JCL which is the connector name
DD1 - INDEX FILE CONNECTOR
DD2 - PATH
EMP IS INDEX FILE (VSAM DATASET)
AIPATH IS ALTERNATH INDEX PATH
example:
In jcl
DD1 DD DSN=TSORSAM.TRG.EMP,DISP=SHR
DD2 DD DSN=TSORSAM.TRG.AIPATH,DISP=SHR |
|
Back to top |
|
|
KAUSHIK RANGARAJAN
New User
Joined: 19 Jul 2005 Posts: 22 Location: chennai
|
|
|
|
Hi,
I have a problem in opening the file when using the path name.
But I am able to read without any error while reading from the base cluster without using alternate key.
Is there any particular syntax for opening the file and reading it while using alternate key.
Can U send me the syntax for opening and reading. I am using the following to open and read:
OPEN INPUT INP-FILE.
IF WS-FSTATUS = "00"
DISPLAY "OPENED"
DISPLAY WS-FSTATUS
PERFORM COMPUTE-PARA
ELSE
DISPLAY "ERROR"
DISPLAY WS-FSTATUS
STOP RUN.
COMPUTE-PARA.
MOVE "RAM" TO STUD-NAME. (STUD-NAME IS THE ALTERNATE KEY)
READ INP-FILE
END-READ.
MOVE STUDENT-REC TO WS-INP-REC.
DISPLAY WS-INP-REC.
.
.
.
.
.
.
.
.
Bye |
|
Back to top |
|
|
gsnvsr
New User
Joined: 06 Jul 2005 Posts: 40
|
|
|
|
When you want to read a VSAM - KSDS with a Key, use 'KEY IS' clause along with the Read statement as in :
READ <File-name> KEY IS <Primary/Alternate key>
Hope this helps!
Best regards!
Prasad |
|
Back to top |
|
|
Rameshs
New User
Joined: 15 Jun 2005 Posts: 53 Location: India, Chennai
|
|
|
|
Note
===
dd1 is DD name for ksds
Don't use path dd name in cobol pgm
CODE
====
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM3.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-FILE ASSIGN TO DD1
ACCESS MODE IS DYNAMIC
ORGANIZATION IS INDEXED
RECORD KEY IS STU-ID
ALTERNATE RECORD KEY IS NAME.
DATA DIVISION.
FILE SECTION.
FD IN-FILE.
01 S-RECORD.
02 STU-ID PIC 9(5).
02 NAME PIC X(10).
02 AGE PIC 9(2).
02 FILLER PIC X(63).
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
MAIN-PARA.
OPEN INPUT IN-FILE.
MOVE 'RAMESH' TO NAME.
PERFORM READ-PARA.
CLOSE IN-FILE.
STOP RUN.
READ-PARA.
READ IN-FILE RECORD KEY IS NAME
INVALID KEY GO TO ERROR-PARA.
DISPLAY STU-ID.
DISPLAY NAME.
DISPLAY AGE.
ERROR-PARA.
DISPLAY 'ERROR SEARCHING KEY ITEM'.
CLOSE IN-FILE.
STOP RUN.
This would give you a clear picture
|
|
Back to top |
|
|
KAUSHIK RANGARAJAN
New User
Joined: 19 Jul 2005 Posts: 22 Location: chennai
|
|
|
|
Hi Prasad,
Sorry I did not mention that but I used that approach to. But I still find ERROR in opening the File.
Here is the Code.
IDENTIFICATION DIVISION.
PROGRAM-ID. FILEREAD.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INP-FILE ASSIGN TO DD1
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS STUD-ID
ALTERNATE KEY IS STUD-NAME
FILE STATUS IS WS-FSTATUS.
DATA DIVISION.
FILE SECTION.
FD INP-FILE.
01 STUDENT-REC.
05 STUD-ID PIC X(4).
05 STUD-NAME PIC X(10).
05 STUD-DEPT PIC A(10).
05 FILLER PIC X(56).
WORKING-STORAGE SECTION.
01 WS-FSTATUS PIC X(2).
01 WS-INP-REC.
05 WS-STUD-ID PIC X(4).
05 WS-STUD-NAME PIC X(10).
05 WS-STUD-DEPT PIC A(10).
05 WS-FILLER PIC X(56).
01 WS-SSTUD-NAME PIC X(7).
PROCEDURE DIVISION.
OPEN-PARA.
OPEN INPUT INP-FILE.
IF WS-FSTATUS = "00"
DISPLAY "OPENED"
DISPLAY WS-FSTATUS
PERFORM COMPUTE-PARA
ELSE
DISPLAY "ERROR"
DISPLAY WS-FSTATUS
STOP RUN.
COMPUTE-PARA.
MOVE "SESHATHRI" TO WS-SSTUD-NAME.
MOVE WS-SSTUD-NAME TO STUD-NAME.
READ INP-FILE KEY IS STUD-NAME
END-READ.
MOVE STUDENT-REC TO WS-INP-REC.
DISPLAY-PARA.
DISPLAY WS-STUD-NAME.
DISPLAY WS-STUD-DEPT.
CLOSE-PARA.
CLOSE INP-FILE.
STOP RUN.
BYE. |
|
Back to top |
|
|
Rameshs
New User
Joined: 15 Jun 2005 Posts: 53 Location: India, Chennai
|
|
|
|
CAN YOU TELL ME THE ERROR clearly ? [error msg]
you also didn't specify where the control should go after performing compute-para. |
|
Back to top |
|
|
KAUSHIK RANGARAJAN
New User
Joined: 19 Jul 2005 Posts: 22 Location: chennai
|
|
|
|
Hi,
The problem is not in the COMPUTE-PARA. Cobol follows a top down approach while running , in this case after the IF CONDITION RETURNS TRUE the control goes to COMPUTE-PARA. When the execution of that PARA is finished the Control is transfered next to the DISPLAY-PARA.
But the problem is not in that, it's in the FILE OPENING . I get a ERROR of 35 in FILE STATUS [WS-FSTATUS ].
Any Clue????
BYE . |
|
Back to top |
|
|
Rameshs
New User
Joined: 15 Jun 2005 Posts: 53 Location: India, Chennai
|
|
|
|
Result
=====
ATEEMPTING TO OPEN AN EMPTY FILE IN INPUT OR I/O MODE. DD NAME IS MISSING OR WRONGLY GIVEN.
Explanation
-------------
An OPEN statement with the INPUT, I-O, or EXTEND phrase was attempted on a non-optional file that was not present. |
|
Back to top |
|
|
KAUSHIK RANGARAJAN
New User
Joined: 19 Jul 2005 Posts: 22 Location: chennai
|
|
|
|
Hi Rameshs,
I got Ur point regarding return of Control after Compute-para and Corrected It. Thanks.
Thanks for the Error Description, but I know this detail already. The problem is that the File exists, I can read from the Base Cluster when I am not using Alternate index approach, that is I use Primary Key. But as soon as change the Key to a Alternate key I get error 35. DDNAME is correct and everything else looks fine.
Help ???
Bye. |
|
Back to top |
|
|
Rameshs
New User
Joined: 15 Jun 2005 Posts: 53 Location: India, Chennai
|
|
|
|
Did you follow these steps while creating Alternate index
1. create Alternate index file
2. Populate the index (build index)
3. create path
4. In Runjcl specify dd for path |
|
Back to top |
|
|
alamelu
New User
Joined: 18 Jul 2005 Posts: 15
|
|
|
|
Hi ,
The Open Error may be due the Incorrect Alternate key position when u defined the Alternate Cluster .
For Ex: when the Key Postion is from 11 column to 10 Bytes , then while defining it , should be Keys(10 10) not (10 11) .
Thanks,
Alamelu |
|
Back to top |
|
|
gsnvsr
New User
Joined: 06 Jul 2005 Posts: 40
|
|
|
|
I believe the alternate index has not been created properly then. Pls check.
Best regards,
Prasad |
|
Back to top |
|
|
shobam
New User
Joined: 18 Jul 2005 Posts: 34 Location: CN
|
|
|
|
When the PATH name is not mentioned correctly or not specified in the JCL we will get this error. Please check the PATH name in the JCL or try creating it again.
Thanks@Regards
Shobam |
|
Back to top |
|
|
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi
in dd1 you give your actuval vsam ksds
dd11 you give ksds path file
thanooz |
|
Back to top |
|
|
KAUSHIK RANGARAJAN
New User
Joined: 19 Jul 2005 Posts: 22 Location: chennai
|
|
|
|
Hi,
Thanks All. I think the problem is in the Alternate key position. I will see this.
Thanks a LOT.
Bye. |
|
Back to top |
|
|
KAUSHIK RANGARAJAN
New User
Joined: 19 Jul 2005 Posts: 22 Location: chennai
|
|
|
|
Hi,
Thanks thanooz, You are RIGHT about the problem. The problem has been solved. Thanks everyone.
Bye. |
|
Back to top |
|
|
|