Using Returned Values from a Report

A report run from the command prompt (via RUNREP) returns a value in the range 0 through 199. A number in the range 0-99 is returned for a normal report completion, and a number in the range 100-199 for a failed report (abnormal termination - for example, file not found error).

The default return codes are:

0 — Normal report completion

100 — Failed report

This return code is affected by the value of GLB.TASK. This is a built-in attribute that has an initial value of 0. Your report logic can assign any value in the range 0-99 to this attribute. If the report completes normally the value of GLB.TASK at the completion of the report is returned.

If the report has an abnormal termination, then the return value is the current value of GLB.TASK plus 100.

For example, if your report logic assigns the value 50 to GLB.TASK, then the return value would be 50 for a normal report completion and 150 for an abnormal report termination.

Example

The following logic is included in a report Budgtrpt:

Multiply 9 BUDGET-SALES Giving TOO-LOW
Multiply 1.1 BUDGET-SALES Giving TOO-HIGH
DoWhen  TOTAL-SALES < TOO-LOW OR
DoWhen  TOTAL-SALES > TOO-HIGH
Move 60 GLB.TASK
End

The following batch program runs the report BUDGRPT and uses the return code to determine whether to run the additional report EXCEPTN. The batch command if errorlevel tests for the exit value of the last program executed:

Runrep BUDGRPT
if errorlevel 60 EXCEPTN

Note: The errorlevel return is true if the actual exit value is greater than or equal to the return value.