The following program, DSQABFF, is shipped with QMF and uses VS FORTRAN.
You can look at the sample source code listing here or you can access it online. For OS/390, the sample program is a member of the library QMF720.SDSQSAPE. For VM, the sample program is on the production disk.
The sample program for the FORTRAN callable interface performs the following function:
QMF does not supply query Q1 or form F1, but the sample program uses these objects.
This section also shows how to compile, link-edit, and run a FORTRAN program using the callable interface. QMF does not ship the REXX EXEC, JCL, or CLIST in these examples, but you can copy them from here, altering them to suit your installation.
C*********************************************************************** C Sample Program: dsqabff C FORTRAN Version of SAA Query Manager Callable Interface C C Creation Date: 11/21/89 C C ENVIRONMENT: API IN FORTRAN C*********************************************************************** C C Processing: C a. Start a Query Manager Session using the Callable Interface. C C b. Set Global Query Manager numeric variables. C C d. Run a Query Manager query using the Callable Interface. C C e. Print a report using the Callable Interface. C C f. Exit the Query Manager Session. C
C Prerequisites:1. Create the SAMPLE database. C C 2. Create a prompted query, Q1, which has a SELECT state C C 3. Create a form, F1, that displays data for query Q1. C C*********************************************************************** PROGRAM DSQABFF C*********************************************************************** C Include and declare query interface communications area C*********************************************************************** INCLUDE (DSQCOMMF) C********************************************************************** C Query interface command lengths and commands C********************************************************************** INTEGER COMMAND_LENGTH CHARACTER START_QUERY_INTERFACE*5, + SET_GLOBAL_VARIABLES*10, + RUN_QUERY*12, + PRINT_REPORT*22, + END_QUERY_INTERFACE*4 C********************************************************************** C Query command extension, number of parameters and lengths C********************************************************************** INTEGER NUMBER_OF_PARAMETERS, + KEYWORD_LENGTHS(10), + DATA_LENGTHS(10) C********************************************************************** C Variable data type constants C********************************************************************** CHARACTER CHAR_DATA_TYPE*4, + INT_DATA_TYPE*4 C********************************************************************** C Keyword parameter and value for START command C********************************************************************** CHARACTER*8 START_KEYWORDS(1) CHARACTER*11 START_KEYWORD_VALUES(1)
C********************************************************************** C Keyword parameter and values for SET command C********************************************************************** CHARACTER SET_KEYWORDS(19) CHARACTER SET_KEYWORD_1*7, + SET_KEYWORD_2*5, + SET_KEYWORD_3*7 EQUIVALENCE (SET_KEYWORDS( 1), SET_KEYWORD_1), + (SET_KEYWORDS( 8), SET_KEYWORD_2), + (SET_KEYWORDS(13), SET_KEYWORD_3) CHARACTER SET_VALUES(12) INTEGER*4 SET_VALUE_1, + SET_VALUE_2, + SET_VALUE_3 EQUIVALENCE (SET_VALUES(1), SET_VALUE_1), + (SET_VALUES(5), SET_VALUE_2), + (SET_VALUES(9), SET_VALUE_3) C*********************************************************************** C Declare command length and return code variables C*********************************************************************** INTEGER LEN, + RC C*********************************************************************** C Initialization C*********************************************************************** DATA START_QUERY_INTERFACE /'START' / DATA SET_GLOBAL_VARIABLES /'SET GLOBAL' / DATA RUN_QUERY /'RUN QUERY Q1' / DATA PRINT_REPORT /'PRINT REPORT (FORM=F1)'/ DATA END_QUERY_INTERFACE /'EXIT' / DATA CHAR_DATA_TYPE /DSQ_VARIABLE_CHAR / DATA INT_DATA_TYPE /DSQ_VARIABLE_FINT /
C********************************************************** C Start Query Session C********************************************************** DSQ_COMM_LEVEL = DSQ_CURRENT_COMM_LEVEL NUMBER_OF_PARAMETERS = 1 COMMAND_LENGTH = LEN(START_QUERY_INTERFACE) KEYWORD_LENGTHS(1) = LEN(START_KEYWORDS(1)) DATA_LENGTHS(1) = LEN(START_KEYWORD_VALUES(1)) START_KEYWORDS(1) = 'DSQSMODE' START_KEYWORD_VALUES(1) = 'INTERACTIVE' RC = DSQCIFE(DSQCOMM, + COMMAND_LENGTH, + START_QUERY_INTERFACE, + NUMBER_OF_PARAMETERS, + KEYWORD_LENGTHS, + START_KEYWORDS, + DATA_LENGTHS, + START_KEYWORD_VALUES, + CHAR_DATA_TYPE) C********************************************************************** C Set numeric values into query using SET command C********************************************************************** NUMBER_OF_PARAMETERS = 3 COMMAND_LENGTH = LEN(SET_GLOBAL_VARIABLES) SET_KEYWORD_1 = 'MYVAR01' SET_KEYWORD_2 = 'SHORT' SET_KEYWORD_3 = 'MYVAR03' KEYWORD_LENGTHS(1) = LEN(SET_KEYWORD_1) KEYWORD_LENGTHS(2) = LEN(SET_KEYWORD_2) KEYWORD_LENGTHS(3) = LEN(SET_KEYWORD_3) DATA_LENGTHS(1) = 4 DATA_LENGTHS(2) = 4 DATA_LENGTHS(3) = 4 SET_VALUE_1 = 20 SET_VALUE_2 = 40 SET_VALUE_3 = 84 RC = DSQCIFE(DSQCOMM, + COMMAND_LENGTH, + SET_GLOBAL_VARIABLES, + NUMBER_OF_PARAMETERS, + KEYWORD_LENGTHS, + SET_KEYWORDS, + DATA_LENGTHS, + SET_VALUES, + INT_DATA_TYPE)
C********************************************************************** C Run a query C********************************************************************** COMMAND_LENGTH = LEN(RUN_QUERY) RC = DSQCIF(DSQCOMM, + COMMAND_LENGTH, + RUN_QUERY) C********************************************************************** C Print the results of the query C********************************************************************** COMMAND_LENGTH = LEN(PRINT_REPORT) RC = DSQCIF(DSQCOMM, + COMMAND_LENGTH, + PRINT_REPORT) C********************************************************************** C End the query interface session C********************************************************************** COMMAND_LENGTH = LEN(END_QUERY_INTERFACE) RC = DSQCIF(DSQCOMM, + COMMAND_LENGTH, + END_QUERY_INTERFACE) END