Previous Topic: Use the Schedule Manager Application Program InterfaceNext Topic: Keywords on the Schedule Manager API QUERY Command


API QUERY Command—Returns Schedule Manager Data

The API QUERY command returns Schedule Manager data, such as schedule names, period definitions, defined links, and so on. The data returned depends on the keywords entered on the QUERY command text. Syntax and examples of the numerous possible keyword combinations on the QUERY command are shown below.

Data is returned by the QUERY command in the following format:

delimit||code||delimit||count||delimit||value1||delimit||value2|
|delimit||...

In the format above, the first character returned is used to delimit values in the returned data. The first value returned is the return code of the QUERY operation. The second value returned is the count of data values that follow. The data always ends with the delimit character. When return code > 0, then count is actually the text of an error message. When return code = 0, then count may also be 0.

Examples given in this section were generated by calling the following REXX program named SM$APIQ to call the Schedule Manager API and display the results at the terminal:

/*------------------------------------------------------------------*/ /* REXX test ASOSMAPI API QUERY calls. */ /*--+----1----+----2----+----3----+----4----+----5----+----6----+---*/ /* */ PARSE UPPER ARG sm_api_parms CALL ASOSMAPI sm_api_parms SAY 'SM$APIQ Result='result IF result='RESULT' THEN DO say 'Bad QUERY' END ELSE DO PARSE VAR result rdelim 2 rcode (rdelim) rcount (rdelim) +0 rresult IF rcode<>0 THEN DO say 'QUERY returned error code "'||rcode||'" and error ' say 'text: "'||rcount||'"' END ELSE DO i = 1 TO rcount PARSE VAR rresult rdelim 2 rentry (rdelim) +0 rresult SAY RIGHT(i,3)||':'||rentry END END EXIT result

Program SM$APIQ above was called by issuing the following command from the ISPF command shell on a TSO user ID logged on to a system with a single copy of CA OPS/MVS running:

OI SM$APIQ arg

Argument arg in the above command text contains the QUERY command syntax to call Schedule Manager, documented below.

For more information on the OI command, see OPSIMEX Command Processor in the chapter “POI Command Processors” in the Command and Function Reference.

Syntax:

QUERY
   {SCHEDULE(ACTIVE) SOURCE}

Returns the name of the schedule that is loaded into the ACTIVE schedule.

Example: Query the schedule name

Command (and response) to query the name of the schedule that is loaded into the ACTIVE schedule on system OPS44R:

OI SM$APIQ QUERY SCHEDULE(OPS44R>ACTIVE) SOURCE
SM$APIQ MESSAGE: LOAD_GET API RESPONSE (continued...)
SM$APIQ MESSAGE: OPS44R>SLEJO01>15:42:17.590471 GLOBAL0.ATMSM_ACTIVE_OPS44R=(PR
ODUCTION ON OPS44R)
SM$APIQ Result=:0:1:PRODUCTION ON OPS44R:
  1:PRODUCTION ON OPS44R
***

Syntax:

QUERY
   {SCHEDULE(*)}

Returns a list of all schedules that are defined in Schedule Manager.

Example: Query names of all schedules

Command (and response) to query the names of all schedules that are defined in Schedule Manager on the local system:

OI SM$APIQ QUERY SCHEDULE(*)
SM$APIQ Result=:0:7:DEVELOPMENT:PRODUCTION:PRODUCTIONA:PRODUCTIONB:PRODUCTIONC:S
ERVER:TESTBED:
   1:DEVELOPMENT                                                                
   2:PRODUCTION                                                                 
   3:PRODUCTIONA                                                                
   4:PRODUCTIONB                                                                
   5:PRODUCTIONC                                                                
   6:SERVER                                                                     
   7:TESTBED                                                                    
***

Syntax:

QUERY
   {PERIOD(*)}
   {SCHEDULE(ssss)}

Return a list of all periods that are defined in schedule ssss.

Example: Query the names of all periods

Command (and response) to query the names of all periods that are defined in schedule PRODUCTION on the local system:

OI SM$APIQ QUERY SCHEDULE(PRODUCTION) PERIOD(*)
SM$APIQ Result=:0:13:WENDLITE S.....S 0800-2000:WENDDARK S.....S 2000-3200:EVER
YNOON SMTWTFS 1200-1300:WEEKDAY .MTWTF. 0800-1600:WEEKEVENING .MTWTF. 1600-2400:
WEEKNIGHT .MTWTF. 2400-3200:THNXLITE03 11/27/2007-11/28 0800-2000:THNXDARK03 11/
27/2                                                                            
  1:WENDLITE S.....S 0800-2000                                                 
  2:WENDDARK S.....S 2000-3200                                                 
  3:EVERYNOON SMTWTFS 1200-1300                                                
  4:WEEKDAY .MTWTF. 0800-1600                                                  
  5:WEEKEVENING .MTWTF. 1600-2400                                              
  6:WEEKNIGHT .MTWTF. 2400-3200                                                
  7:THNXLITE03 11/27/2007-11/28 0800-2000                                      
  8:THNXDARK03 11/27/2007-11/28 2000-3200                                      
  9:XMASLITE03 12/24/2007-12/25 0800-2000                                      
 10:XMASDARK03 12/24/2007-12/25 2000-3200                                      
 11:XMASALL03 12/25/2007 0000-2400                                             
 12:XMASEVERY 12/25 0000-2400                                                  
 13:DEFAULT                                                                    
***

Syntax:

QUERY
   {PERIOD(pppp)}
   {SCHEDULE(ssss)}

Return a list of all resources that are linked to period pppp in schedule ssss.

Example: Query the names of all resources

Command (and response) to query the names of all resources that are linked to period EVERYNOON in schedule PRODUCTION on the local system:

OI SM$APIQ QUERY SCHEDULE(PRODUCTION) PERIOD(EVERYNOON)
SM$APIQ Result=:0:1:DB2_STCTBL.ACF2:                                 
  1:DB2_STCTBL.DB2                                                   
***

Syntax:

QUERY
   {SCHEDULE(ssss)}
   {TABLE(*)}

Returns a list of all SSM resource tables.

Note: Keyword SCHEDULE(ssss) is required to allow the user to specify the system to be queried. You must specify a valid schedule name, although only the system> portion (if any) of the specified schedule name affects the operation of this command.

Example: Query the name of all SSM resource tables

Command (and response) to query the name of all SSM resource tables on the local system:

OI SM$APIQ QUERY SCHEDULE(PRODUCTION) TABLE(*)
SM$APIQ Result=:0:6: ACF2_STCTBL: CICS_STCTBL: DB2_STCTBL: IMS_STCTB
L:JES2_STCTBL: TSO_STCTBL:
  1:ACF2_STCTBL                                                     
  2:CICS_STCTBL                                                     
  3:DB2_STCTBL                                                      
  4:IMS_STCTBL                                                      
  5:JES2_STCTBL                                                     
  6:TSO_STCTBL                                                      
***

Syntax:

QUERY
   {RESOURCE(*)}
   {SCHEDULE(ssss)}
   {TABLE(tttt)}

Returns a list of all resources in SSM resource table tttt.

Note: Keyword SCHEDULE(ssss) is required to allow the user to specify the system to be queried. You must specify a valid schedule name, although only the system> portion (if any) of the specified schedule name affects the operation of this command.

Example: Query the names of all resources in SSM resource table

Command (and response) to query the names of all resources in SSM resource table TSO_STCTBL on the local system:

OI SM$APIQ QUERY SCHEDULE(PRODUCTION) TABLE(TSO_STCTBL) RESOURCE(*)
SM$APIQ Result=:0:2:TSO:TSOTEST:
  1:TSO                         
  2:TSOTEST                     
***

Syntax:

QUERY
   {RESOURCE(rrrr)}
   {SCHEDULE(ssss)}
   {TABLE(tttt)}

Returns a list of all periods defined in schedule ssss that are linked to resource rrrr in table tttt.

Example: query the names of all periods

Command (and response) to query the names of all periods defined in schedule PRODUCTION on the local system that are linked to resource TSO in table TSO_STCTBL:

OI SM$APIQ QUERY SCHEDULE(PRODUCTION) TABLE(TSO_STCTBL) RESOURCE(TSO)
SM$APIQ Result=:0:2:WEEKDAY:XMASALL03:
  1:WEEKDAY                           
  2:XMASALL03                         
***

Syntax:

QUERY
   {PERIOD(pppp)}
   {RESOURCE(rrrr)}
   {SCHEDULE(ssss)}
   {TABLE(tttt)}

Returns the DESIRED_STATE of the link defined in schedule ssss between period pppp and resource rrrr in table tttt, or else return nothing if there is no link defined.

Example: query the DESIRED_STATE of the link

Command (and response) to query the DESIRED_STATE of the link defined in schedule PRODUCTION on the local system between period WEEKDAY and resource TSO in table TSO_STCTBL:

OI SM$APIQ QUERY SCHEDULE(PRODUCTION) TABLE(TSO_STCTBL) RESOURCE(TSO)
           PERIOD(WEEKDAY)
SM$APIQ Result=:0:1:OFF:
  1:OFF 
***

Example: query the DESIRED_STATE of a non-existent link

Command (and response) to query the DESIRED_STATE of a non-existent link in schedule PRODUCTION on the local system between period WEEKNIGHT and resource TSO in table TSO_STCTBL:

OI SM$APIQ QUERY SCHEDULE(PRODUCTION) TABLE(TSO_STCTBL) RESOURCE(TSO)

PERIOD(WEEKNIGHT)
SM$APIQ Result=:0:0:
***