Previous Topic

Next Topic

Book Contents

Book Index

Sample Rule Search API

The following sample program demonstrates usage of the Rule Search API. This sample includes commands that print the information in the RLM and RSI control blocks (that is, the DO statements and relevant descriptions).

This sample is located in the CTTSAM3 member in the IOA SAMPLE library.

Figure 97 Sample Rule Search API

        ***********************************************************************    

        *                                                                     *

        *                             CTTSAM3                                 *

        *                   Using Rule Search API - Sample                    *

        *                                                                     *

        * ------------------------------------------------------------------- *

        *  FUNCTION: This sample program demonstrates the Rule Search API.    *

        *            This program obtains a copy of the real-time environment *

        *            TCT, specifies two ON statements and calls the API.      *

        *                                                                     *

        *            Upon return from the API, the program searches the RLM   *

        *            control block created by the API for DO STACK, DO VAULT  *

        *            and DO CONDITION statements which are triggered by the   *

        *            specified ON criteria. The DO statements that are        *

        *            detected are then printed out.                           *

        *                                                                     *

        *  RETURN CODES:                                                      *

        *            00      OK                                               *

        *            04      No matching rules were triggered or found        *

        *            24      SYSPRINT file could not be opened                *

        *            28      TCT could not be obtained. Control‑M/TAPE is     *

        *                    probably not active                              *

        *            Other   Internal error in API (see documentation)        *

        *                                                                     *

        *  LOGIC:    The following steps are performed by this sample program:*

        *                                                                     *

        *            1. Obtain a copy of the real-time environment TCT.       *

        *                                                                     *

        *            2. Specify ON DATASET and ON VOLUME criteria and call    *

        *               the Rule Search API.                                  *

        *                                                                     *

        *            3. Search for DO STACK, DO VAULT and DO CONDITION        *

        *               statements in the RLM control block created by        *

        *               the API, and print information about detected DO      *

        *               statements.                                           *

        *                                                                     *

        *            4. If a DO STACK statement was found in the previous     *

        *               step, print the rule name, the table name, and the    *

        *               library name in which the DO STACK statement was      *

        *               found.                                                *

        *                                                                     *

        * DD CARDS:  SYSPRINT - Output file                                   *

        *                                                                     *

        * DISCLAIMER: This sample is provided on an as-is basis, without any  *

        *             warranty, either expressed or implied.                  *

        *                                                                     *

        * REGISTERS: R13   - Base                                             *

        *            R12   - TCT address                                      *

        *            R2    - SYSPRINT DCB address                             *

        *            R3:R7 - Work registers                                   *

        *                                                                     *

        * ATTRIBUTES: AMODE 31                                                *

        *             RMODE 24                                                *

        *                                                                     *

        * TO COMPILE, LINK AND RUN THE PROGRAM :                              *

        *                                                                     *

        * //CTTSAMP JOB ...                                                   *

        * //ASM  EXEC IOAASM                                                  *

        * //        JCLLIB  ORDER=IOA.PROCLIB             <<<----- CHANGE     *

        * //        INCLUDE MEMBER=IOASET                                     *

        * //C.SYSIN    DD  DISP=SHR,DSN=&ILPREFA..SAMPLE(CTTSAM3)             *

        * //L.SYSLMOD  DD  DISP=SHR,DSN=YOUR.LOAD.LIBRARY <<<----- CHANGE     *

        * //L.AIOALOAD DD  DISP=SHR,DSN=&ILPREFA..AIOALOAD                    *

        * //L.SYSIN    DD *                                                   *

        *   INCLUDE AIOALOAD(CTTRSR)                                          *

        *   INCLUDE AIOALOAD(IOADBG)                                          *

        *   INCLUDE AIOALOAD(IOAMVN)                                          *

        *   INCLUDE AIOALOAD(CTMXAGR)                                         *

        *   MODE AMODE(31),RMODE(24)                                          *

        *   ENTRY CTTSAM3                                                     *

        *   NAME CTTSAM3(R)                                                   *

        * //*                                                                 *

        * //RUN EXEC PGM=CTTSAM3,COND=(0,NE)                                  *

        * //STEPLIB  DD DISP=SHR,DSN=YOUR.LOAD.LIBRARY    <<<----- CHANGE     *

        * //         DD DISP=SHR,DSN=&STEPLIB                                 *

        * //SYSPRINT DD SYSOUT=*                                              *

        * //                                                                  *

        *                                                                     *

        ***********************************************************************

        CTTSAM3  CSECT

        CTTSAM3  AMODE  31

        CTTSAM3  RMODE  24

                 BEGIN  EQUR=YES

                 CTTLEVEL CTTAPI,1.0.0

        *

                 XC    RC,RC                  Clear RC

                 SPACE 1

        ***********************************************************************

        *  GET ADDRESS OF REAL-TIME ENVIRONMENT TCT                           *

        ***********************************************************************

                 SPACE 1

                 CTTGTCT TCTADDR=ACTVTCT,TEST=ACT

                 LTR   R15,R15                TCT loaded ?

                 BNZ   TCTFAIL                N, exit

                 SPACE 1

        ***********************************************************************

        *  BUILD 'ON' COMMANDS BLOCK                                          *

        ***********************************************************************

                 SPACE 1

                 MVI   MYRSO,C' '             Clear RSO block

                 MVC   MYRSO+1(L'MYRSO-1),MYRSO

                 LA    R3,MYRSO

                 USING RSO,R3

                 MVC   RSODSN,MYDSN           Set 'ON DATASET' command

                 MVC   RSOVOL,MYVOL           Set 'ON VOLUME' command

                 DROP  R3

                 SPACE 1

        ***********************************************************************

        *  CALL RULE SEARCH API                                               *

        ***********************************************************************

                 SPACE 1

                 MVI   FUNCTYPE,C'I'          Extract 'DO' commands & rule info

                 L     R12,ACTVTCT            TCT address

                 USING TCT,R12

                 L     R2,TCTMCTA

                 USING MCT,R2

                 LA    R2,MCTTRCHD            IOA trace header

                 DROP  R2,R12                 was MCT, TCT

                 CALL  CTTRSR,(FUNCTYPE,(R12),MYRSO,EXPDT,DOOPT,(R2),STATUS,   X

                       RULEINFO),VL

                 C     R15,=F'4'              Any matching rules found ?

                 BE    NOMATCH                No, exit

                 BH    RSRFAIL                Rule search API failed ?

                 SPACE 1

        ***********************************************************************

        *  OPEN  SYSPRINT FILE                                                *

        ***********************************************************************

                 SPACE 1

                 OPEN  (SYSPRINT,OUTPUT)

                 LA    R2,SYSPRINT

                 USING IHADCB,R2

                 TM    DCBOFLGS,DCBOFOPN      Successfully opened ?

                 DROP  R2

                 BNO   OPENFAIL

                 SPACE 1

        ***********************************************************************

        *  PRINT OUT THE TRIGGERED 'DO' Statements                            *

        ***********************************************************************

                 SPACE 1

                 BAL   R14,PRTDO

                 SPACE 1

        ***********************************************************************

        *  PRINT OUT THE INFORMATION ORIGIN                                   *

        ***********************************************************************

                 SPACE 1

                 BAL   R14,PRTINFO

                 SPACE 1

        ***********************************************************************

        *  CLOSE SYSPRINT FILE                                                *

        ***********************************************************************

                 SPACE 1

                 CLOSE SYSPRINT

                 SPACE 1

        ***********************************************************************

        *  FREE RULE SEARCH API                                               *

        ***********************************************************************

                 SPACE 1

                 MVI   FUNCTYPE,C'F'          Free request

                 CALL  CTTRSR,(FUNCTYPE,(R12),0,0,DOOPT,STATUS,RULEINFO),VL

                 LTR   R15,R15                RLM/RSI freed ?

                 BNZ   RSRFAIL                Rule search API failed ?

                 B     RETURN                 Return

                 SPACE 1

        ***********************************************************************

        *  CHECK SELECTED 'DO' COMMANDS AND PRINT THEM OUT                    *

        ***********************************************************************

                 SPACE 1

        PRTDO    EQU   *

                 LR    R11,R14                Save return address

        ***

        *  Check 'DO' command (in fixed part of RLM)

        ***

                 L     R3,DOOPT               Get address of RLM block

                 USING RLM,R3

                 CLI   RLMDPSTK,RLMDPSBL      'DO STACK' command is blank ?

                 BE    CHKVLT                 Yes, go check 'DO VAULT'

                 MVC   STACKVAL(1),RLMDPSTK

                 IOAMODE 24,R=R8 

                 PUT   SYSPRINT,STACK         PRINT 'DO STACK = X'

                 IOAMODE RESTORE,R=R8 

        ***

        *  Check 'DO' command (in dynamic part of RLM)

        ***

        CHKVLT   EQU   *

                 ICM   R6,15,RLMDV#VL         Any 'DO VAULT' commands ?

                 BZ    CHKMORE                No, go check other 'DO' commands

                 L     R5,RLMDVADR            Yes, get address of vaults block

        VLTLOOP  MVC   VAULTNAM(L'RLMDVNAM),0(R5)

                 IOAMODE 24,R=R8 

                 PUT   SYSPRINT,VAULT         Print 'DO VAULT = <vault-name>'

                 IOAMODE RESTORE,R=R8 

                 LA    R5,RLMDLVLT(R5)        Skip to next vaulting pattern

                 BCT   R6,VLTLOOP

        CHKMORE  EQU   *

                 ICM   R5,15,RLMDOADR         Address of 'DO' block

                 BZ    NOMORE

                 L     R6,RLMD#IOA            No. of 'DO <IOA-cmd>' commands

                 DROP  R3

                 USING RLMRCRDS,R5

                 L     R6,RLMD#IOA            No. of 'DO <IOA-cmd>' commands

                 XR    R7,R7

        MOREDO   MVI   IOACMDV,C' '           Clear output record

                 MVC   IOACMDV+1(L'IOACMDV-1),IOACMDV

                 CLI   RLMDTYPE,RLMDCOND      Is it a 'DO CONDITION' command ?

                 BNE   SKIPNXT                No, skip to next 'DO' command

                 MVC   IOACMDV(L'RLMDCCND),RLMDCCND

                 IOAMODE 24,R=R8

                 PUT   SYSPRINT,IOACMD        Print the 'DO' command

                 IOAMODE RESTORE,R=R8

                 ICM   R7,B'0001',RLMLRCRD    Length of the 'DO' command

        SKIPNXT  AR    R5,R7                  Skip to next command

                 BCT   R6,MOREDO

                 DROP  R5

        NOMORE   EQU   *

                 BR    R11

                 SPACE 1

        ***********************************************************************

        *  PRINT OUT THE INFORMATION ORIGIN                                   *

        ***********************************************************************

                 SPACE 1

        PRTINFO  EQU   *

                 LR    R11,R14                Save return address

                 CLI   STACKVAL,C' '          DO STACK command retrieved ?

                 BE    NOSTACK                No, don't print its origin

        ***

        *  Print information about the origin of the 'DO STACK' command

        ***

                 L     R3,RULEINFO            Get address of RSI block

                 USING RSI,R3

                 MVC   RULENAME(L'RSISRLNM),RSISRLNM

                 LA    R4,RULENAM

                 IOAMODE 24,R=R8

                 PUT   SYSPRINT,(R4)          Print the rule name

                 IOAMODE RESTORE,R=R8

                 MVC   RULETABL(L'RSISTBNM),RSISTBNM

                 LA    R4,RULETAB

                 IOAMODE 24,R=R8

                 PUT   SYSPRINT,(R4)          Print the rule table

                 IOAMODE RESTORE,R=R8

                 MVC   RULELIBR(L'RSISTBLB),RSISTBLB

                 LA    R4,RULELIB

                 IOAMODE 24,R=R8

                 PUT   SYSPRINT,(R4)          Print the rule library

                 IOAMODE RESTORE,R=R8

        NOSTACK  EQU   *

                 BR    R11

                 SPACE 1

        ***********************************************************************

                 SPACE 1

        NOMATCH  EQU   *                      No rule was triggered

                 MVI   FUNCTYPE,C'F'          Free request

                 CALL  CTTRSR,(FUNCTYPE,(R12),0,0,DOOPT,STATUS,RULEINFO),VL

                 LA    R15,RC4

                 ST    R15,RC

                 B     RETURN

        *

        OPENFAIL EQU   *                      SYSPRINT Open failed

                 MVI   FUNCTYPE,C'F'          Free request

                 CALL  CTTRSR,(FUNCTYPE,(R12),0,0,DOOPT,STATUS,RULEINFO),VL

                 LA    R15,RC24

                 ST    R15,RC

                 B     RETURN

        *

        TCTFAIL  EQU   *                      TCT could not be obtained

                 LA    R15,RC28

                 ST    R15,RC

                 B     RETURN

        *

        RSRFAIL  EQU   *                      Rule search API has failed

                 ST    R15,RC

                 B     RETURN

        *

        RETURN   L     R15,RC                 Return to caller

                 BRTRN (15)

        *--------------------------------------------------------------------*

                 LTORG

                 EJECT

        *--------------------------------------------------------------------*

        *  COMMON BLOCK AREA                                                 *

        *--------------------------------------------------------------------*

        COMBLOCK DS    0D

        *

        *  Constants

        *

        RC4      EQU   4

        RC24     EQU   24

        RC28     EQU   28

        *

        RC       DS    F                      Routine's return code

        ACTVTCT  DS    A                      TCT address

        MYDSN    DC    CL44'N89.CHKIN.TRY'

        MYVOL    DC    CL6'CHKIN0'

        DOSTKFND DS    C                      DO STACK command found ? (Y/N)

        *---------------------------------------------------------------------*

        FUNCTYPE DS    C                      Function type

        MYRSO    DS    XL(RSOLEN)             'ON' statements

        DOOPT    DC    A(0)                   Address of RLM block

        RULEINFO DC    A(0)                   Address of RSI block

        EXPDT    DC    F'0'                   JCL expdt

        STATUS   DC    X'00'                  Status flag 

        *---------------------------------------------------------------------*

        SYSPRINT DCB   DDNAME=SYSPRINT,DSORG=PS,MACRF=PM,RECFM=FB,LRECL=121

        *---------------------------------------------------------------------*

        IOACMD   DC    CL14'DO CONDITION: '

        IOACMDV  DS    CL107' '

        STACK    DC    CL11'DO STACK = '

        STACKVAL DS    CL110

        VAULT    DC    CL11'DO VAULT = '

        VAULTNAM DS    CL110

        RULENAM  DC    CL37'DO STACK command taken from rule:    '

        RULENAME DS    CL84

        RULETAB  DC    CL37'                       from table:   '

        RULETABL DS    CL84

        RULELIB  DC    CL37'                       from library: '

        RULELIBR DS    CL84

        *---------------------------------------------------------------------*

                 EJECT

                 IEFJSCVT                     Macros for CTTGTCT

                 IEFJESCT

                 COPY  CTTSSVT

        CVT      CVT   DSECT=YES,PREFIX=YES

        TCT      DSECT

                 COPY  CTTTCT                 TCT  layout

        MCT      DSECT

                 COPY  IOAMCT                 MCT  layout

        *---------------------------------------------------------------------*

                 EJECT

        RSO      DSECT                        'ON' statements

                 COPY  CTTRSO

        RLM      DSECT                        'DO' statements

                 COPY  CTTRLM

        RSI      DSECT                        Rules information

                 COPY  CTTRSI

        RLD      DSECT                        Equates for CTTRLM

                 COPY  CTTRLD

        RLX      DSECT                        Equates for CTTRLM

                 COPY  CTTRLX

                 DCBD  DSORG=PS

        *---------------------------------------------------------------------*

                 END

Parent Topic

Rule Search API