Using messages with the REXX EXIT statement

As the previous section shows, you can use the REXX EXIT instruction to exit a procedure with logic. QMF always issues a message when it finishes running a procedure with logic. If you use the EXIT instruction, the message you see depends on these factors:

Table 2 shows which message you see based on the given conditions.

Table 2. Messages returned from QMF
Nonzero return code from the last QMF command Procedure return code Message at completion of procedure
No 0 OK, your procedure was run.
No nonzero The return code from your procedure was 8.
Yes 0 The error message provided by QMF.
Yes nonzero The error message provided by QMF.

An error message takes precedence over the return code message if you have an incorrect QMF command and a nonzero return code.

If you want to show the error message from the last command and exit with a QMF return code, use the MESSAGE command and the EXIT DSQ_RETURN_CODE as in the following example:

Figure 5. Showing the error message and return code

·
·
·
"MESSAGE (TEXT='"dsq_message_text"'" exit dsq_return_code

The variables dsq_message_text and dsq_return_code are QMF-provided REXX variables. (For a complete listing of these variables, see REXX language interface.) You can use the MESSAGE command and the dsq_message_text variable to store and display a message after further processing has occurred, as in Figure 6.

Figure 6. Storing and retrieving messages in a procedure

 /* Monthly report                                           */  
Signal on error    
"DISPLAY TABLE JUNE_INFO"    
"PRINT REPORT"    
Exit(0);  
Error:    Original_msg = dsq_message_text    
/* Saves error message. */   
"RUN PROC GENERAL_RECOVERY"        
/* This proc generates  */                             
/* new dsq_message_text. */    
"MESSAGE (TEXT='" Original_msg "'" 
/* Display original error msg. */    
Exit dsq_return_code;

For more information on the MESSAGE command, see MESSAGE.

[ Previous Page | Next Page | Contents | Index ]