REXX programming example

The sample REXX program, DSQABFX, is provided with QMF.

You can look at the sample source code listing here or you can access it online. The sample program is a member of the library QMF1310.SDSQEXCE.

The sample program for the REXX callable interface performs the following functions:

  • Starts QMF
  • Sets three global variables
  • Runs a query called Q1
  • Prints the resulting report by using form F1
  • Ends the QMF session

QMF does not supply query Q1 or form F1, but the sample program uses these objects.

/*REXX***************************************************************/
/* Sample program:  DSQABFX                                         */
/* REXX version of the QMF callable interface                       */
/********************************************************************/
                                                                      
                                                                      
/********************************************************************/
/* Start a query interface session                                  */
/********************************************************************/
                                                                      
call dsqcix "START (DSQSMODE=INTERACTIVE"                             
say dsq_message_id dsq_message_text                                   
if dsq_return_code = dsq_severe then exit dsq_return_code             
                                                                      
/********************************************************************/
/* Set numeric values into query using SET command                  */
/********************************************************************/
                                                                      
call dsqcix "SET GLOBAL (MYVAR01=20,SHORT=40,MYVAR03=84"              
say dsq_message_id dsq_message_text                                   
if dsq_return_code = dsq_severe then exit dsq_return_code             
                                                                      
/********************************************************************/
/* Run a query                                                      */
/********************************************************************/
                                                                      
call dsqcix "RUN QUERY Q1"                                            
say dsq_message_id dsq_message_text                                   
if dsq_return_code = dsq_severe then exit dsq_return_code             
                                                                      
/********************************************************************/
/* Print the results of the query                                   */
/********************************************************************/
                                                                      
call dsqcix "PRINT REPORT (FORM=F1)"                                  
say dsq_message_id dsq_message_text                                   
if dsq_return_code = dsq_severe then exit dsq_return_code             
                                                                      
/********************************************************************/
/* End the query interface session                                  */
/********************************************************************/
                                                                      
call dsqcix "EXIT"                                                    
say dsq_message_id dsq_message_text                                   
exit dsq_return_code