All you need to do is open a second occurrence of your file in the Cobol
program.  Copy the select and FD for the file - give them a different
name than the original occurrence then do an open for the new file name
and perform your indexed reads on the other file.  This gives you a
second logical occurrence of the same file in your program and the
pointers on the original occurrence are not changed. For example:
IDENTIFICATION DIVISION.    
PROGRAM-ID.  TWOFILES.      
ENVIRONMENT DIVISION.       
CONFIGURATION SECTION.      
SOURCE-COMPUTER.  IBM-AS400.
OBJECT-COMPUTER.  IBM-AS400.
INPUT-OUTPUT SECTION.                                   
FILE-CONTROL.                                           
    SELECT CLAIM01 ASSIGN TO DATABASE-CLAIML01         
           ORGANIZATION IS INDEXED                      
           ACCESS MODE  IS DYNAMIC                      
           FILE STATUS  IS CLAIML01-ST                  
           RECORD KEY   IS EXTERNALLY-DESCRIBED-KEY.    
    SELECT CLAIMUP ASSIGN TO DATABASE-CLAIML01         
           ORGANIZATION IS INDEXED                      
           ACCESS MODE  IS DYNAMIC                      
           FILE STATUS  IS CLAIMLUP-ST                  
           RECORD KEY   IS EXTERNALLY-DESCRIBED-KEY.     
DATA DIVISION.                                      
FILE SECTION.                                       
FD  CLAIML01.                                       
01  CLAIML01-REC.                                   
    COPY DD-ALL-FORMATS OF CLAIML01.                
FD  CLAIMLUP.                                       
01  CLAIMLUP-REC.                                   
    COPY DD-ALL-FORMATS OF CLAIML01.         
WORKING-STORAGE SECTION.                    
01  STATUS-CODES.                           
    05 CLAIML01-ST              PIC XX.    
    05 CLAIMLUP-ST              PIC XX.    
01  SWITCHES.                               
    05  SW-EOF    PIC X(01)  VALUE "N".     
        88  END-OF-FILE     VALUE "Y".      
    05  SW-FOUND    PIC X(1) VALUE "N".     
PROCEDURE DIVISION.         
0000-MAIN.                                                     
    PERFORM 1000-OPEN-FILES THRU 1000-EXIT.                    
    PERFORM 2000-READ-CREATE THRU 2000-EXIT UNTIL END-OF-FILE. 
    PERFORM 9000-CLOSE-FILE THRU 9000-EXIT.                    
0000-EXIT.                                                     
    GOBACK.                                                             
1000-OPEN-FILES.    
	OPEN 	I-O   CLAIML01     
      OPEN 	I-O   CLAIMLUP
1000-EXIT.
    EXIT.
2000-READ-CREATE.                                              
    READ CLAIML01 NEXT RECORD AT END                         
         MOVE "Y" TO SW-EOF                                    
         GO TO 2000-EXIT.                                      
    PERFORM 2400-READ-MPINS THRU 2400-EXIT.                    
                                                               
2000-EXIT.    
    EXIT.                                                 
2400-READ-MPINS.                                 
    MOVE "Y" TO SW-FOUND.                        
    MOVE CORR claimrec of CLAIML01                 
    TO        claimrec of CLAIMLUP.                
    READ CLAIMLUP 
	INVALID KEY                         
         MOVE "N" TO SW-FOUND.	                                    
2400-EXIT.   
    EXIT.                               
9000-CLOSE-FILE.                                     
    CLOSE  CLAIML01 , CLAIMUP.                      
9000-EXIT.                                           
    EXIT.                                            
John Arnold
(301) 354-2939
 
-----Original Message-----
From: cobol400-l-bounces@xxxxxxxxxxxx
[mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of Nancy Barney
Sent: Wednesday, June 04, 2008 10:32 AM
To: cobol400-l@xxxxxxxxxxxx
Subject: [COBOL400-L] How to do sequential and random reads concurrently
I have an indexed file that I am reading sequentially using a repeating,
non-unique alternate key, using start and read next. Access is dynamic.
 
As I am reading through this file sequentially, I also have to randomly
retrieve records from the same file using the primary key. (For each
record that I retrieve sequentially, I have to get another record
randomly.)
 
I can't do a start after the random read to reset the record pointers
for the sequential read, because I am using a non-unique alternate key
to start the sequential read. 
 
How do I do this without messing up the record pointers? When I tested
this, I don't get all the records I should get from the sequential read,
as if the random read 'resets' the record pointers.
 
How do I get around this? Thanks in advance for your help!
 
Nancy Barney
Dakota Drug, Inc
 
 
 
--
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing
list To post a message email: COBOL400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: 
http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at 
http://archive.midrange.com/cobol400-l.
As an Amazon Associate we earn from qualifying purchases.