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

Using Alternate Index in COBOL program


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

New User


Joined: 29 Jul 2009
Posts: 7
Location: Kansas

PostPosted: Wed Sep 30, 2009 1:50 am
Reply with quote

hi everyone,

i have the following:
Code:

SELECT INPUT-FILE           ASSIGN TO  UT-S-INFILE
SELECT REPORT-FILE        ASSIGN TO  UT-S-RPT. 
SELECT FVVE-FILE            ASSIGN FVVE                         
                                      ORGANIZATION INDEXED                 
                                     ACCESS DYNAMIC                       
                                     RECORD KEY FVVE-KEY                 
                   ALTERNATE RECORD KEY IO-NAME WITH DUPLICATES
                                    STATUS FVVE-STATUS.                 

FD  FVVE-FILE                               
    LABEL RECORDS ARE STANDARD                 
    DATA RECORD IS FVVE-RECORD.               
01  FVVE-RECORD.                               
    05  FVVE-KEY.                             
        10  IO-NUMBER             PIC X(9).   
        10  IO-FILLER             PIC X(1).   
        10  IO-SFX                PIC X(2).   
    05  IO-NAME                   PIC X(40).   
    05  EXP-NAME                  PIC X(40). 

FD  REPORT-FILE                                         
    LABEL RECORDS ARE STANDARD                       
    BLOCK CONTAINS 0 RECORDS.                       
01  RPT-REC                           PIC X(133).   
                                                     
FD  INPUT-FILE                                   
    LABEL RECORDS ARE STANDARD                     
    BLOCK CONTAINS 0 RECORDS.                     
01  INPUT-REC                        PIC X(520).

WORKING-STORAGE SECTION.

01  WS-INPUT-REC.                             
    05  SUPP-NUM-1-9                  PIC X(9). 
    05  FILLER                        PIC X(22).
    05  SUPP-NAME                     PIC X(40).
    05  FILLER                        PIC X(25).
    05  ORIG-SUPP-NUM                 PIC X(31).
    05  ORIG-SUPP-NAME                PIC X(65).
    05  ADDRESS1                      PIC X(65).
    05  ADDRESS2                      PIC X(65).
    05  ADDRESS3                      PIC X(65).
    05  CITY                          PIC X(81).
    05  STATE                         PIC X(6). 
    05  FED-ID-NUM                    PIC X(11).
    05  CONFIDENCE                    PIC X(12).
    05  SUPP-CODE                     PIC X(8). 
    05  FILLER                        PIC X(15).


01  DETAIL-LINE.                                               
    05  PM-SUPP-OUT                    PIC X(15) VALUE SPACES.
    05  PM-NAME-OUT                    PIC X(45) VALUE SPACES.
    05  VE-NUMBER-OUT                  PIC X(10) VALUE SPACES.
    05  VE-SFX-OUT                     PIC X(2) VALUE SPACES. 
    05  VE-NAME-OUT                    PIC X(40) VALUE SPACES.

01  WS-MISC.                                             
    05  WS-EOF-PM                      PIC X(1) VALUE 'N'.
    05  FVVE-STATUS                    PIC X(2).         


PROCEDURE DIVISION.         
                             
100-INIT.                   
    OPEN INPUT  INPUT-FILE
                       FVVE-FILE.
    OPEN OUTPUT REPORT-FILE.     

READ INPUT-FILE                   
    AT END MOVE 'Y' TO WS-EOF-PM.   
 
MOVE INPUT-REC TO WS-INPUT-REC.

MOVE SPACES TO FVVE-RECORD.         
MOVE SUPP-NAME TO IO-NAME.         
START FVVE-FILE KEY EQUAL TO IO-NAME.

IF FVVE-STATUS = '00' OR '97' OR '02'
   MOVE ORIG-SUPP-NUM TO PM-SUPP-OUT 
   MOVE ORIG-SUPP-NAME TO PM-NAME-OUT
   MOVE IO-NAME TO VE-NAME-OUT
   MOVE IO-NUMBER TO VE-NUMBER-OUT
   MOVE IO-SFX TO VE-SFX-OUT
   MOVE 'MATCH ON NAME' TO MESSAGE-OUT
   WRITE REPORT-REC FROM DETAIL-LINE.



everything is showing up on the report except IO-NUMBER and IO-SFX.

do i need to do a READ or READ NEXT stmt after the START? or is there something else missing?

thanks in advance.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Sep 30, 2009 5:28 am
Reply with quote

The answer is in the Language Reference Manual (START statement).
Back to top
View user's profile Send private message
gretchen

New User


Joined: 29 Jul 2009
Posts: 7
Location: Kansas

PostPosted: Wed Sep 30, 2009 7:31 pm
Reply with quote

actually, by virtue of trial and error, i ended up using:

Code:

READ FVVE-FILE KEY IS IO-NAME


...when i want to use the alternate index, and just a READ w/o the KEY IS when i want to use the primary key.

why isn't it mentioned anywhere that you can do it this way with READ and not just START? oh well.

thanks for the advice!
Back to top
View user's profile Send private message
gretchen

New User


Joined: 29 Jul 2009
Posts: 7
Location: Kansas

PostPosted: Wed Sep 30, 2009 7:32 pm
Reply with quote

p.s. to clarify - i took the START out and am using the READ instead.
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top