Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
File access using Alternate Index

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: File access using Alternate Index
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: 8199
Location: East Dubuque, Illinois, USA

PostPosted: Wed Dec 23, 2009 6:08 pm    Post subject:
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    Post subject: Reply to: File access using Alternate Index
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: 8199
Location: East Dubuque, Illinois, USA

PostPosted: Wed Dec 30, 2009 4:33 pm    Post subject:
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: 6970
Location: porcelain throne

PostPosted: Wed Dec 30, 2009 5:05 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts File Tailoring -- Temporary dataset i... samzee71 CLIST & REXX 3 Fri Dec 01, 2017 3:12 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
No new posts Moving a PS file as body of a mail! Vignesh Sid JCL & VSAM 4 Tue Nov 21, 2017 9:23 pm
No new posts unable to set RC = 4 when empty file migusd SYNCSORT 1 Tue Nov 21, 2017 1:21 am
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us