Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
VSE COBOL - File Status 46 when reading alternate index

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
dennis larson

New User


Joined: 03 Jan 2020
Posts: 4
Location: usa

PostPosted: Fri Jan 03, 2020 11:46 pm    Post subject: VSE COBOL - File Status 46 when reading alternate index
Reply with quote

I have found several posts on status 46 but no resolutions. We are a VSE shop using VSAM. The problem occurs both while CICS is running and when it is not. The programs that abort with status code 46 have all been running for several years without incident. These are read only report programs. We read a KSDS file using an alternate key. When the program gets to a specific record, it always gets this error. the key is 'member-id, work-date'. it aborts on a specific ID with a specific date. I know it is not end of file because the mainfile is by deposit date and there are lots of IDs that are higher than the problem 1 and there are lots of records with deposit dates after this record. Also for the 2 reports that read the file by 4th key, neither even want the record(s) causing the problem. When I try to look at the problem record in CICS (we have a 3rd party tool that we use to access CICS another on-line tool that also uses cics to allow you to browse edit VSAM files. I cannot see the record when using the 3rd part CICS access - it just says 'no data found for key....when I use the other app to look at the records using the primary key, the app stops at the problem record and does not advance to next record.

here is the file:
Code:
SELECT DET01-FILE   ASSIGN TO SYS022-DA-3340-DETK4P       
                              ORGANIZATION IS INDEXED     
                              ACCESS MODE IS SEQUENTIAL   
                              RECORD KEY IS DET-KEY       
                              FILE STATUS IS DET-STATUS. 
FD  DET01-FILE                                     
    RECORD CONTAINS 450 CHARACTERS                 
    LABEL RECORDS ARE STANDARD                     
    DATA RECORD IS DET-REC.                         
                                                   
01  DET-REC.                                       
    03  FILLER                      PIC X(300).     
    03  DET-KEY                     PIC X(13).     
    03  FILLER                      PIC X(137).     

PERFORM B2000-MAINLINE THRU B2000-READ-NEXT             
                            UNTIL DET01-KEY = HIGH-VALUES.   

R1000-READ-DET.                                           
                                                         
    READ DET01-FILE INTO DET01-RECORD                     
      AT END                                             
        MOVE HIGH-VALUES TO DET01-KEY.                   
                                                         
    IF DET01-KEY NOT = HIGH-VALUES   (I added this when trying to debug)                     
    IF DET-STATUS = '00' OR '02'                         
        NEXT SENTENCE                                     
       ELSE                                                 
        DISPLAY 'PROBLEM DET READ - STATUS =' DET-STATUS 
            '**KEY=' DET01-KEY '*****'                   
        CALL 'ABORT'.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


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

PostPosted: Sat Jan 04, 2020 12:47 am    Post subject:
Reply with quote

Quote:
We read a KSDS file using an alternate key.
Yeah, right -- if so, then where is the ALTERNATE RECORD KEY clause in the SELECT?
Quote:
I know it is not end of file because the mainfile is by deposit date and there are lots of IDs that are higher than the problem 1 and there are lots of records with deposit dates after this record.
IF you are reading by alternate index, the base cluster (not "mainfile") sequence has NOTHING to do with the reading of the alternate index -- you could get end of file on the alternate key even though the base cluster is not at end of file.

What is the definition of the base cluster and the alternate index? There may other information needed, but we'll start with the basics since your post is contradicting itself in multiple spots.
Back to top
View user's profile Send private message
dennis larson

New User


Joined: 03 Jan 2020
Posts: 4
Location: usa

PostPosted: Mon Jan 06, 2020 8:41 pm    Post subject: Reply to: VSE COBOL - File Status 46 when reading alternate index
Reply with quote

I apologize for not supplying the file defs ... they are...

main file def:
Code:
/* *** DEFINE CARDS BELOW  ************************************ */
  DELETE EMPLOYEE.DETAIL.FILE                                    -
   CLUSTER                                                        -
   PURGE                                                          -
   CATALOG(WPAS85)                                                 
   DEFINE CLUSTER                                                 -
 ( NAME('EMPLOYEE.DETAIL.FILE')                                   -
   INDEXED                                                        -
   FREESPACE(0 0)                                                 -
   KEYS(53 36)                                                    -
   RECORDSIZE(450 450)                                            -
   NOREUSE                                                        -
   SHAREOPTIONS(4 3)                                              -
   NONSPANNED                                                     -
   TO(2099365)                                                    -
             )    /* END OF CLUSTER */                            -
          DATA                                                    -
 ( NAME('EMPLOYEE.DETAIL.DATA')                                   -
   CYLINDERS(1300 30)                                             -
   VOLUMES( WPAS85  )                                             -
   CISZ(4096)                                                     -   
   SPEED                                                          -   
             )    /* END OF DATA */                               -   
          INDEX                                                   -   
 ( NAME('EMPLOYEE.DETAIL.INDEX')                                  -   
   CYLINDERS(5 1)                                              -     
   VOLUMES( WPAS85  )                                             -   
   CISZ(3584)                                                     -   
             )    /* END OF INDEX */                              -   
   CATALOG(WPAS85)                                                   


1st alternate index:
Code:
/* *** AIX STUFF BELOW   *************************************** */
  DEFINE AIX                                                     - 
( NAME('EMPLOYEE.AIX.FILE')                                      - 
  RELATE('EMPLOYEE.DETAIL.FILE')                                 - 
  FREESPACE(0 0)                                                 - 
  KEYS(41 48)                                                    - 
   RECORDSIZE(100 3148)                                           - 
   NOREUSE                                                        - 
   SHAREOPTIONS(4 3)                                              - 
   NONUNIQUEKEY                                                   - 
   UPGRADE                                                        - 
   TO(2099365)                                                    - 
             )    /* END OF AIX     */                            - 
          DATA                                                    - 
 ( NAME('EMPLOYEE.AIX.FILE.DATA')                                 - 
   CYLINDERS(300 10)                                              - 
   VOLUMES( WPAS85  )                                             - 
   CISZ(4096)                                                     - 
   SPEED                                                          - 
             )    /* END OF DATA */                               - 
          INDEX                                                   - 
 ( NAME('EMPLOYEE.AIX.FILE.INDEX')                                - 
   CYLINDERS(10 1)                                                 -
   VOLUMES( WPAS85  )                                             - 
   CISZ(3072)                                                     -   
             )    /* END OF INDEX */                              -   
   CATALOG(WPAS85)                                                   
   DEFINE  PATH                                                   -   
 ( NAME('EMPLOYEE.AIX.FILE.PATH')                                 -   
   PATHENTRY('EMPLOYEE.AIX.FILE')                                 -   
   UPDATE                                                         -   
             )    /* END OF PATH    */                            -   
   CATALOG(WPAS85)                                                   


2nd alt. index:
Code:
   DEFINE AIX                                                     -   
 ( NAME('EMPLOYEE.AIX3.FILE')                                     -   
   RELATE('EMPLOYEE.DETAIL.FILE')                                 -   
   FREESPACE(0 0)                                                 -   
   KEYS(13 300)                                                   -   
   RECORDSIZE(92 4138)                                            -   
   NOREUSE                                                        -   
   SHAREOPTIONS(4 3)                                              -   
   NONUNIQUEKEY                                                   -   
   UPGRADE                                                        - 
   TO(2099365)                                                    - 
             )    /* END OF AIX     */                            - 
          DATA                                                    - 
 ( NAME('EMPLOYEE.AIX3.FILE.DATA')                                - 
   CYLINDERS(220 10)                                              - 
   VOLUMES( WPAS85  )                                             - 
   CISZ(5632)                                                     - 
   SPEED                                                          - 
             )    /* END OF DATA */                               - 
          INDEX                                                   - 
 ( NAME('EMPLOYEE.AIX3.FILE.INDEX')                               - 
   CYLINDERS(10 1)                                                - 
   VOLUMES( WPAS85  )                                             - 
   CISZ(2048)                                                     - 
             )    /* END OF INDEX */                              - 
   CATALOG(WPAS85)                                                   
   DEFINE  PATH                                                   - 
 ( NAME('EMPLOYEE.AIX3.FILE.PATH')                                - 
   PATHENTRY('EMPLOYEE.AIX3.FILE')                                - 
   UPDATE                                                         - 
             )    /* END OF PATH    */                            - 
   CATALOG(WPAS85)                                                   


standard label:
// DLBL DETK4P,'EMPLOYEE.AIX3.FILE.PATH',,VSAM,CAT=WPAS85


thanks,
Dennis

Code'd for you
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 775
Location: Maryland

PostPosted: Mon Jan 06, 2020 9:31 pm    Post subject:
Reply with quote

Where are the
Code:
CODE TAGS???????
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon Jan 06, 2020 9:36 pm    Post subject:
Reply with quote

Your VSAM definitions don't make a whole lot of sense -- neither alternate index definition will contain an integer number of duplicate keys. And the alternate index you are reading is being treated as a primary key by the code since there is no ALTERNATE RECORD KEY statement in the SELECT.

Since your program does not treat the alternate index as an alternate index, I recommend debugging by printing each file status code after the read. A 46 file status code means either the previous read did NOT cause end-of-file but was not successful, or the previous read DID cause end-of-file yet the program attempted to read another record -- so displaying each file status value will tell you which of these conditions occurred. I'm not in favor of mixing READ / AT END with IF <file-status> statements since it's easy to get odd behavior in the code.

And you should be using code tags for code -- it's a lot easier to follow when you do.
Back to top
View user's profile Send private message
dennis larson

New User


Joined: 03 Jan 2020
Posts: 4
Location: usa

PostPosted: Mon Jan 06, 2020 9:36 pm    Post subject:
Reply with quote

not sure what you mean by code tags?

I define the file as:
SELECT DET01-FILE ASSIGN TO SYS022-DA-3340-DETK4P

which uses the standard label:
// DLBL DETK4P,'EMPLOYEE.AIX3.FILE.PATH',,VSAM,CAT=WPAS85

so I am reading the file by the 3rd key .....
I can start reading the file after the problem records using the 3rd key just fine ....
and can read the file from the start of the 3rd key until I get to the 'bad' record(s) which get the VSAM status code of 46

thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon Jan 06, 2020 9:42 pm    Post subject: Reply to: VSE COBOL - File Status 46 when reading alternate index
Reply with quote

When you click on the Reply button, there is a Code button just below the topic subject -- use that for code; otherwise the forum software makes every line left-justified without preserving spacing (which can be very important in code).

And COBOL expects, if you are using alternate indexes, that the program SELECT includes the base cluster. So your program may be "working" without that base cluster but it is also entirely possible that your file status 46 is caused because you have not coded your program per the COBOL standard.
Back to top
View user's profile Send private message
dennis larson

New User


Joined: 03 Jan 2020
Posts: 4
Location: usa

PostPosted: Mon Jan 06, 2020 9:43 pm    Post subject:
Reply with quote

I can look into using the alternate key phrase in the COBOL file def. however, all the programs in our shop use this coding style and we have never had an issue previously. As for printing each status code after each read, I would assume that all of the previous reads had a status of 00 or 02 since this status check is after each read and if it is any other value, I display the status and blow up the program:

READ DET01-FILE INTO DET01-RECORD
AT END
MOVE HIGH-VALUES TO DET01-KEY.

IF DET01-KEY NOT = HIGH-VALUES (I added this when trying to debug)
IF DET-STATUS = '00' OR '02'
NEXT SENTENCE
ELSE
DISPLAY 'PROBLEM DET READ - STATUS =' DET-STATUS
'**KEY=' DET01-KEY '*****'
CALL 'ABORT'.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon Jan 06, 2020 11:12 pm    Post subject:
Reply with quote

From the Enterprise COBOL Language Reference manual (page 276 of the 6.3 version on the 46 file status code):
Quote:
A sequential READ statement was attempted on a file open in the input or I-O mode and no valid next record had been established because:
• The preceding READ statement was unsuccessful but did not cause an at-end condition.
• The preceding READ statement caused an at-end condition.
Either you're not getting a 46 file status code (in which case why did you post), or you're getting a 46 file status code and one of those two conditions FROM THE MANUAL applies.

Since you are certain your code is correct, and you're not willing to perform reasonable debugging actions to help yourself, topic is locked.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    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 Question for Cobol Report Writer jackzhang75 COBOL Programming 0 Wed May 27, 2020 4:35 am
No new posts Compare multiple files using JCL/Rexx... tanvi110788 JCL & VSAM 4 Tue May 19, 2020 5:47 pm
No new posts Need help to concatenate files with w... ssuthagar All Other Mainframe Topics 3 Fri May 15, 2020 1:39 am
No new posts Need example for CALL 'ISRSUPC' in COBOL Sue Adams COBOL Programming 2 Thu May 14, 2020 5:32 am
No new posts COBOL Student learning COBOL File Han... torrind COBOL Programming 3 Sat May 09, 2020 3:40 am

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