Previous Topic: &FILEKEY

Next Topic: &FILERCNT


&FILERC

Indicates the success or otherwise of a file processing function.

A return code is set after the execution of the &FILE ADD, &FILE DEL, &FILE GET, &FILE OPEN, and &FILE PUT file processing statements. This return code is placed in the &FILERC system variable, which can then be tested to determine whether the operation was successful. The meaning of the various return codes is as follows:

For &FILE ADD:

0

Record added successfully.

1

Record added; truncation has occurred.

4

Record already exists (not replaced).

8

Error occurred; &VSAMFDBK is set.

16

NCL or Mapping Services processing error; &SYSMSG is set.

For &FILE DEL:

0

Record deleted successfully.

4

Record not found.

8

Error occurred; &VSAMFDBK is set.

16

NCL or Mapping Services processing error; &SYSMSG is set.

For &FILE GET:

0

Record retrieved successfully.

4

Record not found or end of data.

8

Error occurred; &VSAMFDBK is set.

16

NCL or Mapping Services processing error; &SYSMSG is set.

For &FILE OPEN:

0

Procedure is restricted to read only access.

4

Procedure is restricted to read and update access without delete authority.

8

Procedure is not restricted. Read, update and delete are authorized. If no authorization exit (NCLEX01) is in effect, then this value is set if the file is available for processing.

12

No access is authorized.

16

Specified file ID is not available for processing.

For &FILE PUT:

0

Record added or replaced successfully.

1

Record added; truncation has occurred.

4

Reserved for future use.

8

Error occurred; &VSAMFDBK is set.

16

NCL or Mapping Services processing error; &SYSMSG is set.

Example: &FILERC

& FILE OPEN ID=HELPDESK FORMAT=DELIMITED 

&IF &FILERC EQ 16 &THEN +
    &ENDAFTER &WRITE DATA=NOT AVAILABLE 

&FILE SET ID=HELPDESK KEY='PROB005' 

&FILE GET ID=HELPDESK OPT=KEQ VARS=TXT 

&IF &FILERC NE O &THEN +
    &WRITE DATA=RECORD NOT FOUND

Notes:

Simplify the testing for &FILERC and branching to the appropriate processing routine by using direct branching. For more information, see the Network Control Language Programming Guide.

For example:

&FILE GET ID=HELPDESK OPT=KEQ VARS=TXT

&GOTO 
.GET&FILERC

.GET0 
&ENDAFTER &WRITE DATA=RECORD RETRIEVED SUCCESSFULLY

.GET4
&ENDAFTER &WRITE DATA=RECORD NOT FOUND

.GET8 
&ENDAFTER &WRITE DATA=ERROR VSAM CODE=&VSAMFDBK

The &VSAMFDBK system variable is also set on completion of a file processing operation, and is used to determine the exact cause of a VSAM-related error.

The values set in &FILERC after an &FILE OPEN statement are determined by the NCL file ID authorization exit NCLEX01. NCLEX01 is invoked the first time each new &FILE OPEN statement is referenced in a procedure. The name of the invoked exit is determined by the SYSPARMS command NCLEX01 operand. If no exit is in effect, only values of 8 (to authorize full access) and 16 (to indicate that the specified file is not available for processing) are set.

When &FILERC returns 16, &SYSMSG contains a message explaining the error. A value of 16 is also set for Mapping Services processing errors. This should occur only when in mapped processing mode.

Note: For more information, see the examples in the distribution library.

More information:

&VSAMFDBK