VSAM status key 23 after READ NEXT!



Help for IBM's record-oriented filesystem VSAM, ESDS, KSDS, RRDS, LDS and Storage management Subsystems

VSAM status key 23 after READ NEXT!

Postby j2422tw » Wed May 14, 2008 12:04 pm

Dear all:

I have a strange error by our batch COBOL!

The batch processing with SAM and VSAM,

1. read SAM , compare with VSAM
2. insert the new and rewrite the exist to VSAM
3. after read entire SAM, start VSAM from 1st record
4. VSAM READ NEXT until end
5. compare the non-key value with a date value
6. if greater , pass
7. if less or equal, delete the VSAM record, then check the VSAM status

After normal processing insert and rewrite 800 records, and delete 1700 records,
the program is end at "step 7", the status key value is 23.

After interprete the COBOL , I think the error occure at "READ NEXT" and doubt
rewrite records in "step 2" cause the problem, but not sure.

Can anyone help me to explain it?
j2422tw
 
Posts: 25
Joined: Wed Sep 19, 2007 9:46 am
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM status key 23 after READ NEXT!

Postby CICS Guy » Wed May 14, 2008 7:38 pm

j2422tw wrote:I think the error occure at "READ NEXT" and doubt
rewrite records in "step 2" cause the problem, but not sure.
You really should be checking the return code after every VSAM command.
Put in checks and display the step and return code if it is not normal, then you will know.......
CICS Guy
 
Posts: 246
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM status key 23 after READ NEXT!

Postby j2422tw » Thu May 15, 2008 6:35 am

To CICS Guy:

Thanks for your reply, that's a good way to make it clear to know what happen.

But because can't re-generate the error situation ( not sure the reason ), so we

merely wait for the error appear again.

Still thank you again.
j2422tw
 
Posts: 25
Joined: Wed Sep 19, 2007 9:46 am
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM status key 23 after READ NEXT!

Postby CICS Guy » Thu May 15, 2008 6:46 pm

j2422tw wrote:But because can't re-generate the error situation ( not sure the reason ), so we merely wait for the error appear again.
With checking the return code after every VSAM command?
CICS Guy
 
Posts: 246
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM status key 23 after READ NEXT!

Postby j2422tw » Fri May 16, 2008 6:42 am

To CICS Guy:

After two days, the batch job still normal finish. ;)

I will continue to watch it!

Many thanks for your reply!
j2422tw
 
Posts: 25
Joined: Wed Sep 19, 2007 9:46 am
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM status key 23 after READ NEXT!

Postby jayind » Fri May 16, 2008 11:40 am

Hi,

Good that it is working now but becuase of same reason it may fail again. So as suggested by CICS Guy and as a mitigation and value addition to your process, you may need to change the program now having file status check after each I-O operation on the file and it is a very good practice also. If you check the file status, you can direct the program what to do next on a particular status code, otherwise the program execution may not be in the correct flow as expected. Hope you are aware of this but still wanted to remind you. You have given the pseudocode but didnt mention about the mode in which you have opened the files. If you want a permanent fix for this, mention how you have opened the files and how the comparision has been coded with flow.

Cheers,
Jayind
jayind
 
Posts: 62
Joined: Wed Apr 23, 2008 1:37 pm
Location: Chennai, India
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM status key 23 after READ NEXT!

Postby j2422tw » Mon May 19, 2008 11:58 am

To Jayind:

Thanks for your reply!

Your mention is helpful, I make more clearly description.

The VSAM file's ACCESS MODE is DYNAMIC, and OPEN for I-O.

I attatch the partial COBOL code, is the original processing of compare and delete code
that generate the error status key 23.
         READ       VSAMFIL            NEXT  RECORD                     
             AT       END                                               
               MOVE     'Y'               TO    SW-VSAMFIL-END         
         END-READ.                                                       
    * delete records older than 12 days                                 
         IF   YFPF-INS-DATE         <=    WA-L12D-DATE                   
              DELETE                     JCVKYFPF                       
              IF   STS-VSAMFIL     NOT =   '00'                         
                   MOVE    1234     TO      RETURN-CODE                 
                   DISPLAY '*STEPXYZ * (4000-DELETE-YFPF-L12D) '       
                           'DELETE VSAMFIL ERROR:' STS-VSAMFIL         
                   GO               TO      0000-MAIN-EXIT               
              END-IF                                                     
              ADD   1               TO     CNT-DELETE-VSAMFIL           
         END-IF.                                                         


We add the file status check in the program, help it's helpful.

Thanks again for your reply!
j2422tw
 
Posts: 25
Joined: Wed Sep 19, 2007 9:46 am
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM status key 23 after READ NEXT!

Postby jayind » Mon May 19, 2008 4:11 pm

Hi,

From the code you have given,
====================================================================
1. READ VSAMFIL NEXT RECORD AT END
MOVE 'Y' TO SW-VSAMFIL-END
END-READ.
2. * delete records older than 12 days
IF YFPF-INS-DATE <= WA-L12D-DATE
DELETE JCVKYFPF
IF STS-VSAMFIL NOT = '00'
MOVE 1234 TO RETURN-CODE
DISPLAY '*STEPXYZ * (4000-DELETE-YFPF-L12D) '
'DELETE VSAMFIL ERROR:' STS-VSAMFIL
GO TO 0000-MAIN-EXIT
END-IF
ADD 1 TO CNT-DELETE-VSAMFIL
END-IF.
====================================================================

Since the record structure is not availalbe and the error message is not available, I assume the following,

1. JCVKYFPF is the key of the VSAM file record
2. You are getting 1234 is the JCL return code and the error message is "'DELETE VSAMFIL ERROR:23"

I see a flaw in the above code given by you and hence my assumptions 1 and 2 should be true.
The Flaw is,
your code is reading the VSAM file next record and at end it is moving "Y" to SW-VSAMFIL-END flag. When the actual end of file occurs, this move will happen and since there is no branching happening and as a fall through, it will execute the code below, which is the delete record "DELETE JCVKYFPF". The condition just above this statement "IF YFPF-INS-DATE <= WA-L12D-DATE " may be true because of improper initialization of "YFPF-INS-DATE".

Since your ealier loop would have deleted the current record, it is trying to delete it again and hence causing this problem. More over your intention is to delete the record and if the record does not exists, you dont need to terminate the program. You can still proceed.
The following IF statement

IF STS-VSAMFIL NOT = '00'

can be modified as

IF (STS-VSAMFIL NOT = '00' ) and (STS-VSAMFIL NOT = '23' )

then your error can occur.

Try the above and let me know.
jayind
 
Posts: 62
Joined: Wed Apr 23, 2008 1:37 pm
Location: Chennai, India
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM status key 23 after READ NEXT!

Postby j2422tw » Wed May 21, 2008 11:25 am

To Jayind:

By your mention, I make a test........

Yes, you are right, the error is happen when the last one record needed delete.

As you described:

your code is reading the VSAM file next record and at end it is moving "Y" to SW-VSAMFIL-END flag. When the actual end of file occurs, this move will happen and since there is no branching happening and as a fall through, it will execute the code below, which is the delete record "DELETE JCVKYFPF". The condition just above this statement "IF YFPF-INS-DATE <= WA-L12D-DATE " may be true because of improper initialization of "YFPF-INS-DATE".


The test result re-generate the VSAM status key 23, and because the record has been

deleted, it will finish normal in the next time run.

I will pass this message and ask programmer to fix this logic problem.

Many thanks for your detail description and help !!!
j2422tw
 
Posts: 25
Joined: Wed Sep 19, 2007 9:46 am
Has thanked: 0 time
Been thanked: 0 time


Return to VSAM/SMS

 


  • Related topics
    Replies
    Views
    Last post