IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

File access using Alternate Index


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mosinjamadar

New User


Joined: 26 Sep 2007
Posts: 42
Location: pune

PostPosted: Wed Dec 23, 2009 5:14 pm
Reply with quote

Hi All

I want to read KSDS file using alternate key which I have defined on KSDS but I am not able to access using alternate kye its giving file status 23

Kindly let me know what mistake i am doing
following is my code
Code:

 ID DIVISION.                                   
 PROGRAM-ID. KSDAIX.                             
 ENVIRONMENT DIVISION.                           
 INPUT-OUTPUT SECTION.                           
 FILE-CONTROL.                                   
       SELECT EMPDTA   ASSIGN TO DDIDX           
       ORGANIZATION IS INDEXED                   
       ACCESS MODE  IS RANDOM                   
       RECORD KEY IS EMP-NUM                     
       ALTERNATE KEY IS EMP-DEPT  WITH DUPLICATES
       FILE STATUS  IS WF-KSDS-STATUS.           
                                                 
 DATA DIVISION.                                 
 FILE SECTION.                                   
 FD EMPDTA.                                     
 01 EMPDTA-REC.                                 
      03 EM-SR       PIC 9(1).                   
          03 EMP-NUM     PIC 9(5).               
          03 EMP-NAME    PIC X(10).             
          03 EMP-DEPT    PIC X(10).             
          03 FILLER      PIC X(54).             
                                                 
     WORKING-STORAGE SECTION.                   
     01 WS-DATA.                                 
         03 WF-KSDS-STATUS    PIC X(2).         
         03 WS-CNT            PIC 9(2).         
         03 WF-EOF-FILE       PIC X(1).         
            88 WF-EOF         VALUE 'Y'.         
            88 WF-NOT-EOF     VALUE 'N'.         
                                                 
     PROCEDURE DIVISION.                         
     A00-MAIN SECTION.                           
          PERFORM A010-INITIAL                   
          PERFORM B020-PROCESS                   
 A00-MAIN-EXIT SECTION.                         
      EXIT.                                     
                                                 
 A010-INITIAL SECTION.                           
      OPEN INPUT EMPDTA                         
                                                 
      IF WF-KSDS-STATUS > '00'                   
       DISPLAY 'ERROR IN OPENING' WF-KSDS-STATUS
      END-IF                                     
                                                 
      move  'globalbusn'  to EMP-DEPT           
      .                                         
 A010-INITIAL-EXIT SECTION.                     
      EXIT.                                     
                                                 
 B020-PROCESS SECTION.                           
                                                                         
             PERFORM C010-READ-KSDS UNTIL WF-KSDS-STATUS = '10'         
             STOP RUN                                                   
             .                                                           
        B020-PROCESS-EXIT SECTION.                                       
             EXIT.                                                       
                                                                         
        C010-READ-KSDS SECTION.                                         
              READ EMPDTA                                               
                INVALID KEY                                             
                DISPLAY 'INVALID KEY' WF-KSDS-STATUS                     
                MOVE '10'      TO WF-KSDS-STATUS                         
              .                                                         
        C010-READ-KSDS-EXIT SECTION.                                     
             EXIT.                                                       


following is base cluster content
1 23456 mosinjamadbankandcar
2 23457 mosinjamadbankandcar
2 23458 1234611111bankandcar
2 23459 abcd123456globalbusn
2 23460 mosinjamadglobalbusn
2 23461 mosinjamadinsurance

following is alternate index file content

bankandcar 234562345723458
globalbusn 2345923460
insurance 23461
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 23, 2009 6:08 pm
Reply with quote

Code:
              READ EMPDTA                                               
                KEY IS EMP-DEPT
                INVALID KEY                                             
The default is to read by the primary key, which you didn't initialize.
Back to top
View user's profile Send private message
mosinjamadar

New User


Joined: 26 Sep 2007
Posts: 42
Location: pune

PostPosted: Wed Dec 30, 2009 2:30 pm
Reply with quote

Hi

The solution you have mentioed is not working please specify if you have any other solution

Regards,
Mosin
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 30, 2009 4:33 pm
Reply with quote

Saying something is not working provides us nothing to help you with. What is the file status code? Are there any other messages? What does your JCL look like that is executing KSDAIX?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Dec 30, 2009 5:05 pm
Reply with quote

Quote:
solution you have mentioed is not working

TS does not bother to insure his posts are accurate.
more than likely the TS did not bother to fully implement Robert's suggestion.

But, the JCL for the STEP is also necessary, especially since he probably codes as sloppily and haphazard as he posts.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top