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?
VSAM status key 23 after READ NEXT!
Re: VSAM status key 23 after READ NEXT!
You really should be checking the return code after every VSAM command.j2422tw wrote:I think the error occure at "READ NEXT" and doubt
rewrite records in "step 2" cause the problem, but not sure.
Put in checks and display the step and return code if it is not normal, then you will know.......
Re: VSAM status key 23 after READ NEXT!
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.
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.
Re: VSAM status key 23 after READ NEXT!
With checking the return code after every VSAM command?j2422tw wrote:But because can't re-generate the error situation ( not sure the reason ), so we merely wait for the error appear again.
Re: VSAM status key 23 after READ NEXT!
To CICS Guy:
After two days, the batch job still normal finish.
I will continue to watch it!
Many thanks for your reply!
After two days, the batch job still normal finish.

I will continue to watch it!
Many thanks for your reply!
-
- Posts: 62
- Joined: Wed Apr 23, 2008 1:37 pm
- Skillset: Mainframe - JCL, COBOL, VSAM, DB2, REXX, CICS
- Referer: Internet Search
- Location: Chennai, India
- Contact:
Re: VSAM status key 23 after READ NEXT!
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
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
Re: VSAM status key 23 after READ NEXT!
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.
We add the file status check in the program, help it's helpful.
Thanks again for your reply!
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.
Code: Select all
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!
-
- Posts: 62
- Joined: Wed Apr 23, 2008 1:37 pm
- Skillset: Mainframe - JCL, COBOL, VSAM, DB2, REXX, CICS
- Referer: Internet Search
- Location: Chennai, India
- Contact:
Re: VSAM status key 23 after READ NEXT!
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.
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.
Re: VSAM status key 23 after READ NEXT!
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:
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 !!!
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:
Code: Select all
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 !!!
-
- Similar Topics
- Replies
- Views
- Last post
-
- 3
- 7927
-
by socker_dad
View the latest post
Thu Jan 28, 2021 4:13 am
-
- 2
- 1463
-
by naga821
View the latest post
Fri Oct 28, 2022 7:31 pm
-
- 6
- 6365
-
by Mainframe_Dev
View the latest post
Mon Jan 30, 2023 1:06 am
-
- 11
- 3762
-
by Pedro
View the latest post
Tue Dec 27, 2022 11:24 am
-
- 2
- 4025
-
by zbius
View the latest post
Wed Nov 06, 2024 2:16 pm