ON-ERROR Handling using VSAM

I’m new to this community so please bear with me.

I have a subprogram that is accessing Customer Credit data on a VSAM file. During maintenance periods the unavailability of this data causes all orders entered to go on Credit Hold which causes our Credit Dept extra work.

The decision was made to create a “Shadow” VSAM Credit file that can be accessed while the “REAL” VSAM Credit File is closed for Maintenance. If a NAT3539 is detected, we will READ the “Shadow” file to gather customer credit data.

However, even though I am capturing the NAT3539 with ON-ERROR logic, when control returns to the calling program, the NAT3539 is still being triggered causing the On-Line Application to abend.

How do I get my Application(s) to Ignore this error and continue normal program execution ?

Thanks for any suggestions.

Tadd Yarbrough
AVX Corporation
Greenville, SC USA

Hi Tadd,

Perhaps, such a “solution” would help you(?). Briefly, I close the VSAM file for CICS and the program sends me that “‘PLEASE WAIT UNTIL VSAM IS OPENED; CALL THE GUY, PLEASE’” message; then, I run a batch job to open the VSAM file, hit the ENTER, NATURALS does “FETCH”, and the program runs successfully.
My point: you may use such a “trick”, but I think you have no choice as to FETCH your another program which reads your Shadow file when the main one is on maintenance.

Best regards,
NK

This is the source of the program NKT:

DEFINE DATA LOCAL
01 SAISI-SAL VIEW OF SAISI-SAL
02 DELETE-XX
02 KEY-XX
END-DEFINE
**
ON ERROR
IF *ERROR-NR = 3539
RESET ERROR-NR
INPUT ‘PLEASE WAIT UNTIL VSAM IS OPENED; CALL THE GUY, PLEASE’
FETCH ‘NKT’ /
FETCH THE SAME PROGRAM, BUT IT’S NOT REQUIRED
END-IF
END-ERROR
**
READ SAISI-SAL BY KEY-XX
DISPLAY ‘THE VSAM FILE IS READ WITH SUCCESS’
END-READ
END

A Natural error does not always have to trigger an abend. The trick is to regain control of the process within the ON ERROR block. If the module reaches the END-ERROR statement, then it will abend. There are two ways that I know of to regain control, FETCH another program, or within an external subroutine or subprogram, ESCAPE ROUTINE will return control to the calling module.

So, if you externalize your VSAM access into a subprogram, within the ON ERROR block you can include a parameter to tell the calling module that VSAM is closed and the calling module can then look to your shadow file.

Here is a simple example:
Calling program:

DEFINE DATA LOCAL       
1 #ERROR (N4)           
END-DEFINE              
INCLUDE TXCPERR         
*                       
CALLNAT 'ON-ERR' #ERROR 
DISPLAY #ERROR (EM=9999)
END                     

Subprogram:

DEFINE DATA PARAMETER          
1 #ERROR (N4)                  
LOCAL                          
1 #ERROR-NR  (N4)              
END-DEFINE                     
ON ERROR                       
  MOVE *ERROR-NR  TO #ERROR    
  RESET *ERROR-NR              
  ESCAPE ROUTINE               
END-ERROR                      
*                              
INPUT #ERROR-NR                
MOVE #ERROR-NR   TO *ERROR-NR  
END                            

The RESET *ERROR-NR is optional.