IBM Operational Decision Manager メモ - (5) z/OS上での環境セットアップ

# はじめに
ここまでの記事ではLinux上にODMサーバーを構築する手順を見てきましたが、今回はz/OS上にODMサーバーを構築してみます。ここでは、RES(Rule Execution Server)をz/OS上に立てることを目標にします。z/OS上のRESをzRESと呼ぶことにします。zRES上のルールは、COBOLのバッチプログラム、または、CICS上のCOBOLプログラムから利用される想定とします。
今回の手順ではz/OS上にDecision Centerは構築しません。(Decision Centerはオープンプラットフォームのものを共有利用できます。つまりLinux上のDcision Centerからz/OS上のzRESにルールをデプロイすることができます。)

※関連記事として「[zODM構成作業の全体像](https://qiita.com/tomotagwork/items/fdda485b28c55edae6e6#zodm%E6%A7%8B%E6%88%90%E4%BD%9C%E6%A5%AD%E3%81%AE%E5%85%A8%E4%BD%93%E5%83%8F)」というのを記載しています。そちらも合わせて参照いただくとイメージしやすいかと思います。


## 関連記事

[IBM Operational Decision Manager メモ - (1) 概要、Linuxへのインストール](https://qiita.com/tomotagwork/items/2bdcc13cc5a896b6a3a1)
[IBM Operational Decision Manager メモ - (2) ルール開発から実行までの流れ](https://qiita.com/tomotagwork/items/446975617acfdb0eda5f)
[IBM Operational Decision Manager メモ - (3) Decision Center利用の流れ](https://qiita.com/tomotagwork/items/5e8b1efbe0072cf5af6b)
[IBM Operational Decision Manager メモ - (4) Linux上での環境セットアップ](https://qiita.com/tomotagwork/items/dd9dc49ed6a67ff876bb)
[IBM Operational Decision Manager メモ - (5) z/OS上での環境セットアップ](https://qiita.com/tomotagwork/items/73ceaf84fb89b5d2af7b)
[IBM Operational Decision Manager メモ - (6) z/OS上でのルール呼び出し](https://qiita.com/tomotagwork/items/577895e05f9ec5e40c06)
[IBM Operational Decision Manager メモ - (7) zODM環境補足](https://qiita.com/tomotagwork/items/fdda485b28c55edae6e6)


# 環境構築
今回はZD&T(z/OS V2.4)上にzODM V8.11環境を作ることにします。z/OS、Db2、CICSはADCDに含まれて提供されるものをそのまま利用する想定です。

z/OS V2.4 (ADCD May 2021)
zODM V8.11
Db2 V12
CICS TS V5.6

## 全体像

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/132331/e05ee860-d0aa-4b70-ea01-e367ab1f6fe5.png)

上の図の赤枠部分を構築していくイメージです。
最終的に、サンプルのCOBOLバッチ、CICS-COBOLアプリケーションからzRES上のルール呼び出しができるところまでを確認したいと思います。

z/OS版のODMの場合、分散系のODMとは構成上取り得るトポロジーが異なります。今回z/OS上ではJVM上でRESを稼働させる構成を選択しています。z/OS版では複数のRESを1つのServer Groupと呼ばれる単位で扱うことができます。これは複数のRESを1つのサーバーのように見立ててグループ中の1つのRESが落ちても透過的に別のRESに振り分ける機能を提供してくれます。つまりzODMが可用性のための仕組みを提供してくれています。
(分散系ODMで冗長構成を行う場合はWASのクラスターなどを利用することになります。)

RES Console(ブラウザの画面を提供する管理機能)はLiberty上で稼働させる必要がありますのでLibertyサーバーを立ててその上にRES Console用のアプリをデプロイして稼働させることになります。z/OS上でLibertyを稼働させる場合セキュリティの管理を行う際にLiberty Angelプロセスというサーバーが必要になりますのでそちらも構成することになります。
実際にルールを稼働させるzRESインスタンスは冗長化のため2つ構成することにします。
(※1つのServer Groupには1～32インスタンスまで含めることが可能)

## ODMインストール
ODMのインストールは基本的にSMP/Eを使用してProgram Directoryの記述に従ってインストールすることになるので、ここでは詳細は省略します。
主に以下のようなパラメーター指定でインストールしています。

```
-SHLQUAL-=ODM811
-GZONECSI-=ODM811.GZONE.CSI
-TZNAME-=TZONE
-DZNAME-=DZONE
-THLQUAL-=ODM811.TLIB
-DHLQUAL-=ODM811.DLIB
-ZFSNAMEA-=ODM811.ZFS
-PATHPREFIX-=
```

## ODMセットアップ

基本的に以下のマニュアルの手順に従ってセットアップしていきます。
参考: [IBM Operational Decision Manager for z/OS 8.11.0 - Configuring](https://www.ibm.com/docs/en/odm/8.11.0?topic=odmz8-configuring)

### Step 1: Authorizing the load library

xxx.SHBRAUTHについてAPF登録を行います。

動的登録例

```
SETPROG APF,ADD,DSN=ODM811.TLIB.SHBRAUTH,VOLUME=ODM003
```

静的登録例
ADCD.Z24D.PARMLIB(PROGAC)に以下を追加 (CICS用のPROGxxに相乗り)

```xxx:ADCD.Z24D.PARMLIB(PROGAC)
...
/* ODM 8.11 */
APF ADD
    DSNAME(ODM811.TLIB.SHBRAUTH)                         VOLUME(ODM003)
```

<details><summary><font color="blue">参考: APF確認</font></summary><div>

```
S0W1      2022025  19:10:39.32            -d prog,apf
S0W1      2022025  19:10:39.35             CSV450I 19.10.39 PROG,APF DISPLAY 001
                                           FORMAT=DYNAMIC
                                           ENTRY VOLUME DSNAME
                                              1  D4RES1 SYS1.LINKLIB
                                              2  D4RES1 SYS1.SVCLIB
                                              3  D4RES1 SYS1.SHASLNKE
                                              4  D4RES1 SYS1.SIEAMIGE
                                              5  D4RES1 SYS1.MIGLIB
                                              6  D4RES1 SYS1.SERBLINK
                                              7  D4RES1 SYS1.SIEALNKE
                                              8  D4RES1 SYS1.CSSLIB
                                              9  D4RES1 GIM.SGIMLMD0
                                             10  D4RES1 SYS1.SHASMIG
                                             11  D4RES2 CSF.SCSFMOD0
                                             12  D4RES2 ISF.SISFLOAD
                                             13  D4RES1 SYS1.SBDTCMD
                                             14  D4RES1 SYS1.SBDTLIB
                                             15  D4CFG1 USER.Z24D.LINKLIB
                                             16  D4CFG1 FEU.Z24D.LINKLIB
                                             17  D4SYS1 ADCD.Z24D.LINKLIB
                                             18  D4CFG1 USER.Z24D.VTAMLIB
                                             19  D4CFG1 FEU.Z24D.VTAMLIB
                                             20  D4SYS1 ADCD.Z24D.VTAMLIB
                                             21  D4RES1 FFST.SEPWMOD2
                                             22  D4RES1 FFST.SEPWMOD4
                                             23  D4RES2 NFS.NFSLIBE
                                             24  D4RES1 TCPIP.SEZATCP
                                             25  D4RES1 TCPIP.SEZALNK2
                                             26  D4RES2 TCPIP.SEZADSIL
                                             27  D4RES1 TCPIP.SEZALPA
                                             28  D4RES1 TCPIP.SEZALOAD
                                             29  D4RES1 ISP.SISPLOAD
                                             30  D4RES1 SYS1.VTAMLIB
                                             31  D4RES1 SYS1.SISTCLIB
                                             32  D4RES2 CEE.SCEERUN
                                             33  D4RES2 CEE.SCEERUN2
                                             34  D4RES1 CBC.SCLBDLL
                                             35  D4RES1 CBC.SCLBDLL2
                                             36  D4PRD2 IGY630.SIGYCOMP
                                             37  D4PRD1 EQAF00.SEQAMOD
                                             38  D4PRD1 EQAF00.SEQABMOD
                                             39  D4PRD1 EQAF00.SEQAAUTH
                                             40  D4PRD1 FAN140.SEAGLPA
                                             41  D4PRD1 DIT130.SDITMOD1
                                             42  *SMS*  EQAF00.DB2SP.SCEERUN
                                             43  D4BLZ1 BLZ701.SBLZAUTH
                                             44  D4BLZ1 BLZ701.SBLZLOAD
                                             45  D4PRD1 FELE20.SFEKAUTH
                                             46  D4PRD1 FELE20.SFELLPA
                                             47  D4PRD1 FEUD00.SFEUAUTH
                                             48  D4C551 DFH550.CICS.SDFHEXCI
                                             49  D4C551 DFH550.CICS.SDFHAUTH
                                             50  D4C551 DFH550.CPSM.SEYUAUTH
                                             51  D4C551 DFH550.CICS.SDFHLPA
                                             52  D4C551 DFH550.CPSM.SEYULPA
                                             53  D4C551 DFH550.CICS.SDFHLINK
                                             54  D4C551 DFH550.CPSM.SEYULINK
                                             55  D4C551 DFH550.SDFHLIC
                                             56  D4C560 DFH560.CICS.SDFHAUTH
                                             57  D4C560 DFH560.CICS.SDFHLINK
                                             58  D4C560 DFH560.CICS.SDFHLPA
                                             59  D4C560 DFH560.CPSM.SEYUAUTH
                                             60  D4C560 DFH560.CPSM.SEYULPA
                                             61  D4C560 DFH560.CPSM.SEYULINK
                                             62  D4C560 DFH560.CICS.SDFHEXCI
                                             63  D4C560 DFH560.SDFHLIC
                                             64  D4DBB1 DSNB10.SDSNLINK
                                             65  D4DBB1 DSNB10.DBBG.SDSNEXIT
                                             66  D4DBB1 DSNB10.SDSNLOD2
                                             67  D4DBB1 DSNB10.SDSNLOAD
                                             68  D4DBB1 DSNB10.SDXRRESL
                                             69  D4DBB1 ADBB20.SADBLINK
                                             70  D4DBC1 DSNC10.SDSNLINK
                                             71  D4DBC1 DSNC10.DBCG.SDSNEXIT
                                             72  D4DBC1 DSNC10.SDSNLOAD
                                             73  D4DBC1 DSNC10.SDSNLOD2
                                             74  D4DBC1 DSNC10.SDXRRESL
                                             75  D4DBC1 ADBC10.SADBLINK
                                             76  D4PRD2 AQT750.NEW.SAQTMOD
                                             77  D4IMF1 DFSF10.SDXRRESL
                                             78  D4IMF1 DFSF10.SDFSRESL
                                             79  D4IMF1 DFSF10.MODBLKS
                                             80  D4IMF1 DFSF10.MODBLKSA
                                             81  D4IMF1 DFSF10.MODBLKSB
                                             82  D4IMF1 DFSF10.VTAMLIB
                                             83  D4IMF1 DFSF10.USER.SDFSRESL
                                             84  D4IME1 DFSE10.SDXRRESL
                                             85  D4IME1 DFSE10.SDFSRESL
                                             86  D4IME1 DFSE10.MODBLKS
                                             87  D4IME1 DFSE10.MODBLKSA
                                             88  D4IME1 DFSE10.MODBLKSB
                                             89  D4IME1 DFSE10.VTAMLIB
                                             90  D4IME1 DFSE10.USER.SDFSRESL
                                             91  D4PRD4 CSQ920.SCSQLINK
                                             92  D4PRD4 CSQ920.SCSQAUTH
                                             93  D4PRD4 CSQ920.CSQ9.SCSQAUTH
                                             94  D4PRD4 CSQ920.SCSQSNLE
                                             95  D4PRD4 CSQ920.SCSQANLE
                                             96  D4PRD4 CSQ920.SCSQMVR1
                                             97  D4ZWE1 ZWE100.SZWEAUTH
                                             98  D4PRD3 NET630.CNMLINK
                                             99  D4PRD3 NET630.SCNMLNKN
                                            100  D4PRD3 NET630.SCNMLNK1
                                            101  D4PRD3 NET630.SCNMLPA1
                                            102  D4PRD3 NET630.SAQNLINK
                                            103  ODM003 ODM811.TLIB.SHBRAUTH

```

</div></details>


### Step 2: Choosing your topology

ここでは"Topology 1: zRule Execution Server for z/OS group with a shared console" の構成を取ることにします。

### Step 3: Customizing the z/OS configuration and runtime variables

`ODM811.TLIB.SHBRPARM(HBRINST)` を `ODM811.TLIB.SHBRPARM(@BRINST)` にコピーして編集します。
ここでは以下の項目のパラメーターについて、環境に応じた値を設定します。

- Variables to be customized for Rules on z/OS
- Variables to be customized for DB2
- Variables to be customized for CICS and CICS JVM Server

※それ以外は使用しないのでデフォルト設定のまま放置でOK

参考: [z/OS configuration variables](https://www.ibm.com/docs/en/odm/8.11.0?topic=configuring-zos-configuration-variables)

```xxx:ODM811.TLIB.SHBRPARM(@BRINST)
********************************************************************
*
* <copyright
* notice="lm-source-program"
* pids="5655-Y31"
* years="2009,2021"
* crc="2779074398" >
* Licensed Materials - Property of IBM
*
* 5655-Y31
*
* (C) Copyright IBM Corp. 2009, 2021 All Rights Reserved.
*
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with
* IBM Corp.
* </copyright>
*
********************************************************************
* Variables are in column 1.
* Substitution values are in column 2.
* The HBRUUPTI job replaces the variables in
* column 1 with the values you specify in column 2.
*
* See the IBM Documentation topic "JCL and runtime variables" for
* detailed information about these variables.
*
* NB: If HBRWORKPATH is greater than 35 characters you will need to
* manually update the JCL where ever this value is inserted. For
* more information please refer to the IBM Documentation.
********************************************************************

********************************************************************
* Variables to be customized for Rules on z/OS
********************************************************************
 ++HBRHLQ++                ODM811.TLIB
 ++HBRINSTPATH++           /usr/lpp/zDM/V8R11ML
 ++HBRWORKPATH++           /var/zDM/V8R11ML
 ++HBRJAVAHOME++           /usr/lpp/java/J8.0_64
 ++HBRPORT++               34114
 ++HBRSECUREPORT++         24114
 ++HBRCONSOLECOMPORT++     44114
 ++HBRCONSOLECOMHOST++     localhost
 ++HBRWLPANGELNAME++       O8B0ANGL
 ++HBRWLPSTRICTTRANSPORT++ false
 ++HBRSSLKEYSTORE++        JAVA
 ++HBRLANG++               En_US
 ++HBRTRACELEVEL++         WARNING
 ++HBRPERSISTENCETYPE++    DB2
 ++HBRIFAUSAGE++           YES
 ++HBRSMFST100++           YES
 ++HBRPRINTWTO++           YES
 ++HBRARMENABLED++         NO
 ++HBRLOGTIMEOUTS++        NO
 ++HBRLOGLONGEXECTIME++    0
 ++HBRLOGLONGEXECPARMS++   NO

********************************************************************
* Variables to be customized for CICS and CICS JVM Server
********************************************************************
 ++CICSLIST++             HBRLIST

********************************************************************
* Variables to be customized for CICS JVM Server Only
********************************************************************
 ++JDBCPLAN++             DSNJCC

********************************************************************
* Variables to be customized for IMS
********************************************************************
 ++IMSHLQ++               IMS.V12.DBDC
 ++IMSREGID++             IM2A
 ++IMSREGHLQ++            IMSDATA.IM12A

********************************************************************
* Variables to be customized for DB2
********************************************************************
 ++DB2HLQ++               DSNC10
 ++DB2RUNLIB++            DSNC10.DBCG.RUNLIB.LOAD
 ++DB2SUBSYSTEM++         DBCG
 ++DB2LOCATION++          DALLASC
 ++DB2VCAT++              DBODM
 ++DB2ADMIN++             IBMUSER
 ++DB2SCHEMA++            ODM811
 ++DBCONTYPE++            4
 ++RESDATABASE++          RESDB811
 ++RTSDATABASE++          RTSDB811
 ++RESSTOGROUP++          RESSTG811
 ++RTSSTOGROUP++          RTSSTG811
 ++DB2TABLEBP++           BP0
 ++DB2INDEXBP++           BP0
 ++DB2LOBBP++             BP3
 ++DB2SAMPLEPROGRAM++     DSNTEP2
 ++DB2SAMPLEPROGRAMPLAN++ DSNTEP12
 ++DB2BP4K++              BP0
 ++DB2BP8K++              BP8K0
 ++DB2BP32K++             BP32K
 ++DB2USER++              IBMUSER
 ++DB2PSWD++              SYS1
 ++DB2GROUP++             SYS1
 ++DB2SERVNAME++          localhost
 ++DB2PORT++              5040
 ++DB2JARLOCN++           /usr/lpp/db2c10/jdbc/classes
 ++DB2NATIVELOC++         /usr/lpp/db2c10/jdbc/lib

********************************************************************
* Variables to be customized for WebSphere Liberty Profile
* values also taken from the DB2 section above
********************************************************************
 ++WLPSAFPREF++           BBGZDFLT
 ++WLPINSTDIR++           /was/Liberty
 ++WLPUSERDIR++           /Liberty
 ++WLPSERVER++            odmserv
 ++WLPANGELNAME++
 ++WLPPORT++              9111
 ++WLPSECUREPORT++        9443
 ++WLPTYPE++              STD
 ++WLPVERSION++           18

********************************************************************
* Variables to be customized for WOLA Liberty script parameters
********************************************************************
 ++HBRWOLALOADLIB++       USER.WOLA.LOADLIB.WAS8
 ++HBRWOLANODE++          NIL1
 ++HBRWOLASERVER++        HBRWOLA


********************************************************************
* Variables to be customized for SMF report sample programs
********************************************************************
 ++PSMFDS++               SYS1.S0W1.MAN1
 ++SSMFDS++               SYS1.S0W1.MAN2
 ++CSVPATH++              /var/zDM/V8R11ML/08B0

********************************************************************
* Variables to be customized for use of BAI for emitting events
*
* HBRBAISASLJAASCONFIGMODULE is automatically prefixed with
* org.apache.kafka.common.security.
********************************************************************
++HBRBAIENABLE++                 FALSE
++HBRBAITOPIC++                  bai-odm-z-example
++HBRBAIBOOTSTRAPSERVERS++       bootstrap.example.com
++HBRBAISECURITYPROTOCOL++       SASL_SSL
++HBRBAISSLTRUSTSTORELOCATION++  /u/rules/truststore.jks
++HBRBAISSLTRUSTSTOREPASSWORD++  password
++HBRBAISSLTRUSTSTOREPROTOCOL++  TLSv1.2
++HBRBAISASLMECHANISM++          PLAIN
++HBRBAISASLJAASCONFIGMODULE++   plain.PlainLoginModule
++HBRBAISASLJAASCONFIGOPTIONS++  required
++HBRBAISASLJAASCONFIGUSERNAME++ kafkauser
++HBRBAISASLJAASCONFIGPASSWORD++ kafkapass
```

### Step 4: Customizing the control statements for your topology

`ODM811.TLIB.SHBRPARM(HBRCNTL)` を `ODM811.TLIB.SHBRPARM(@BRCNTL)` にコピーして編集します。
先に示した全体像に従い、zRES ConsoleとしてO8B0, zRESとしてO8B1,O8B2を構成します。また、CICSからRESアクセスする際に必要な定義を追加する先のCICS CSD情報などを設定します。

```xxx:ODM811.TLIB.SHBRPARM(@BRCNTL)
********************************************************************
* Use the following statements to create the working datasets for the
* zRule Execution Server execution environment. This example shows
* how to create Topology 1.
********************************************************************
CREATE ZRES HBRMODE=CONSOLE
            HBRSSID=O8B0
            HBRWORKDS=ODM811.WORK.O8B0

CREATE ZRES HBRMODE=RULE
            HBRSSID=O8B1
            HBRWORKDS=ODM811.WORK.O8B1

CREATE ZRES HBRMODE=RULE
            HBRSSID=O8B2
            HBRWORKDS=ODM811.WORK.O8B2


********************************************************************
* Use the following statements to create the working datasets for the
* CICS rule-owning / application-owning region execution environment.
* This example shows how to create Topology 3.
********************************************************************
CREATE CICS HBRWORKDS=ODM811.WORK.CICS
            CICSHLQ=DFH560.CICS
            CICSCSDDSN=DFH560.CICS.DFHCSD
```

### Step 5: Creating the working data sets

`ODM811.TLIB.SHBRJCL(HBRUUPTI)`を適当な場所にコピーして編集(まだSubmitはしない)

```JCL:HBRUUPTI.jcl
//HBRUUPTI JOB MSGCLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//**********************************************************************
//         SET HBRHLQ=ODM811.TLIB
//HBRUUPTI EXEC PGM=IKJEFT01,REGION=2M,DYNAMNBR=99
//SYSPROC  DD DISP=SHR,DSN=&HBRHLQ..SHBREXEC
//INCNTRL  DD DISP=SHR,DSN=&HBRHLQ..SHBRPARM(@BRCTRL)
//INLINES  DD DISP=SHR,DSN=&HBRHLQ..SHBRPARM(@BRINST)
//SYSTSIN  DD *
 %@BRUUPTE
//SYSTSPRT DD SYSOUT=*
```

上のJCLを流すと、REXXスクリプトにより作業用のデータセットが作成されることになりますが、今回の環境はSMS管理ではないDASDを使用する想定のため、デフォルトだとWork Volumeにアロケートされてしまします。明示的にVOL指定したいのでREXXスクリプトを編集します。

`ODM811.TLIB.SHBREXEC(HBRUUPTE)`を`ODM811.TLIB.SHBREXEC(@BRUUPTE)`にコピーし、データセットアロケートの部分にVOLUME, STORCLASS指定を追記します。

```
...
*AllocateTargetLib:
/**********************************************************************/
/*                                                                    */
/* Allocate the new target dataset if necessary                       */
/*                                                                    */
/**********************************************************************/
   If SYSDSN("'"TargetLib"'") <> 'OK'
   Then Do
      "ALLOCATE DA('"TargetLib"') LIKE('"SourceLib"') VOLUME("ODM003") 
       STORCLAS("SCNOSMS")"
      If rc <> 0
      Then Do
         Call Report "(ERROR) ALLOCATE DA('"TargetLib"') LIKE('"SourceLib"')",
            "gave return code" rx, errorNo
         Signal Terminate
      End /* of If rc <> 0 Then Do                   */
   End    /* of If SYSDSN ... Then Do                */
...
```

※ALLOCATEステートメントで、VOLUME, STORCLASを明示指定する方法
参考: [ALLOCATE command syntax](https://www.ibm.com/docs/en/zos/2.4.0?topic=command-allocate-syntax)

HBRUUPTI.jclをサブミットすると、以下のデータセットが作成されます。

```
ODM811.WORK.CICS.SHBRJCL                                       ODM003
ODM811.WORK.CICS.SHBRPARM                                      ODM003
ODM811.WORK.O8B0.SHBRJCL                                       ODM003
ODM811.WORK.O8B0.SHBRPARM                                      ODM003
ODM811.WORK.O8B0.SHBRPROC                                      ODM003
ODM811.WORK.O8B1.SHBRJCL                                       ODM003
ODM811.WORK.O8B1.SHBRPARM                                      ODM003
ODM811.WORK.O8B1.SHBRPROC                                      ODM003
ODM811.WORK.O8B2.SHBRJCL                                       ODM003
ODM811.WORK.O8B2.SHBRPARM                                      ODM003
ODM811.WORK.O8B2.SHBRPROC                                      ODM003

```

### Step 6: Creating the working directory

ここのステップではUSS上の/var/zDM/V8R11ML以下にディレクトリが作成されることになります。ここはファイルシステムを分けておきたいので、事前にzFS作成してマウントしておきます。

```
//ZFSJOB  JOB CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//***************************************************************
//CREATE  EXEC PGM=IDCAMS,REGION=64M,COND=(0,LT)
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  DEFINE -
       CLUSTER -
         ( -
             NAME(ODM811.ZFS.VAR) -
             LINEAR -
             MEGABYTES(150 50) -
             SHAREOPTIONS(3) -
             VOLUMES(ODM003) -
             STORAGECLASS(SCNOSMS) -
         )
/*
//*
// SET HFSDSN='ODM811.ZFS.VAR'
//FORMAT   EXEC PGM=IOEAGFMT,REGION=64M,COND=(0,LT),
// PARM='-aggregate &HFSDSN -compat'
//SYSPRINT DD SYSOUT=*
//STDOUT   DD SYSOUT=*
//STDERR   DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//CEEDUMP  DD SYSOUT=*
//*
//MOUNT    EXEC PGM=IKJEFT01,REGION=64M,COND=(0,LT)
//SYSTSPRT DD   SYSOUT=*
//SYSTSIN  DD   *
  PROFILE MSGID WTPMSG
  MKDIR  '/var/zDM/V8R11ML' +
       MODE(7,5,5)
  MOUNT +
    FILESYSTEM('ODM811.ZFS.VAR') +
    MOUNTPOINT('/var/zDM/V8R11ML') +
    TYPE(ZFS) +
    MODE(RDWR)
/*
```

IPL後も自動マウントされるようにBPXPRMxxにも設定追加しておきます。

```xxx:FEU.Z24D.PARMLIB(BPXPRM01)
MOUNT    FILESYSTEM('IODM811.ZFS')
         TYPE(ZFS)
         MODE(RDWR) NOAUTOMOVE
         MOUNTPOINT('/usr/lpp/zDM/V8R11ML')

MOUNT    FILESYSTEM('ODM811.ZFS.VAR')
         TYPE(ZFS)
         MODE(RDWR) NOAUTOMOVE
         MOUNTPOINT('/var/zDM/V8R11ML')
```

ODM811.WORK.O8B0.SHBRJCL(HBRCRTI)に生成されたJCLを実行します。

```jcl:ODM811.WORK.O8B0.SHBRJCL(HBRCRTI)
//HBRCRTI JOB MSGCLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//**********************************************************************
//HBRCRTI EXEC PGM=IKJEFT01,REGION=0M,TIME=NOLIMIT
//SYSTSPRT DD  SYSOUT=*
//STDOUT   DD  SYSOUT=*
//STDERR   DD  SYSOUT=*
//SYSTSIN  DD  *
  BPXBATCH SH . +
  /usr/lpp/zDM/V8R11ML+
  /zexecutionserver/bin/hbrcrtin.sh +
  /usr/lpp/zDM/V8R11ML +
  /var/zDM/V8R11ML
/*
```

/var/zDM/V8R11MLに以下ディレクトリが作成されます。

```
TAGUCHI:/S0W1/var/zDM/V8R11ML: >ls -laR .

.:
total 48
drwxrwxrwx   8 OMVSKERN SYS1        8192 Jan 26 04:39 .
drwxrwxrwx   3 OMVSKERN OMVSGRP     8192 Jan 26 02:10 ..
drwxrwxrwx   5 OMVSKERN SYS1        8192 Jan 26 04:39 config
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 logs
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 res_data
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 res_xom
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 servers
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 tmp

./config:
total 50
drwxrwxrwx   5 OMVSKERN SYS1        8192 Jan 26 04:39 .
drwxrwxrwx   8 OMVSKERN SYS1        8192 Jan 26 04:39 ..
-rw-rw-rw-   1 OMVSKERN SYS1           9 Jan 26 04:39 HBR_CONFIG_OK
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 console
drwxrwxrwx   2 OMVSKERN SYS1        8192 Jan 26 04:39 res
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 wlp

./config/console:
total 16
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 .
drwxrwxrwx   5 OMVSKERN SYS1        8192 Jan 26 04:39 ..

./config/res:
total 96
drwxrwxrwx   2 OMVSKERN SYS1        8192 Jan 26 04:39 .
drwxrwxrwx   5 OMVSKERN SYS1        8192 Jan 26 04:39 ..
-rwxrwxrwx   1 OMVSKERN SYS1       28495 Jan 26 04:39 ra.xml

./config/wlp:
total 16
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 .
drwxrwxrwx   5 OMVSKERN SYS1        8192 Jan 26 04:39 ..

./logs:
total 16
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 .
drwxrwxrwx   8 OMVSKERN SYS1        8192 Jan 26 04:39 ..

./res_data:
total 16
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 .
drwxrwxrwx   8 OMVSKERN SYS1        8192 Jan 26 04:39 ..

./res_xom:
total 16
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 .
drwxrwxrwx   8 OMVSKERN SYS1        8192 Jan 26 04:39 ..

./servers:
total 16
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 .
drwxrwxrwx   8 OMVSKERN SYS1        8192 Jan 26 04:39 ..

./tmp:
total 16
drwxrwxrwx   2 OMVSKERN SYS1           0 Jan 26 04:39 .
drwxrwxrwx   8 OMVSKERN SYS1        8192 Jan 26 04:39 ..
```

### Step 7: Configuring a DB2 persistence layer 

#### Creating a DB2 database for your rules runtime persistence layer

ここではDb2関連のオブジェクト(STORAGE GROUP、DATABASE、TABLESPACEなど)を作成していくことになりますが、Step3で パラメーター ++DB2VCAT++ で指定したHLQのVSAMファイルが作成されることになります。
そのため、事前にUCAT、ALIASを作成しておく必要があります。

※ちなみに、DB関連のデータセットは、VCATをHLQとして、xxx.DSNDBC.xxx, xxx.DSNDBD.xxx というデータセット名で作成されます。ZD&TのSMSのACS Routineでは、これらのデータセット名はSCDB2というStorageClassが割り当てられるようになっています。それに合わせてUCAT作成時にはSTORAGECLASS(SCDB2)を指定することにします。

UCAT作成

```
//DEFUCAT JOB ,CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//*---------------------------------------------------------------
//* DEFINE USER CATALOG
//*---------------------------------------------------------------
//DEFINE EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
 DEFINE USERCATALOG(NAME(UCAT.DBODM) -
 CYLINDERS(5 2) -
 STORAGECLASS(SCDB2) -
 ICFCATALOG )
/* 
```

ALIAS作成

```
//DEFALIAS JOB ,CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//*---------------------------------------------------------------
//* DEFINE USER CATALOG
//*---------------------------------------------------------------
//DEFINE EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
 DEF ALIAS(NAME(DBODM) REL(UCAT.DBODM)) -
 CATALOG(CATALOG.Z24D.MASTER)
/* 
```

UCAT、ALIASが作成されたら以下のJCLを実行していきます。
ODM811.WORK.O8B0.SHBRJCL(HBRDSCDB)
ODM811.WORK.O8B0.SHBRJCL(HBRDSXOM)
ODM811.WORK.O8B0.SHBRJCL(HBRDSCTR)

<font color="red">注意</font>: これらのJCLは、Step3で編集したパラメーター`ODM81.TLIB.SHBRPARM(@BRINST)`を元に、Step5のJCLから実行されるREXXで生成されます。ただし、いずれもSTEPLIBに指定されているSDNEXITのデータセット名は環境に合わせて手動で変更する必要がありました。(今回はZD&Tで提供されているDb2をそのまま使用しており、そのネーミングルールがあまり一般的では無いのかもしれませんが...)	

```
...
    //STEPLIB  DD DISP=SHR,DSN=DSNC10.DBCG.SDSNEXIT
	//         DD DISP=SHR,DSN=DSNC10.SDSNLOAD
	//         DD DISP=SHR,DSN=DSNC10.SDSNLOD2
	//         DD DISP=SHR,DSN=DSNC10.DBCG.RUNLIB.LOAD
...
```

上のJCL実行すると、以下のデータセットが作成されます。

```
DBODM                                                          *ALIAS 
DBODM.DSNDBC.RESDB811.AUXRRULE.I0001.A001                      *VSAM* 
DBODM.DSNDBC.RESDB811.AUXRXOMR.I0001.A001                      *VSAM* 
DBODM.DSNDBC.RESDB811.AUXSETRE.I0001.A001                      *VSAM* 
DBODM.DSNDBC.RESDB811.RUAPP.I0001.A001                         *VSAM* 
DBODM.DSNDBC.RESDB811.RUAPPPRO.I0001.A001                      *VSAM* 
DBODM.DSNDBC.RESDB811.RUSET.I0001.A001                         *VSAM* 
DBODM.DSNDBC.RESDB811.RUSETPRO.I0001.A001                      *VSAM* 
DBODM.DSNDBC.RESDB811.RUSETRES.I0001.A001                      *VSAM* 
DBODM.DSNDBC.RESDB811.XOMLIB.I0001.A001                        *VSAM* 
DBODM.DSNDBC.RESDB811.XOMLIBVS.I0001.A001                      *VSAM* 
DBODM.DSNDBC.RESDB811.XOMRES.I0001.A001                        *VSAM* 
DBODM.DSNDBC.RESDB811.XRTS.I0001.A001                          *VSAM* 
DBODM.DSNDBD.RESDB811.AUXRRULE.I0001.A001                      D4USR1 
DBODM.DSNDBD.RESDB811.AUXRXOMR.I0001.A001                      D4DBC2 
DBODM.DSNDBD.RESDB811.AUXSETRE.I0001.A001                      D4USR1 
DBODM.DSNDBD.RESDB811.RUAPP.I0001.A001                         D4DBC2 
DBODM.DSNDBD.RESDB811.RUAPPPRO.I0001.A001                      D4DBC2
DBODM.DSNDBD.RESDB811.RUSET.I0001.A001                         D4USR1
DBODM.DSNDBD.RESDB811.RUSETPRO.I0001.A001                      D4USR1
DBODM.DSNDBD.RESDB811.RUSETRES.I0001.A001                      D4DBC2
DBODM.DSNDBD.RESDB811.XOMLIB.I0001.A001                        D4DBC2
DBODM.DSNDBD.RESDB811.XOMLIBVS.I0001.A001                      D4USR1
DBODM.DSNDBD.RESDB811.XOMRES.I0001.A001                        D4USR1
DBODM.DSNDBD.RESDB811.XRTS.I0001.A001                          D4DBC2
```

参考: 実行したJCLは以下の通り

<details><summary><font color="blue">HBRDSCDB</font></summary><div>

```
//HBRDSCDB JOB MSGCLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//**********************************************************************
//* <copyright                                                         *
//* notice="lm-source-program"                                         *
//* pids="5655-Y31"                                                    *
//* years="2009,2019"                                                  *
//* crc="4113179558" >                                                 *
//* Licensed Materials - Property of IBM                               *
//*                                                                    *
//* 5655-Y31                                                           *
//*                                                                    *
//* (C) Copyright IBM Corp. 2009, 2019 All Rights Reserved.            *
//*                                                                    *
//* US Government Users Restricted Rights - Use, duplication or        *
//* disclosure restricted by GSA ADP Schedule Contract with            *
//* IBM Corp.                                                          *
//* </copyright>                                                       *
//**********************************************************************
//*                                                                    *
//* The job will create the Rules Execution Server storagegroup,       *
//* database,tablespaces and tables for supported versions of          *
//* DB2 for zOS                                                        *
//*                                                                    *
//* Note: ++variables++ in this job will be substituted with the       *
//* values specified in the HBRINST member as part of the              *
//* configuration process. See the documentation for more details.     *
//*                                                                    *
//* Expected return code: 0                                            *
//*                                                                    *
//**********************************************************************
//*
//**********************************************************************
//* Create rules storagegroup                                          *
//**********************************************************************
//*
//STORGRP  EXEC PGM=IKJEFT01,REGION=0M
//*        DB2 Runtime Libraries
//STEPLIB  DD DISP=SHR,DSN=DSNC10.DBCG.SDSNEXIT
//         DD DISP=SHR,DSN=DSNC10.SDSNLOAD
//         DD DISP=SHR,DSN=DSNC10.SDSNLOD2
//         DD DISP=SHR,DSN=DSNC10.DBCG.RUNLIB.LOAD
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
DSN SYSTEM(DBCG)
   RUN -
     PROGRAM(DSNTEP2) -
     PLAN(DSNTEP12)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN    DD *
----------------------------------------------------------------------
-- Setting SQLID with authority to create database objects etc.
----------------------------------------------------------------------
  set current SQLID ='IBMUSER';
--
  CREATE STOGROUP RESSTG811
     VOLUMES('*')
     VCAT DBODM;
/*
//*
//******************************************************************
//* Create rules database
//******************************************************************
//*
//DATABASE EXEC PGM=IKJEFT01,REGION=0M
//*        DB2 Runtime Libraries
//STEPLIB  DD DISP=SHR,DSN=DSNC10.DBCG.SDSNEXIT
//         DD DISP=SHR,DSN=DSNC10.SDSNLOAD
//         DD DISP=SHR,DSN=DSNC10.SDSNLOD2
//         DD DISP=SHR,DSN=DSNC10.DBCG.RUNLIB.LOAD
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
DSN SYSTEM(DBCG)
   RUN -
     PROGRAM(DSNTEP2) -
     PLAN(DSNTEP12)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN    DD *
----------------------------------------------------------------------
-- Setting SQLID with authority to create database objects etc.
----------------------------------------------------------------------
  set current SQLID ='IBMUSER';
--
  CREATE DATABASE RESDB811
     STOGROUP RESSTG811
     INDEXBP  BP0;
/*
//*
//******************************************************************
//* Create rules tablespaces
//******************************************************************
//*
//TABLESPC EXEC PGM=IKJEFT01,REGION=0M
//*        DB2 Runtime Libraries
//STEPLIB  DD DISP=SHR,DSN=DSNC10.DBCG.SDSNEXIT
//         DD DISP=SHR,DSN=DSNC10.SDSNLOAD
//         DD DISP=SHR,DSN=DSNC10.SDSNLOD2
//         DD DISP=SHR,DSN=DSNC10.DBCG.RUNLIB.LOAD
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
DSN SYSTEM(DBCG)
   RUN -
     PROGRAM(DSNTEP2) -
     PLAN(DSNTEP12)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN    DD *
----------------------------------------------------------------------
-- Setting SQLID with authority to create database objects etc.
----------------------------------------------------------------------
  set current SQLID ='IBMUSER';
--

  CREATE TABLESPACE RUAPP
    IN RESDB811
    CCSID UNICODE
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    FREEPAGE      0
    PCTFREE       0
    SEGSIZE       64
    MAXPARTITIONS 128
    BUFFERPOOL BP0
    LOCKSIZE ROW
    COMPRESS YES
    CLOSE YES;

  CREATE TABLESPACE RUSET
    IN RESDB811
    CCSID UNICODE
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    FREEPAGE      0
    PCTFREE       0
    SEGSIZE       64
    MAXPARTITIONS 128
    BUFFERPOOL BP0
    COMPRESS YES
    LOCKSIZE ANY
    CLOSE YES;

  CREATE TABLESPACE RUAPPPRO
    IN RESDB811
    CCSID UNICODE
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    FREEPAGE      0
    PCTFREE       0
    SEGSIZE       64
    MAXPARTITIONS 128
    BUFFERPOOL BP0
    COMPRESS YES
    LOCKSIZE ANY
    CLOSE YES;

  CREATE TABLESPACE RUSETPRO
    IN RESDB811
    CCSID UNICODE
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    FREEPAGE      0
    PCTFREE       0
    SEGSIZE       64
    MAXPARTITIONS 128
    BUFFERPOOL BP0
    COMPRESS YES
    LOCKSIZE ANY
    CLOSE YES;

  CREATE TABLESPACE RUSETRES
    IN RESDB811
    CCSID UNICODE
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    FREEPAGE      0
    PCTFREE       0
    SEGSIZE     64
    MAXPARTITIONS 128
    BUFFERPOOL BP0
    COMPRESS YES
    LOCKSIZE ANY
    CLOSE YES;

  CREATE LOB TABLESPACE AUXSETRE LOG NO
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    CLOSE YES;
/*
//*
//******************************************************************
//* Create rules tables
//******************************************************************
//*
//TABLES   EXEC PGM=IKJEFT01,REGION=0M
//*        DB2 Runtime Libraries
//STEPLIB  DD DISP=SHR,DSN=DSNC10.DBCG.SDSNEXIT
//         DD DISP=SHR,DSN=DSNC10.SDSNLOAD
//         DD DISP=SHR,DSN=DSNC10.SDSNLOD2
//         DD DISP=SHR,DSN=DSNC10.DBCG.RUNLIB.LOAD
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
DSN SYSTEM(DBCG)
   RUN -
     PROGRAM(DSNTEP2) -
     PLAN(DSNTEP12)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN    DD *
  --#SET MAXERRORS 1
----------------------------------------------------------------------
-- Setting SQLID with authority to create database objects etc.
----------------------------------------------------------------------
   SET CURRENT SQLID='IBMUSER';

--
----------------------------------------------------------------------
-- Setting SCHEMA to specified schema name
-- All elements, tables, indexes etc. will be created within this
-- schema
----------------------------------------------------------------------
   SET CURRENT SCHEMA = 'ODM811';

--

  CREATE TABLE RULEAPPS
  (
    ID             INT GENERATED ALWAYS AS
    IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
    NAME           VARCHAR(256)      NOT NULL,
    MAJOR_VERSION  INT               NOT NULL,
    MINOR_VERSION  INT               NOT NULL,
    CREATION_DATE  BIGINT            NOT NULL,
    DISPLAY_NAME   VARCHAR(256),
    DESCRIPTION    VARCHAR(256),
    CONSTRAINT RA_PK PRIMARY KEY (ID),
    CONSTRAINT RA_UNIQUE UNIQUE (NAME, MAJOR_VERSION, MINOR_VERSION)
  )
  IN RESDB811.RUAPP
  APPEND YES
  CCSID UNICODE;

  CREATE UNIQUE INDEX RULEAPPS_IDX1
  ON RULEAPPS
  (
    ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE     0
      CLUSTER
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;


  CREATE UNIQUE INDEX RULEAPPS_IDX2
  ON RULEAPPS
  (
    NAME,
    MAJOR_VERSION,
    MINOR_VERSION
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE     0
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;

  CREATE TABLE RULESETS
  (
    ID             INT GENERATED ALWAYS AS
    IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
    NAME           VARCHAR(256)      NOT NULL,
    MAJOR_VERSION  INT               NOT NULL,
    MINOR_VERSION  INT               NOT NULL,
    CREATION_DATE  BIGINT            NOT NULL,
    DISPLAY_NAME   VARCHAR(256),
    DESCRIPTION    VARCHAR(256),
    RULEAPP_ID     INT               NOT NULL,
    CONSTRAINT RS_PK PRIMARY KEY (ID),
    CONSTRAINT RS_FK FOREIGN KEY (RULEAPP_ID)
     REFERENCES RULEAPPS (ID) ON DELETE CASCADE,
    CONSTRAINT RS_UNIQUE
        UNIQUE (RULEAPP_ID, NAME, MAJOR_VERSION, MINOR_VERSION)
  )
  IN RESDB811.RUSET
  CCSID UNICODE;


  CREATE UNIQUE INDEX RULESETS_IDX1
  ON RULESETS
  (
    ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE     0
      CLUSTER
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;

  CREATE UNIQUE INDEX RULESETS_IDX2
  ON RULESETS
  (
    RULEAPP_ID,
    NAME,
    MAJOR_VERSION,
    MINOR_VERSION
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE     0
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;


  CREATE TABLE RULEAPP_PROPERTIES
  (
    ID             INT GENERATED ALWAYS AS
    IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
    RULEAPP_ID     INT               NOT NULL,
    NAME           VARCHAR(256)      NOT NULL,
    VALUE          VARCHAR(2000)     NOT NULL,
    CONSTRAINT RA_PROPS_PK PRIMARY KEY (ID),
    CONSTRAINT RA_PROPS_FK FOREIGN KEY (RULEAPP_ID)
    REFERENCES RULEAPPS (ID) ON DELETE CASCADE,
    CONSTRAINT RA_PROPS_UN UNIQUE (RULEAPP_ID, NAME)
  )
  IN RESDB811.RUAPPPRO
  CCSID UNICODE;

  CREATE UNIQUE INDEX RULEAPP_PROPERTIES_IDX1
  ON RULEAPP_PROPERTIES
  (
    ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE     0
      CLUSTER
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;



  CREATE UNIQUE INDEX  RULEAPP_PROPERTIES_IDX2
  ON RULEAPP_PROPERTIES
  (
     RULEAPP_ID,
     NAME
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE     0
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES
      NOT PADDED;

  CREATE TABLE RULESET_PROPERTIES
  (
    ID             INT GENERATED ALWAYS AS
    IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
    RULESET_ID     INT               NOT NULL,
    NAME           VARCHAR(256)      NOT NULL,
    VALUE          VARCHAR(2000)     NOT NULL,
    CONSTRAINT RS_PROPS_PK PRIMARY KEY (ID),
    CONSTRAINT RS_PROPS_FK FOREIGN KEY (RULESET_ID)
    REFERENCES RULESETS (ID) ON DELETE CASCADE,
    CONSTRAINT RS_PROPS_UN UNIQUE (RULESET_ID, NAME)
  )
  IN RESDB811.RUSETPRO
  CCSID UNICODE;


  CREATE UNIQUE INDEX RULESET_PROPERTIES_IDX1
  ON RULESET_PROPERTIES
  (
    ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE     0
      CLUSTER
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;

  CREATE UNIQUE INDEX  RULESET_PROPERTIES_IDX2
  ON RULESET_PROPERTIES
  (
     RULESET_ID,
     NAME
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE     0
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES
      NOT PADDED;

  CREATE TABLE RULESET_RESOURCES
  (
    ID INT GENERATED ALWAYS AS
    IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
    RULESET_ID     INT               NOT NULL,
    ARCHIVE        BLOB(1024 M)      NOT NULL,
    CONSTRAINT RS_RES_PK PRIMARY KEY (ID),
    CONSTRAINT RS_RES_FK FOREIGN KEY (RULESET_ID)
    REFERENCES RULESETS (ID) ON DELETE CASCADE
  )
  IN RESDB811.RUSETRES
  CCSID UNICODE;

  CREATE UNIQUE INDEX RULESET_RESOURCES_IDX1
  ON  RULESET_RESOURCES
  (
      ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE     0
      CLUSTER
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;


  CREATE AUX TABLE AUX_RULESET_RESOURCES
  IN RESDB811.AUXSETRE
    STORES RULESET_RESOURCES
    COLUMN ARCHIVE PART 1;

  CREATE UNIQUE INDEX AUX_RULESET_RESOURCES_UI1
  ON AUX_RULESET_RESOURCES;

  CREATE VIEW RS_ENABLED_VIEW AS
  SELECT RA.ID AS RA_ID, RA.NAME AS RA_NAME,
         RA.MAJOR_VERSION AS RA_MAJVERS,
         RA.MINOR_VERSION AS RA_MINVERS,
         RS.ID AS RS_ID, RS.NAME AS RS_NAME,
         RS.MAJOR_VERSION AS RS_MAJVERS,
         RS.MINOR_VERSION AS RS_MINVERS
  FROM   RULEAPPS RA,
         RULESETS RS,
         RULESET_PROPERTIES P
  WHERE RS.RULEAPP_ID = RA.ID AND RS.ID = P.RULESET_ID
  AND UPPER(P.NAME) = 'RULESET.STATUS' AND UPPER(P.VALUE) = 'ENABLED';


/*
//*
```

</div></details>

<details><summary><font color="blue">HBRDSXOM</font></summary><div>

```
//HBRDSXOM JOB MSGCLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//**********************************************************************
//*                                                                    *
//* <copyright                                                         *
//* notice="lm-source-program"                                         *
//* pids="5655-Y31"                                                    *
//* years="2012,2019"                                                  *
//* crc="914288038" >                                                  *
//* Licensed Materials - Property of IBM                               *
//*                                                                    *
//* 5655-Y31                                                           *
//*                                                                    *
//* (C) Copyright IBM Corp. 2012, 2019 All Rights Reserved.            *
//*                                                                    *
//* US Government Users Restricted Rights - Use, duplication or        *
//* disclosure restricted by GSA ADP Schedule Contract with            *
//* IBM Corp.                                                          *
//* </copyright>                                                       *
//**********************************************************************
//*                                                                    *
//* This job will create the XOM database artifacts for                *
//* ODM for z/OS                                                    *
//*                                                                    *
//* Note: ++variables++ in this job will be substituted with the       *
//* values specified in the HBRINST member as part of the              *
//* configuration process. See the documentation for more details.     *
//*                                                                    *
//* Expected return code: 0                                            *
//*                                                                    *
//**********************************************************************
//* Create rules tablespaces
//**********************************************************************
//*
//TABLESPC EXEC PGM=IKJEFT01,REGION=0M
//*        DB2 Runtime Libraries
//STEPLIB  DD DISP=SHR,DSN=DSNC10.DBCG.SDSNEXIT
//         DD DISP=SHR,DSN=DSNC10.SDSNLOAD
//         DD DISP=SHR,DSN=DSNC10.SDSNLOD2
//         DD DISP=SHR,DSN=DSNC10.DBCG.RUNLIB.LOAD
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
DSN SYSTEM(DBCG)
   RUN -
     PROGRAM(DSNTEP2) -
     PLAN(DSNTEP12)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN    DD *
----------------------------------------------------------------------
-- Setting SQLID with authority to create database objects etc.
----------------------------------------------------------------------
  set current SQLID ='IBMUSER';
--
  CREATE TABLESPACE XOMRES
    IN RESDB811
    CCSID UNICODE
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    FREEPAGE      5
    PCTFREE       20
    SEGSIZE       64
    MAXPARTITIONS 128
    BUFFERPOOL BP0
    LOCKSIZE ANY
    CLOSE YES;

  CREATE TABLESPACE XOMLIB
    IN RESDB811
    CCSID UNICODE
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    FREEPAGE      5
    PCTFREE       20
    SEGSIZE       64
    DSSIZE        1G
    MAXPARTITIONS 128
    BUFFERPOOL BP0
    LOCKSIZE ANY
    CLOSE YES;

  CREATE TABLESPACE XOMLIBVS
    IN RESDB811
    CCSID UNICODE
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    FREEPAGE      5
    PCTFREE       20
    SEGSIZE       64
    MAXPARTITIONS 128
    BUFFERPOOL BP0
    LOCKSIZE ANY
    CLOSE YES;

  CREATE LOB TABLESPACE XRTS LOG NO
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    CLOSE YES;
/*
//*
//**********************************************************************
//* Create rules tables
//**********************************************************************
//*
//TABLES   EXEC PGM=IKJEFT01,REGION=0M
//*        DB2 Runtime Libraries
//STEPLIB  DD DISP=SHR,DSN=DSNC10.DBCG.SDSNEXIT
//         DD DISP=SHR,DSN=DSNC10.SDSNLOAD
//         DD DISP=SHR,DSN=DSNC10.SDSNLOD2
//         DD DISP=SHR,DSN=DSNC10.DBCG.RUNLIB.LOAD
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
DSN SYSTEM(DBCG)
   RUN -
     PROGRAM(DSNTEP2) -
     PLAN(DSNTEP12)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN    DD *
  --#SET MAXERRORS 1
----------------------------------------------------------------------
-- Setting SQLID with authority to create database objects etc.
----------------------------------------------------------------------
   SET CURRENT SQLID='IBMUSER';

--
----------------------------------------------------------------------
-- Setting SCHEMA to specified schema name
-- All elements, tables, indexes etc. will be created within this
-- schema
----------------------------------------------------------------------
   SET CURRENT SCHEMA = 'ODM811';

--

  CREATE TABLE XOM_LIBRARIES
  (
    ID INT GENERATED ALWAYS AS
    IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
    NAME              VARCHAR(256)  NOT NULL,
    MAJOR_VERSION     INT           NOT NULL,
    MINOR_VERSION     INT           NOT NULL,
    CREATION_DATE     BIGINT        NOT NULL,
    CONSTRAINT XL_PK PRIMARY        KEY (ID),
    CONSTRAINT XL_UNIQUE UNIQUE (NAME, MAJOR_VERSION, MINOR_VERSION)
  )
  IN RESDB811.XOMLIB
  CCSID UNICODE;

  CREATE UNIQUE INDEX XLIBS_IDXU1
  ON  XOM_LIBRARIES
  (
    ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     5
      PCTFREE     30
      CLUSTER
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;


  CREATE UNIQUE INDEX XLIBS_IDXU2
  ON XOM_LIBRARIES
  (
    NAME, MAJOR_VERSION, MINOR_VERSION
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     5
      PCTFREE     30
      DEFINE      NO
      BUFFERPOOL BP0
      CLOSE       YES
      NOT PADDED;

  CREATE TABLE XOM_RESOURCES
  (
    ID INT GENERATED ALWAYS AS
    IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
    NAME                VARCHAR(256)   NOT NULL,
    MAJOR_VERSION       INT            NOT NULL,
    MINOR_VERSION       INT            NOT NULL,
    SHA1                VARCHAR(40)    NOT NULL,
    CREATION_DATE       BIGINT         NOT NULL,
    DATA                BLOB(1024 M)   NOT NULL,
    CONSTRAINT XR_PK PRIMARY KEY (ID),
    CONSTRAINT XR_UNIQUE1 UNIQUE (NAME, MAJOR_VERSION, MINOR_VERSION),
    CONSTRAINT XR_UNIQUE2 UNIQUE (NAME, SHA1)
  )
  IN RESDB811.XOMRES
  CCSID UNICODE;

  CREATE UNIQUE INDEX XRESS_IDXU1
  ON XOM_RESOURCES
  (
    ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     5
      PCTFREE     30
      CLUSTER
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;

  CREATE UNIQUE INDEX XRESS_IDXU2
  ON XOM_RESOURCES
  (
    NAME, MAJOR_VERSION, MINOR_VERSION
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     5
      PCTFREE     30
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;

  CREATE UNIQUE INDEX XRESS_IDXU3
  ON XOM_RESOURCES
  (
    NAME,
    SHA1
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     5
      PCTFREE     30
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES
      NOT PADDED;

  CREATE AUX TABLE AUX_XOM_RESOURCES
  IN RESDB811.XRTS
    STORES XOM_RESOURCES COLUMN DATA PART 1;


  CREATE UNIQUE INDEX AUX_XOM_RESOURCES_UI1
  ON AUX_XOM_RESOURCES;

  CREATE TABLE XOM_LIBRARY_VALUES
  (
    ID INT GENERATED ALWAYS AS
    IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
    LIBRARY_ID            INT               NOT NULL,
    URL                   VARCHAR(256)      NOT NULL,
    CONSTRAINT XL_VLS_PK PRIMARY KEY (ID),
    CONSTRAINT XL_VLS_FK FOREIGN KEY (LIBRARY_ID)
      REFERENCES XOM_LIBRARIES (ID) ON DELETE CASCADE,
    CONSTRAINT XL_VLS_UN UNIQUE (LIBRARY_ID, URL)
  )
  IN RESDB811.XOMLIBVS
  CCSID UNICODE;

  CREATE UNIQUE INDEX XLIBVLS_IDXU1
  ON XOM_LIBRARY_VALUES
  (
    ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     5
      PCTFREE     30
      CLUSTER
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES;


  CREATE UNIQUE INDEX XLIBVLS_IDXU2
  ON XOM_LIBRARY_VALUES
  (
    LIBRARY_ID, URL
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     5
      PCTFREE     30
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE YES
      NOT PADDED;


/*
//*
```

</div></details>

<details><summary><font color="blue">HBRDSCTR</font></summary><div>

```
//HBRDSCTR JOB MSGCLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//**********************************************************************
//* <copyright                                                         *
//* notice="lm-source-program"                                         *
//* pids="5655-Y31"                                                    *
//* years="2009,2019"                                                  *
//* crc="468919026" >                                                  *
//* Licensed Materials - Property of IBM                               *
//*                                                                    *
//* 5655-Y31                                                           *
//*                                                                    *
//* (C) Copyright IBM Corp. 2009, 2019 All Rights Reserved.            *
//*                                                                    *
//* US Government Users Restricted Rights - Use, duplication or        *
//* disclosure restricted by GSA ADP Schedule Contract with            *
//* IBM Corp.                                                          *
//* </copyright>                                                       *
//**********************************************************************
//*                                                                    *
//* This job will create the tables required for trace                 *
//*                                                                    *
//* Note: This job assumes that the Storage Group and Database exist   *
//*                                                                    *
//* Note: ++variables++ in this job will be substituted with the       *
//* values specified in the HBRINST member as part of the              *
//* configuration process. See the documentation for more details.     *
//*                                                                    *
//* Expected return code: 0                                            *
//*                                                                    *
//**********************************************************************
//*
//TABLES   EXEC PGM=IKJEFT01,REGION=0M
//*        DB2 Runtime Libraries
//STEPLIB  DD DISP=SHR,DSN=DSNC10.DBCG.SDSNEXIT
//         DD DISP=SHR,DSN=DSNC10.SDSNLOAD
//         DD DISP=SHR,DSN=DSNC10.SDSNLOD2
//         DD DISP=SHR,DSN=DSNC10.DBCG.RUNLIB.LOAD
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
DSN SYSTEM(DBCG)
   RUN -
     PROGRAM(DSNTEP2) -
     PLAN(DSNTEP12)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN    DD *
----------------------------------------------------------------------
-- Setting SQLID with authority to create database objects etc.
----------------------------------------------------------------------
   SET CURRENT SQLID='IBMUSER';

--
----------------------------------------------------------------------
-- Setting SCHEMA to specified schema name
-- All elements, tables, indexes etc. will be created within this
-- schema
----------------------------------------------------------------------
   SET CURRENT SCHEMA = 'ODM811';

--

  -- Use a buffer pool with a 32K page size

  CREATE TABLESPACE RESDWTS
    IN RESDB811
    CCSID UNICODE
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    FREEPAGE     0
    PCTFREE     0
    SEGSIZE     64
    MAXPARTITIONS 128
    BUFFERPOOL BP32K
    LOCKSIZE ANY
    COMPRESS YES
    CLOSE YES;

  CREATE LOB TABLESPACE EXTRA001
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    LOG NO
    CLOSE NO;

  CREATE LOB TABLESPACE EXTRA002
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    LOG NO
    CLOSE NO;

  CREATE LOB TABLESPACE EXTRA003
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    LOG NO
    CLOSE NO;

  CREATE LOB TABLESPACE EXTRA004
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    LOG NO
    CLOSE NO;

  CREATE LOB TABLESPACE EXTRA005
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    LOG NO
    CLOSE NO;

  CREATE LOB TABLESPACE EXTRA006
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    LOG NO
    CLOSE NO;

  CREATE LOB TABLESPACE EXTRA007
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    LOG NO
    CLOSE NO;

  CREATE LOB TABLESPACE EXTRA008
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    LOG NO
    CLOSE NO;

  CREATE LOB TABLESPACE EXTRA009
    IN RESDB811
    USING STOGROUP RESSTG811
          PRIQTY     -1
          SECQTY      -1
    ERASE NO
    BUFFERPOOL BP3
    LOCKSIZE ANY
    LOG NO
    CLOSE NO;

  CREATE TABLE EXECUTION_TRACES
  (
    ID                 INT GENERATED ALWAYS AS IDENTITY
    (START WITH 1,     INCREMENT BY 1,NO CYCLE,CACHE 1000)  NOT NULL,
    TIME_STAMP         BIGINT,
    LOCATION           VARCHAR(2000),
    REQUEST_PATH       VARCHAR(2000)         NOT NULL,
    CANONICAL_PATH     VARCHAR(2000)         NOT NULL,
    RULESET_PROPERTIES CLOB(1G),
    ELAPSED_TIME       BIGINT,
    USER_DATA          CLOB(1G),
    NB_RULES           INT,
    NB_RULES_FIRED     INT,
    NB_RULES_NOT_FIRED INT,
    NB_TASKS INT,
    NB_TASKS_EXECUTED  INT,
    NB_TASKS_NOT_EXECUTED INT,
    RULES              CLOB(1G),
    TASKS              CLOB(1G),
    EXECUTION_TRACE_TREE CLOB(1G),
    EXEC_OUTPUT        CLOB(1G),
    INPUT_PARAMS       CLOB(1G),
    OUTPUT_PARAMS      CLOB(1G),
    EXECUTION_ID       VARCHAR(255)          NOT NULL,
    FULL_EXECUTION_TRACE CLOB(1G),
    CONSTRAINT         ET_PK      PRIMARY KEY (ID),
    CONSTRAINT         EID_UNQ    UNIQUE (EXECUTION_ID)
  )
  IN RESDB811.RESDWTS
  CCSID UNICODE;

  CREATE UNIQUE INDEX EXECUTION_TRACES_IDX1
    ON EXECUTION_TRACES
  (
    ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE      0
      CLUSTER
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE NO;

  CREATE UNIQUE INDEX EXECUTION_TRACES_IDX2
    ON EXECUTION_TRACES
  (
    EXECUTION_ID
  )
  USING STOGROUP RESSTG811
      PRIQTY      -1
      SECQTY      -1
      ERASE NO
      FREEPAGE     0
      PCTFREE      0
      DEFINE NO
      BUFFERPOOL BP0
      CLOSE NO;

  CREATE AUX TABLE AUX_EX_TRACE_RS_PROPS
    IN RESDB811.EXTRA001
    STORES EXECUTION_TRACES COLUMN RULESET_PROPERTIES PART 1;

  CREATE UNIQUE INDEX AUX_EX_TRACE_RS_PROPS_UI1
    ON AUX_EX_TRACE_RS_PROPS;

  CREATE AUX TABLE AUX_EX_TRACE_USER_DATA
    IN RESDB811.EXTRA002
    STORES EXECUTION_TRACES COLUMN USER_DATA PART 1;

  CREATE UNIQUE INDEX AUX_EX_TRACE_USER_DATA_UI1
    ON AUX_EX_TRACE_USER_DATA;

  CREATE AUX TABLE AUX_EX_TRACE_RULES
    IN RESDB811.EXTRA003
    STORES EXECUTION_TRACES COLUMN RULES PART 1;

  CREATE UNIQUE INDEX AUX_EX_TRACE_RULES_UI1
    ON AUX_EX_TRACE_RULES;

  CREATE AUX TABLE AUX_EX_TRACE_TASKS
    IN RESDB811.EXTRA004
    STORES EXECUTION_TRACES COLUMN TASKS PART 1;

  CREATE UNIQUE INDEX AUX_EX_TRACE_TASKS_UI1
    ON AUX_EX_TRACE_TASKS;


  CREATE AUX TABLE AUX_EX_TRACE_ETT
    IN RESDB811.EXTRA005
    STORES EXECUTION_TRACES COLUMN EXECUTION_TRACE_TREE PART 1;

  CREATE UNIQUE INDEX AUX_EX_TRACE_ETT_UI1
    ON AUX_EX_TRACE_ETT;

  CREATE AUX TABLE AUX_EX_TRACE_EXOUT
    IN RESDB811.EXTRA006
    STORES EXECUTION_TRACES COLUMN EXEC_OUTPUT PART 1;

  CREATE UNIQUE INDEX AUX_EX_TRACE_EXOUT_UI1
    ON AUX_EX_TRACE_EXOUT;

  CREATE AUX TABLE AUX_EX_TRACE_INPARAMS
    IN RESDB811.EXTRA007
    STORES EXECUTION_TRACES COLUMN INPUT_PARAMS PART 1;

  CREATE UNIQUE INDEX AUX_EX_TRACE_INPARAMS_UI1
    ON AUX_EX_TRACE_INPARAMS;

  CREATE AUX TABLE AUX_EX_TRACE_OUTPARAMS
    IN RESDB811.EXTRA008
    STORES EXECUTION_TRACES COLUMN OUTPUT_PARAMS PART 1;

  CREATE UNIQUE INDEX AUX_EX_TRACE_OUTPARAMS_UI1
    ON AUX_EX_TRACE_OUTPARAMS;

  CREATE AUX TABLE AUX_EX_TRACE_FULLET
    IN RESDB811.EXTRA009
    STORES EXECUTION_TRACES COLUMN FULL_EXECUTION_TRACE PART 1;

  CREATE UNIQUE INDEX AUX_EX_TRACE_FULLET_UI1
    ON AUX_EX_TRACE_FULLET;


/*
//*
```

</div></details>


#### Creating the Decision Center DB2 database
今回Decision Centerは構成しないので、このステップは飛ばします。


### Step 8: Configuring your topology

[Configuring topology 1: zRule Execution Server group with a shared console](https://www.ibm.com/docs/en/odm/8.11.0?topic=s8cyt-configuring-topology-1-zrule-execution-server-group-shared-console) のガイドに従って設定していきます。

#### Configuring the Liberty server angel process
マニュアル上は後続の手順に記載されているのですが、次の手順の中でリンクで飛ばされるので先に実施しておきます。(マニュアルの書き方の順番がちょっと分かりにくいですが...)
参考: [Configuring the Liberty server angel process](https://www.ibm.com/docs/en/odm/8.11.0?topic=security-configuring-liberty-server-angel-process)

/usr/lpp/zDM/V8R11ML/zexecutionserver/wlp/templates/zos/procs/bbgzangl.jcl に提供されるサンプルをを、FEU.Z24D.PROCLIB(O8B0ANGL)にコピーし、環境に合わせて編集します。

```FEU.Z24D.PROCLIB(O8B0ANGL)
//O8B0ANGL PROC PARMS='',COLD=N,NAME='O8B0ANGL'
//*O8B0ANGL PROC PARMS='',COLD=N,NAME='O8B0ANGL',SAFLOG=N
//*------------------------------------------------------------------
//  SET ROOT='/usr/lpp/zDM/V8R11ML/zexecutionserver/wlp'
//*------------------------------------------------------------------
//* Start the Liberty angel process
//*------------------------------------------------------------------
//* This proc may be overwritten by fixpacks or iFixes.
//* You must copy to another location before customizing.
//*------------------------------------------------------------------
//STEP1   EXEC PGM=BPXBATA2,REGION=0M,TIME=NOLIMIT,
//      PARM='PGM &ROOT./lib/native/zos/s390x/bbgzangl COLD=&COLD NAME=X
//             &NAME &PARMS'
//*             &NAME &PARMS SAFLOG=&SAFLOG'
//*------------------------------------------------------------------
//* To enable ARM services for angel, append ARMEL='' in the PROC
//* line and replace the last line of PARAM adding the ARMEL=&ARMEL
//* just like this:
//*            &NAME &PARMS SAFLOG=&SAFLOG ARMEL=&ARMEL'
//*------------------------------------------------------------------
//STDOUT    DD SYSOUT=*
//STDERR    DD SYSOUT=*
```

ANGELプロセス起動ユーザーを作成します。

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "ADDUSER LIBSRV DFLTGRP(SYS1) OMVS(UID(100202)) NOPASSWORD NOOIDCARD"
ADDUSER LIBSRV DFLTGRP(SYS1) OMVS(UID(100202)) NOPASSWORD NOOIDCARD
```

STARTEDクラスにプロファイル登録

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE STARTED O8B0ANGL.* UACC(NONE) STDATA(USER(LIBSRV) GROUP(SYS1) PRIVILEGED(NO) TRUSTED(NO) TRACE(YES))"
RDEFINE STARTED O8B0ANGL.* UACC(NONE) STDATA(USER(LIBSRV) GROUP(SYS1) PRIVILEGED(NO) TRUSTED(NO) TRACE(YES))
ICH10006I RACLISTED PROFILES FOR STARTED WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "SETROPTS RACLIST(STARTED) REFRESH"
SETROPTS RACLIST(STARTED) REFRESH
```

SERVERクラスにプロファイル登録

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE SERVER BBG.ANGEL.O8B0ANGL UACC(NONE)"
RDEFINE SERVER BBG.ANGEL.O8B0ANGL UACC(NONE)
ICH10006I RACLISTED PROFILES FOR SERVER WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT BBG.ANGEL.O8B0ANGL CLASS(SERVER) ACCESS(READ) ID(ODMUSER)"
PERMIT BBG.ANGEL.O8B0ANGL CLASS(SERVER) ACCESS(READ) ID(ODMUSER)
ICH06011I RACLISTED PROFILES FOR SERVER   WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED

TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE SERVER BBG.AUTHMOD.BBGZSAFM UACC(NONE)"
RDEFINE SERVER BBG.AUTHMOD.BBGZSAFM UACC(NONE)
ICH10102I BBG.AUTHMOD.BBGZSAFM ALREADY DEFINED TO CLASS SERVER.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT BBG.AUTHMOD.BBGZSAFM CLASS(SERVER) ACCESS(READ) ID(ODMUSER)"
PERMIT BBG.AUTHMOD.BBGZSAFM CLASS(SERVER) ACCESS(READ) ID(ODMUSER)
ICH06011I RACLISTED PROFILES FOR SERVER   WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED

TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE SERVER BBG.AUTHMOD.BBGZSAFM.SAFCRED UACC(NONE)"
RDEFINE SERVER BBG.AUTHMOD.BBGZSAFM.SAFCRED UACC(NONE)
ICH10102I BBG.AUTHMOD.BBGZSAFM.SAFCRED ALREADY DEFINED TO CLASS SERVER.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT BBG.AUTHMOD.BBGZSAFM.SAFCRED CLASS(SERVER) ACCESS(READ) ID(ODMUSER)"
PERMIT BBG.AUTHMOD.BBGZSAFM.SAFCRED CLASS(SERVER) ACCESS(READ) ID(ODMUSER)
ICH06011I RACLISTED PROFILES FOR SERVER   WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED
```

※2つ目、3つ目は既に登録されてた

リフレッシュ

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "SETROPTS RACLIST(SERVER) REFRESH"
SETROPTS RACLIST(SERVER) REFRESH
```

Angelプロセス稼働確認してみます。

```
S O8B0ANGL                                                                
IRR812I PROFILE O8B0ANGL.* (G) IN THE STARTED CLASS WAS USED 407          
        TO START O8B0ANGL WITH JOBNAME O8B0ANGL.                          
$HASP100 O8B0ANGL ON STCINRDR                                             
IEF695I START O8B0ANGL WITH JOBNAME O8B0ANGL IS ASSIGNED TO USER LIBSRV   
 , GROUP SYS1                                                             
$HASP373 O8B0ANGL STARTED                                                 
IEF403I O8B0ANGL - STARTED - TIME=04.35.33                                
CWWKB0079I THE ANGEL BUILD LEVEL IS 21.0.0.9 20210825-0508 / 412          
2021.9.0.0 20210825-0508                                                  
CWWKB0069I INITIALIZATION IS COMPLETE FOR THE O8B0ANGL ANGEL PROCESS.     
```

OKそうです。

#### Configuring a zRule Execution Server for z/OS server group

元の手順にもどって、RES用のSUBSYS登録を行います。

動的登録用のコマンド:
SETSSI ADD,SUBNAME=O8B0
SETSSI ADD,SUBNAME=O8B1
SETSSI ADD,SUBNAME=O8B2

静的登録: IEFSSNxxに以下を追記

```FEU.Z24D.PARMLIB(IEFSSNDB)
SUBSYS SUBNAME(O8B0) 
SUBSYS SUBNAME(O8B1) 
SUBSYS SUBNAME(O8B2) 

```

WORK用データセットに生成された起動プロシージャーを、以下のようにPROCLIBにコピーします。

IODM811.WORK.O8B0.SHBRPROC(HBRXMSTR) => FEU.Z24D.PROCLIB(O8B0MSTR)
IODM811.WORK.O8B1.SHBRPROC(HBRXMSTR) => FEU.Z24D.PROCLIB(O8B1MSTR)
IODM811.WORK.O8B2.SHBRPROC(HBRXMSTR) => FEU.Z24D.PROCLIB(O8B2MSTR)

いずれも、STEPLIBに指定されているSDSNEXITのデータセット名を手動で修正します。

```
//STEPLIB  DD DISP=SHR,DSN=&HBRHLQ..SHBRAUTH
//         DD DISP=SHR,DSN=DSNC10.SDSNLOAD
//         DD DISP=SHR,DSN=DSNC10.SDSNLOD2
//         DD DISP=SHR,DSN=DSNC10.DBCG.SDSNEXIT
```

ODM起動ユーザーを作成します。

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "ADDUSER ODMUSER NAME('ODM USER') DFLTGRP(SYS1) OMVS(UID(100201)) NOPASSWORD NOOIDCARD"
ADDUSER ODMUSER NAME('ODM USER') DFLTGRP(SYS1) OMVS(UID(100201)) NOPASSWORD NOOIDCARD
```

STARTEDクラスにプロファイル登録します。

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE STARTED O8B0MSTR.* STDATA(USER(ODMUSER) GROUP(SYS1))"
RDEFINE STARTED O8B0MSTR.* STDATA(USER(ODMUSER) GROUP(SYS1))
ICH10006I RACLISTED PROFILES FOR STARTED WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE STARTED O8B1MSTR.* STDATA(USER(ODMUSER) GROUP(SYS1))"
RDEFINE STARTED O8B1MSTR.* STDATA(USER(ODMUSER) GROUP(SYS1))
ICH10006I RACLISTED PROFILES FOR STARTED WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE STARTED O8B2MSTR.* STDATA(USER(ODMUSER) GROUP(SYS1))"
RDEFINE STARTED O8B2MSTR.* STDATA(USER(ODMUSER) GROUP(SYS1))
ICH10006I RACLISTED PROFILES FOR STARTED WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.

TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "SETR REF RACLIST(STARTED)"
SETR REF RACLIST(STARTED)
```

SERVERクラスにプロファイル登録し、権限設定を行います。

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE SERVER BBG.SECPFX.O8B0 UACC(NONE)"
RDEFINE SERVER BBG.SECPFX.O8B0 UACC(NONE)
ICH10006I RACLISTED PROFILES FOR SERVER WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT BBG.SECPFX.O8B0 CLASS(SERVER) ACCESS(READ) ID(ODMUSER)"
PERMIT BBG.SECPFX.O8B0 CLASS(SERVER) ACCESS(READ) ID(ODMUSER)
ICH06011I RACLISTED PROFILES FOR SERVER   WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "SETR RACLIST(SERVER) REFR"
SETR RACLIST(SERVER) REFR
```

APPLクラスにプロファイル登録し、権限設定を行います。

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE APPL O8B0 UACC(NONE)"
RDEFINE APPL O8B0 UACC(NONE)
ICH10006I RACLISTED PROFILES FOR APPL WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0  CLASS(APPL) ACCESS(READ) ID(WSGUEST)"
PERMIT O8B0  CLASS(APPL) ACCESS(READ) ID(WSGUEST)
ICH06011I RACLISTED PROFILES FOR APPL     WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0  CLASS(APPL) ACCESS(READ) ID(ODMUSER)"
PERMIT O8B0  CLASS(APPL) ACCESS(READ) ID(ODMUSER)
ICH06011I RACLISTED PROFILES FOR APPL     WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "SETR RACLIST(APPL) REFR"
SETR RACLIST(APPL) REFR
```

#### Configuring CICS to execute rules on zRule Execution Server for z/OS
ここでは一旦保留とします。後でCICSセットアップのところで実施します。

#### Securing zRule Execution Server for z/OS resources

##### Securing access to the working directory and the installation directory
USSの以下のディレクトリにODM実行ユーザーの権限付与しておきます。
/var/zDM/V8R11ML: Read/Write/Execute
/usr/lpp/zDM/V8R11ML: Read/Execute

##### Creating the RACF classes for securing server resources

ODM811.WORK.O8B0.SHBRJCL(HBRCRECL)に生成されたJCLをSubmitします。
SETROPTS LISTでHBRxxxがActiveになったことを確認します。

```
TAGUCHI:/u/TAGUCHI: >tsocmd "SETROPTS LIST"
SETROPTS LIST
ATTRIBUTES = INITSTATS WHEN(PROGRAM -- BASIC)
STATISTICS = NONE
ACTIVE CLASSES = DATASET USER GROUP ACCTNUM ACICSPCT AIMS APPL BCICSPCT
                 CBIND CCICSCMD CDT CIMS CONSOLE CSFKEYS CSFSERV DASDVOL
                 DCICSDCT DIGTCERT DIGTCRIT DIGTNMAP DIGTRING DIMS DSNADM
                 DSNR ECICSDCT EJBROLE FACILITY FCICSFCT GCICSTRN GCSFKEYS
                 GDASDVOL GEJBROLE GIMS GMQADMIN GSDSF GXCSFKEY GXFACILI
                 GZMFAPLA HBRADMIN HBRCMD HBRCONN HCICSFCT IDIDMAP IIMS
                 JCICSJCT JIMS KCICSJCT LIMS LOGSTRM MCICSPPT MIMS MQADMIN
                 NCICSPPT OPERCMDS PCICSPSB PTKTDATA PTKTVAL QCICSPSB
                 RCICSRES RDATALIB RIMS SCICSTST SDSF SERVAUTH SERVER
                 STARTED SURROGAT TAPEVOL TCICSTRN TEMPDSN TIMS TSOAUTH
                 TSOPROC UCICSTST UNIXPRIV VCICSCMD WBEM WCICSRES XCSFKEY
                 XFACILIT ZMFAPLA ZMFCLOUD
...
```

##### Managing connection security

接続関連のRACF設定

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE HBRCONN O8B0 UACC(NONE)"
RDEFINE HBRCONN O8B0 UACC(NONE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE HBRCONN O8B1 UACC(NONE)"
RDEFINE HBRCONN O8B1 UACC(NONE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE HBRCONN O8B2 UACC(NONE)"
RDEFINE HBRCONN O8B2 UACC(NONE)

TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0 CLASS(HBRCONN) ID(ODMUSER) ACCESS(UPDATE)"
PERMIT O8B0 CLASS(HBRCONN) ID(ODMUSER) ACCESS(UPDATE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B1 CLASS(HBRCONN) ID(ODMUSER) ACCESS(UPDATE)"
PERMIT O8B1 CLASS(HBRCONN) ID(ODMUSER) ACCESS(UPDATE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B2 CLASS(HBRCONN) ID(ODMUSER) ACCESS(UPDATE)"
PERMIT O8B2 CLASS(HBRCONN) ID(ODMUSER) ACCESS(UPDATE)
```

##### Managing CONSOLE mode security

RES Console関連のRACF設定

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE EJBROLE O8B0.res.resDeployers UACC(NONE)"
RDEFINE EJBROLE O8B0.res.resDeployers UACC(NONE)
ICH10006I RACLISTED PROFILES FOR EJBROLE WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE EJBROLE O8B0.res.resAdministrators UACC(NONE)"
RDEFINE EJBROLE O8B0.res.resAdministrators UACC(NONE)
ICH10006I RACLISTED PROFILES FOR EJBROLE WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.

TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0.res.resDeployers CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)"
PERMIT O8B0.res.resDeployers CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)
ICH06011I RACLISTED PROFILES FOR EJBROLE  WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0.res.resAdministrators CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)"
PERMIT O8B0.res.resAdministrators CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)
ICH06011I RACLISTED PROFILES FOR EJBROLE  WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED

TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "SETROPTS RACLIST(EJBROLE) REFRESH"
SETROPTS RACLIST(EJBROLE) REFRESH
```

この辺は横着して一旦IBMUSER使う想定にしてます。

※注意！
V8.11のマニュアルではRACFプロファイル`<HBRSSID_NAME>.res.resMonitors`についての記述が削除されています。
[ODM V8.10 - Managing CONSOLE mode security](https://www.ibm.com/docs/en/odm/8.10?topic=security-managing-console-mode)
[ODM V8.11 - Managing CONSOLE mode security](https://www.ibm.com/docs/en/odm/8.11.0?topic=security-managing-console-mode)

このプロファイルの定義は不要になったのかと思いきや、定義せずにRES Consoleを起動させると以下の様なメッセージが出ました。

```
 [1/31/22 0:08:08:632 GMT] 00000031 com.ibm.ws.security.saf.SAFServiceResult                     
     E CWWKS2911E: SAF Service RACROUTE_AUTH did not succeed because the resource profile O8B0.res.resMonitors in class EJBROLE does 
 not exist. SAF return code 0x00000004. RACF return code 0x00000004. RACF reason code 0x00000000.
```

V8.10のドキュメントの記述に従って、以下の定義を追加することでエラーは解消されました。(マニュアルの不備の可能性あり)

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE EJBROLE O8B0.res.Monitors UACC(NONE)"
RDEFINE EJBROLE O8B0.res.Monitors UACC(NONE)
ICH10006I RACLISTED PROFILES FOR EJBROLE WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0.res.Monitors CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)"
PERMIT O8B0.res.Monitors CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)
ICH06011I RACLISTED PROFILES FOR EJBROLE  WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "SETROPTS RACLIST(EJBROLE) REFRESH"
SETROPTS RACLIST(EJBROLE) REFRESH
```

##### Managing TEST mode security

TEST mode関連RACF設定

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE EJBROLE O8B0.DecisionRunner.resAdministrators UACC(NONE)"
RDEFINE EJBROLE O8B0.DecisionRunner.resAdministrators UACC(NONE)
ICH10006I RACLISTED PROFILES FOR EJBROLE WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE EJBROLE O8B0.DecisionRunner.resDeployers UACC(NONE)"
RDEFINE EJBROLE O8B0.DecisionRunner.resDeployers UACC(NONE)
ICH10006I RACLISTED PROFILES FOR EJBROLE WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED.

TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0.DecisionRunner.resAdministrators CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)"
PERMIT O8B0.DecisionRunner.resAdministrators CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)
ICH06011I RACLISTED PROFILES FOR EJBROLE  WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0.DecisionRunner.resDeployers CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)"
PERMIT O8B0.DecisionRunner.resDeployers CLASS(EJBROLE) ID(IBMUSER) ACCESS(READ)
ICH06011I RACLISTED PROFILES FOR EJBROLE  WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED

TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "SETROPTS RACLIST(EJBROLE) REFRESH"
SETROPTS RACLIST(EJBROLE) REFRESH
```

##### Managing command security

zRES command関連RACF設定

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE HBRCMD O8B0.SET.TRACE UACC(NONE)"
RDEFINE HBRCMD O8B0.SET.TRACE UACC(NONE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE HBRCMD O8B0.PAUSE UACC(NONE)"
RDEFINE HBRCMD O8B0.PAUSE UACC(NONE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE HBRCMD O8B0.RESUME UACC(NONE)"
RDEFINE HBRCMD O8B0.RESUME UACC(NONE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "RDEFINE HBRCMD O8B0.DUMP UACC(NONE)"
RDEFINE HBRCMD O8B0.DUMP UACC(NONE)

TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0.SET.TRACE CLASS(HBRCMD) ID(IBMUSER) ACCESS(UPDATE)"
PERMIT O8B0.SET.TRACE CLASS(HBRCMD) ID(IBMUSER) ACCESS(UPDATE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0.PAUSE CLASS(HBRCMD) ID(IBMUSER) ACCESS(UPDATE)"
PERMIT O8B0.PAUSE CLASS(HBRCMD) ID(IBMUSER) ACCESS(UPDATE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0.RESUME CLASS(HBRCMD) ID(IBMUSER) ACCESS(UPDATE)"
PERMIT O8B0.RESUME CLASS(HBRCMD) ID(IBMUSER) ACCESS(UPDATE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B0.DUMP CLASS(HBRCMD) ID(IBMUSER) ACCESS(UPDATE)"
PERMIT O8B0.DUMP CLASS(HBRCMD) ID(IBMUSER) ACCESS(UPDATE)
```

##### Starting a new server instance
zRES Console, zRES x2 を起動してみます。

S O8B0MSTR
S O8B1MSTR
S O8B2MSTR

RESコンソールにブラウザからアクセスしてみます。
`http://<servername>:34114/res`
IBMUSERでログイン
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/132331/c912160f-2fc1-566d-9242-ae7d1ecafcf1.png)

ログインできました。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/132331/b59d4ec8-56ab-49a9-887f-72fc34df2b62.png)


### Step 9: Verifying your rule execution environment configuration

RESコンソールにログインして、診断タブを開き、再実行ボタンをクリックします。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/132331/478e8660-cf45-356a-1286-73041db1f64f.png)

×が消えればOKです。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/132331/e3d4d22e-811d-1d7d-7901-d62c9a43d9f2.png)

### Configuring your system to collect execution data
参考: [Configuring zRule Execution Server for z/OS® to collect execution data](https://www.ibm.com/docs/en/odm/8.11.0?topic=cysced-configuring-zrule-execution-server-zos-collect-execution-data)
上の記述を参考に、SMF関連のRACF設定しておきます。

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT BPX.SMF CLASS(FACILITY) ID(ODMUSER) ACCESS(READ)"
PERMIT BPX.SMF CLASS(FACILITY) ID(ODMUSER) ACCESS(READ)
ICH06011I RACLISTED PROFILES FOR FACILITY WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "SETROPTS RACLIST(FACILITY) REFRESH"
SETROPTS RACLIST(FACILITY) REFRESH
```

## 稼働確認

### サンプル・ルールのデプロイ
以下を参考に、サンプルとして提供されているルールをzRESにデプロイしてみます。
[Deploying RuleApps and XOMs automatically by using JCL](https://www.ibm.com/docs/en/odm/8.11.0?topic=xoms-deploying-ruleapps-automatically-by-using-jcl)

ODM811.WORK.O8B0.SHBRJCL(HBRDPLOY)に生成されたJCLをカスタマイズして実行します。

※生成されたJCLをそのまま実行すると、` .: deploy.sh: not found` というエラーになりました。カレントディレクトリにパスが通っていないためと思われます。そのため、"deploy.sh"を実行している部分を、以下のように`. deploy.sh` ⇒ `. ./deploy.sh` というように修正してからJCLサブミットします。

```xxx:ODM811.WORK.O8B0.SHBRJCL(HBRDPLOY) 
//HBRDPLOY EXEC PGM=IKJEFT01,REGION=0M,TIME=NOLIMIT
//SYSTSPRT DD  SYSOUT=*
//STDOUT   DD  SYSOUT=*
//STDERR   DD  SYSOUT=*
//SYSTSIN  DD  *
  BPXBATCH SH +
  cd /usr/lpp/zDM/V8R11ML+
  /zexecutionserver/samples/ruleApps; +
  . ./deploy.sh +
  /usr/lpp/java/J8.0_64 +
  /usr/lpp/zDM/V8R11ML+
  /shared/tools/ant +
  DB2 +
  -DHBRINSTPATH=/usr/lpp/zDM/V8R11ML +
  -DHBRWORKPATH=/var/zDM/V8R11ML +
  -DRULEAPPNAME=MiniLoanDemo +
  -DLIBNAME=MiniLoanDemoRuleApp_1.0 +
  -DDB2SERVNAME=localhost +
  -DDB2PORT=5040 +
  -DDB2LOCATION=DALLASC +
  -DDB2SCHEMA=ODM811 +
  -DDB2USER=IBMUSER +
  -DDB2PASSWORD=SYS1 +
  -DDB2JARLOCN=/usr/lpp/db2c10/jdbc/classes
/*
```

ログ

```
 Buildfile: build.xml
      [echo] executionserver.home is /usr/lpp/zDM/V8R11ML/executionserver
      [echo] HBRINSTPATH is /usr/lpp/zDM/V8R11ML
      [echo] HBRWORKPATH is /var/zDM/V8R11ML
      [echo] RULEAPPNAME is MiniLoanDemo

 db2.deploy:
 [res-write-db] Decision Server 8.11.0.0
 [res-write-db] [URL] jdbc:db2://localhost:5040/DALLASC:currentSchema=ODM811;
 [res-write-db] [file] /Z24D/usr/lpp/zDM/V8R11ML/zexecutionserver/samples/ruleApps/MiniLoanDemo/MiniLoanDemoRuleApp.jar
 [res-write-db] [driver] com.ibm.db2.jcc.DB2Driver
 [res-write-db] [classpath] /usr/lpp/db2c10/jdbc/classes/db2jcc.jar:/usr/lpp/db2c10/jdbc/classes/db2jcc_license_cisuz.jar
 [res-write-db] [mergingpolicy] REPLACE_MERGING_POLICY
 [res-write-db] [versioningpolicy] MINOR_VERSION_POLICY
 [res-write-db] [resourceVersioningPolicy] MAJOR_VERSION_POLICY
 [res-write-db] [libraryVersioningPolicy] MINOR_VERSION_POLICY
 [res-write-db] Jan 30, 2022 10:46:28 PM com.ibm.rules.res.logging.internal.RESLogger log
 [res-write-db] INFO: XOM repository set in database persistence mode: DB2 DSN12015
 [res-write-db] Jan 30, 2022 10:46:32 PM com.ibm.rules.res.logging.internal.RESLogger log
 [res-write-db] INFO: RESMGMT persistence: Adding RuleApp "/MiniLoanDemoRuleApp/1.0".
 [res-write-db] Jan 30, 2022 10:46:45 PM com.ibm.rules.res.logging.internal.RESLogger log
 [res-write-db] INFO: RESMGMT persistence: RuleApp "/MiniLoanDemoRuleApp/1.0" is added.
 [res-write-db] Deployed RuleApps and rulesets:
 [res-write-db]         /MiniLoanDemoRuleApp/1.0 -> /MiniLoanDemoRuleApp/1.0: Element added.
 [res-write-db]         /MiniLoanDemoRuleApp/1.0/MiniLoanDemo/1.0 -> /MiniLoanDemoRuleApp/1.0/MiniLoanDemo/1.0: Element added.
 [res-write-db] Write succeeded.
 [res-write-xom-db] Decision Server 8.11.0.0
 [res-write-xom-db] [+] /Z24D/usr/lpp/zDM/V8R11ML/zexecutionserver/samples/ruleApps/MiniLoanDemo/MiniLoanDemo-plibmarshaller.jar
 [res-write-xom-db] [+] /Z24D/usr/lpp/zDM/V8R11ML/zexecutionserver/samples/ruleApps/MiniLoanDemo/MiniLoanDemo-xom-xmarshaller.jar
 [res-write-xom-db] [+] /Z24D/usr/lpp/zDM/V8R11ML/zexecutionserver/samples/ruleApps/MiniLoanDemo/MiniLoanDemo-xom.zip
 [res-write-xom-db] ruleset.managedxom.uris = reslib://MiniLoanDemoRuleApp_1.0/1.0
 [res-write-xom-db] Write succeeded.

 BUILD SUCCESSFUL
 Total time: 2 minutes 2 seconds
```

zRESにブラウザからアクセスするとエクスプローラータブにてMiniLoanDemoRuleAppがデプロイされていることが確認できます。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/132331/a586a073-378f-ef4a-b167-ee56bfa4a9a2.png)


### COBOLバッチからのルール呼び出し

COBOLバッチから上のルールを呼び出すCOBOLバッチのサンプルが提供されているので、それを動かしてみます。

参考:
[Sample: Running an application as a batch job](https://www.ibm.com/docs/en/odm/8.11.0?topic=samples-sample-running-application-as-batch-job)
[Calling zRule Execution Server for z/OS from a batch application](https://www.ibm.com/docs/en/odm/8.11.0?topic=eaczesz-calling-zrule-execution-server-zos-from-batch-application)


ODM811.WORK.O8B0.SHBRJCL(HBRMINB)に生成されたJCLをそのままサブミット。

```xxx:ODM811.WORK.O8B0.SHBRJCL(HBRMINB)
//HBRMINB JOB MSGCLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//**********************************************************************
//* <copyright                                                         *
//* notice="lm-source-program"                                         *
//* pids="5655-Y31"                                                    *
//* years="2012,2017"                                                  *
//* crc="3403398131" >                                                 *
//* Licensed Materials - Property of IBM                               *
//*                                                                    *
//* 5655-Y31                                                           *
//*                                                                    *
//* (C) Copyright IBM Corp. 2012, 2017 All Rights Reserved.            *
//*                                                                    *
//* US Government Users Restricted Rights - Use, duplication or        *
//* disclosure restricted by GSA ADP Schedule Contract with            *
//* IBM Corp.                                                          *
//* </copyright>                                                       *
//**********************************************************************
//HBRSAMP1 EXEC PGM=HBRMINB,REGION=0M
//         SET HBRHLQ=ODM811.TLIB
//         SET HBRWDS=ODM811.WORK.O8B0
//STEPLIB  DD DISP=SHR,DSN=&HBRHLQ..SHBRLOAD
//SYSUDUMP DD SYSOUT=*
//HBRENVPR DD DISP=SHR,DSN=&HBRWDS..SHBRPARM(HBRBATCH)
//**********************************************************************
//* See miniloan-test.xls
//* name,creditscore,yearlyIncome,age
//* amount,yearlyinterestRate,yearlyRepayment
//*
//**********************************************************************
//SCENARIO DD DISP=SHR,DSN=&HBRWDS..SHBRPARM(HBRSCEN)
//*
```

<details><summary><font color="blue">参考: COBOLバッチのソース</font></summary><div>

上のJCLで実行されるルール呼び出しを行うCOBOLバッチのソースです。

```cobol:ODM811.TLIB.SHBRCOBS(HBRMINB)
      * <copyright
      * notice="lm-source-program"
      * pids="5655-Y31"
      * years="2012,2019"
      * crc="341629201" >
      * Licensed Materials - Property of IBM
      *
      * 5655-Y31
      *
      * (C) Copyright IBM Corp. 2012, 2019 All Rights Reserved.
      *
      * US Government Users Restricted Rights - Use, duplication or
      * disclosure restricted by GSA ADP Schedule Contract with
      * IBM Corp.
      * </copyright>

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HBRMINB.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT SCENARIO-FILE
               ASSIGN TO S-SCENARIO
               ORGANIZATION    SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD  SCENARIO-FILE
           RECORDING MODE    F
           LABEL RECORD STANDARD.
       01 SCENARIO-AREA.
          05 SCENARIO-DATA            PIC X(496).

       WORKING-STORAGE SECTION.
       01 WS-EOF                       PIC X.
          88 WS-FILE-AT-EOF               VALUE "Y".
          88 WS-FILE-NOT-AT-EOF           VALUE "N".
       01  WS-IN.
          05  WS-IN-DATA               PIC  X(50) OCCURS 8 TIMES.

       01 MY-LOCAL-STORAGE.
          02 WS-PROGRAM                PIC X(8)
                                          VALUE "MINILOAN".
          02 FILLER                    PIC X(4)
                                          VALUE "-WS>".
       COPY HBRLDAT1.

       01 WS-MAX-MESSAGE-LEN           PIC 9(10).
       01 WS-CUSTOMERNUMBER            PIC 9(4)
                                          VALUE ZERO.
       01 WS-MSGCOUNT                  PIC 9(10).
       01 WS-START-TIME                PIC 9(12)
                                          VALUE ZERO.
       01 WS-END-TIME                  PIC 9(12)
                                          VALUE ZERO.
       01 WS-DURATION-TIME             PIC 9(12)
                                          VALUE ZERO.

       01 WS-DURATION-PRINT    REDEFINES WS-DURATION-TIME.
          02 WS-HOURS-PRINT            PIC 9(2).
          02 WS-MINS-PRINT             PIC 9(2).
          02 WS-SECS-PRINT             PIC 9(2).
          02 WS-TENTHS-PRINT           PIC 9(1).
          02 WS-HUNDREDTHS-PRINT       PIC 9(1).
          02 WS-MILLIS-PRINT           PIC 9(1).
          02 WS-TENTHOU-PRINT          PIC 9(1).
          02 WS-HUNTHOU-PRINT          PIC 9(1).
          02 WS-MICROS-PRINT           PIC 9(1).

       01 WS-DEMO-OUTCOME              PIC X.
          88 WS-DEMO-OUTCOME-GOOD          VALUE "T".
          88 WS-DEMO-OUTCOME-FAIL          VALUE "F".

       01 WS-HBR-REASON-CODES.
       COPY HBRC.

       COPY HBRWS.

      ******************************************************************
       PROCEDURE DIVISION.
      ******************************************************************
       MAIN SECTION.
      ******************************************************************
       MAIN-DO.
      * Initialise
      *    Posit a good outcome!
           SET WS-DEMO-OUTCOME-GOOD TO TRUE.

           DISPLAY WS-PROGRAM ' --Miniloan Demo on zOS Batch '.

      * Open input file
           OPEN INPUT SCENARIO-FILE.

      * Execute the core logic
           PERFORM MAIN-PROCESSING.

      * Close input file
           CLOSE SCENARIO-FILE.

      * End
           IF WS-DEMO-OUTCOME-GOOD
              DISPLAY WS-PROGRAM ' --SUCCESSFUL COMPLETION of demo'
              MOVE ZERO             TO RETURN-CODE
           ELSE
              DISPLAY WS-PROGRAM ' --demo completed with ERRORS'
              DISPLAY WS-PROGRAM ' --please review logs and rerun '
              DISPLAY WS-PROGRAM ' --with trace as needed.'
              MOVE 8                TO RETURN-CODE
           END-IF.
      ******************************************************************
       MAIN-EXIT.
           GOBACK.
      ******************************************************************
      ******************************************************************


      ******************************************************************
       MAIN-PROCESSING SECTION.
      ******************************************************************
       MAIN-PROCESSING-DO.
      *    Connect
           PERFORM MAIN-CONNECT.

           IF  HBRA-CONN-COMPLETION-CODE = HBR-CC-ERROR OR
           HBRA-CONN-COMPLETION-CODE = HBR-CC-SEVERE THEN
      *       Abort as error encountered!
              GO TO MAIN-PROCESSING-EXIT
           END-IF.

      *    Initial read
           PERFORM READ-NEXT-FROM-FILE.

      *    For each record found
           PERFORM UNTIL WS-FILE-AT-EOF
                   ADD 1                 TO WS-CUSTOMERNUMBER
                   PERFORM PROCESS-DATA
                   PERFORM READ-NEXT-FROM-FILE
           END-PERFORM.

      *    Disconnect
           PERFORM MAIN-DISCONNECT.

      ******************************************************************
       MAIN-PROCESSING-EXIT.
           EXIT.
      *

      ******************************************************************
       MAIN-CONNECT SECTION.
      ******************************************************************
       MAIN-CONNECT-DO.
      *
           DISPLAY WS-PROGRAM ' --Connecting to rule execution server'

           CALL 'HBRCONN' USING HBRA-CONN-AREA.

           IF HBRA-CONN-COMPLETION-CODE = HBR-CC-ERROR OR
           HBRA-CONN-COMPLETION-CODE = HBR-CC-SEVERE
      *
      *       We've hit an error condition, so report!
      *
      *       Admit failure!
              SET WS-DEMO-OUTCOME-FAIL TO TRUE
      *
              DISPLAY WS-PROGRAM ' --' 'HBRCONN FAILED'
              '-CC->'  HBRA-CONN-COMPLETION-CODE
              '-RC->'  HBRA-CONN-REASON-CODE
              '-MSG->' HBRA-RESPONSE-MESSAGE
           ELSE
              IF HBRA-CONN-COMPLETION-CODE EQUAL TO HBR-CC-WARNING

                 DISPLAY WS-PROGRAM  ' --' 'HBRCONN WARNING'
                 '-CC->'  HBRA-CONN-COMPLETION-CODE
                 '-RC->'  HBRA-CONN-REASON-CODE
                 '-MSG->' HBRA-RESPONSE-MESSAGE
              ELSE

                 DISPLAY WS-PROGRAM  '   Connection successful'
              END-IF
           END-IF.
      *
      ******************************************************************
       MAIN-CONNECT-EXIT.
           EXIT.
      *

      ******************************************************************
       MAIN-DISCONNECT SECTION.
      ******************************************************************
       MAIN-DISCONNECT-DO.
      *
           DISPLAY WS-PROGRAM
           ' --Disconnecting from rule execution server'

           CALL 'HBRDISC' USING HBRA-CONN-AREA.

           IF HBRA-CONN-COMPLETION-CODE NOT EQUAL HBR-CC-OK
      *
      *       We've hit an error condition, so report!
      *
      *       Admit failure!
              SET WS-DEMO-OUTCOME-FAIL TO TRUE
      *
              DISPLAY WS-PROGRAM ' --' 'HBRDISC FAILED'
              '-CC->' HBRA-CONN-COMPLETION-CODE
              '-RC->' HBRA-CONN-REASON-CODE
           ELSE

              DISPLAY WS-PROGRAM  '   Disconnection successful'
           END-IF.
      *
      ******************************************************************
       MAIN-DISCONNECT-EXIT.
           EXIT.
      *
      ******************************************************************
       PROCESS-DATA SECTION.
      ******************************************************************
       PROCESS-DATA-DO.
      *
      * Initialize call parameters
      *
           MOVE ALL SPACES          TO BORROWER LOAN
           MOVE ALL LOW-VALUES      TO HBRA-RA-PARMETERS
           MOVE "/MiniLoanDemoRuleApp/MiniLoanDemo"
           TO HBRA-CONN-RULEAPP-PATH

           MOVE LENGTH OF BORROWER  TO HBRA-RA-DATA-LENGTH(1)
           MOVE "borrower"          TO HBRA-RA-PARAMETER-NAME(1)
           SET HBRA-RA-DATA-ADDRESS(1)
           TO ADDRESS OF BORROWER

           MOVE LENGTH OF LOAN      TO HBRA-RA-DATA-LENGTH(2)
           MULTIPLY LENGTH OF MESSAGES
           BY 99
           GIVING WS-MAX-MESSAGE-LEN
           ADD  WS-MAX-MESSAGE-LEN  TO HBRA-RA-DATA-LENGTH(2)
           MOVE "loan"              TO HBRA-RA-PARAMETER-NAME(2)
           SET  HBRA-RA-DATA-ADDRESS(2)
           TO ADDRESS OF LOAN

      *
      * Read scenario data
      *
           MOVE ALL LOW-VALUES      TO WS-IN
           UNSTRING SCENARIO-DATA DELIMITED BY ','
           INTO
           WS-IN-DATA(1) WS-IN-DATA(2) WS-IN-DATA(3)
           WS-IN-DATA(4) WS-IN-DATA(5) WS-IN-DATA(6)
           WS-IN-DATA(7) WS-IN-DATA(8)

           MOVE    WS-IN-DATA(1)    TO NAME
           COMPUTE CREDITSCORE      =  FUNCTION NUMVAL(WS-IN-DATA(2))
           COMPUTE YEARLYINCOME     =  FUNCTION NUMVAL(WS-IN-DATA(3))
           COMPUTE AGE              =  FUNCTION NUMVAL(WS-IN-DATA(4))

           COMPUTE AMOUNT           =  FUNCTION NUMVAL(WS-IN-DATA(5))
           COMPUTE YEARLYINTERESTRATE
           =  FUNCTION NUMVAL(WS-IN-DATA(6))
           COMPUTE YEARLYREPAYMENT  =  FUNCTION NUMVAL(WS-IN-DATA(7))

           MOVE    WS-IN-DATA(8)    TO EFFECTDATE
           MOVE    'T'              TO APPROVED
           MOVE    0                TO MESSAGECOUNT

           DISPLAY WS-PROGRAM ' --Loan customer ' WS-CUSTOMERNUMBER
      *
      * Invoke the rule
      *
           DISPLAY WS-PROGRAM
           ' -- Invoking rules in rule execution server'

           CALL 'HBRRULE' USING HBRA-CONN-AREA
      *
      * Display rule responses, or error code, as appropriate
      *
           IF HBRA-CONN-COMPLETION-CODE = HBR-CC-OK

              DISPLAY WS-PROGRAM ' --'
              ' Rule executed in ->' HBRA-CONN-SSID

              DISPLAY WS-PROGRAM ' --'
              ' Start time ->' HBRA-TIME-STAMP-START

              DISPLAY WS-PROGRAM ' --'
              ' End time   ->' HBRA-TIME-STAMP-END

              COMPUTE WS-START-TIME =
                  FUNCTION NUMVAL(HBRA-TIME-STAMP-START)

              COMPUTE WS-END-TIME =
                  FUNCTION NUMVAL(HBRA-TIME-STAMP-END)

              SUBTRACT WS-START-TIME FROM WS-END-TIME
                  GIVING WS-DURATION-TIME

              DISPLAY WS-PROGRAM ' --'
              ' Duration   ->' WS-SECS-PRINT '.' WS-TENTHS-PRINT
              WS-HUNDREDTHS-PRINT WS-MILLIS-PRINT WS-TENTHOU-PRINT
              WS-HUNTHOU-PRINT WS-MICROS-PRINT ' seconds'

              DISPLAY WS-PROGRAM ' --'
              ' Execution ID ->' HBRA-EXECUTION-ID

              DISPLAY WS-PROGRAM ' --'
              ' name->'         NAME
              ' -loan amount->' AMOUNT
              ' -approved->'    APPROVED

              MOVE 1                TO WS-MSGCOUNT

              DISPLAY WS-PROGRAM ' --' ' messages->'

              PERFORM UNTIL WS-MSGCOUNT >  MESSAGECOUNT
                      DISPLAY WS-PROGRAM ' --    '
                      MESSAGES(WS-MSGCOUNT)

                      ADD 1              TO WS-MSGCOUNT
              END-PERFORM
           ELSE
      *
      *       We've hit an error condition, so report!
      *
      *       Admit failure!
              SET WS-DEMO-OUTCOME-FAIL TO TRUE
      *
              DISPLAY WS-PROGRAM ' --'
              '-CC->'  HBRA-CONN-COMPLETION-CODE
              '-RC->'  HBRA-CONN-REASON-CODE
              '-MSG->' HBRA-RESPONSE-MESSAGE
           END-IF.
      *
      ******************************************************************
       PROCESS-DATA-EXIT.
           EXIT.
      *
      ******************************************************************
       READ-NEXT-FROM-FILE SECTION.
      ******************************************************************
       READ-NEXT-FROM-FILE-DO.
      *
           READ SCENARIO-FILE
           AT END SET WS-FILE-AT-EOF TO TRUE.
      ******************************************************************
       READ-NEXT-FROM-FILE-EXIT.
           EXIT.
```

</div></details>


ログ

```
 MINILOAN --Miniloan Demo on zOS Batch
 MINILOAN --Connecting to rule execution server
 MINILOAN   Connection successful
 MINILOAN --Loan customer 0001
 MINILOAN -- Invoking rules in rule execution server
 MINILOAN -- Rule executed in ->O8B1
 MINILOAN -- Start time ->051610801714
 MINILOAN -- End time   ->051640223787
 MINILOAN -- Duration   ->29.422073 seconds
 MINILOAN -- Execution ID ->e2b10581-29b9-419f-b276-5cb2ed6577200
 MINILOAN -- name->Joe                  -loan amount->0000500000 -approved->T
 MINILOAN -- messages->
 MINILOAN --Loan customer 0002
 MINILOAN -- Invoking rules in rule execution server
 MINILOAN -- Rule executed in ->O8B1
 MINILOAN -- Start time ->051640225480
 MINILOAN -- End time   ->051640338732
 MINILOAN -- Duration   ->00.113252 seconds
 MINILOAN -- Execution ID ->e2b10581-29b9-419f-b276-5cb2ed6577201
 MINILOAN -- name->John                 -loan amount->0000250000 -approved->F
 MINILOAN -- messages->
 MINILOAN --    The age exceeds the maximum.
 MINILOAN --Loan customer 0003
 MINILOAN -- Invoking rules in rule execution server
 MINILOAN -- Rule executed in ->O8B1
 MINILOAN -- Start time ->051640340012
 MINILOAN -- End time   ->051640378839
 MINILOAN -- Duration   ->00.038827 seconds
 MINILOAN -- Execution ID ->e2b10581-29b9-419f-b276-5cb2ed6577202
 MINILOAN -- name->Sarah                -loan amount->0000500000 -approved->F
 MINILOAN -- messages->
 MINILOAN --    Debt-to-income too high compared to credit score
 MINILOAN --Loan customer 0004
 MINILOAN -- Invoking rules in rule execution server
 MINILOAN -- Rule executed in ->O8B1
 MINILOAN -- Start time ->051640380493
 MINILOAN -- End time   ->051640425041
 MINILOAN -- Duration   ->00.044548 seconds
 MINILOAN -- Execution ID ->e2b10581-29b9-419f-b276-5cb2ed6577203
 MINILOAN -- name->Andy                 -loan amount->0000500000 -approved->F
 MINILOAN -- messages->
 MINILOAN --    Debt-to-income ratio is greater than 49%
 MINILOAN --Loan customer 0005
 MINILOAN -- Invoking rules in rule execution server
 MINILOAN -- Rule executed in ->O8B1
 MINILOAN -- Start time ->051640426967
 MINILOAN -- End time   ->051640473897
 MINILOAN -- Duration   ->00.046930 seconds
 MINILOAN -- Execution ID ->e2b10581-29b9-419f-b276-5cb2ed6577204
 MINILOAN -- name->David                -loan amount->0000250000 -approved->F
 MINILOAN -- messages->
 MINILOAN --    The yearly income is lower than the basic request
 MINILOAN --Loan customer 0006
 MINILOAN -- Invoking rules in rule execution server
 MINILOAN -- Rule executed in ->O8B1
 MINILOAN -- Start time ->051640475794
 MINILOAN -- End time   ->051640520191
 MINILOAN -- Duration   ->00.044397 seconds
 MINILOAN -- Execution ID ->e2b10581-29b9-419f-b276-5cb2ed6577205
 MINILOAN -- name->Michelle             -loan amount->0001000100 -approved->F
 MINILOAN -- messages->
 MINILOAN --    The loan cannot exceed 1000000
 MINILOAN --Disconnecting from rule execution server
 MINILOAN   Disconnection successful
 MINILOAN --SUCCESSFUL COMPLETION of demo
```

正常に完了しました。

### CICS-COBOLアプリからのルール呼び出し

#### CICS関連設定

上で保留にしていたCICS関連設定を行います。
参考: [Configuring CICS to execute rules on zRule Execution Server for z/OS](https://www.ibm.com/docs/en/odm/8.11.0?topic=ct1zesgsc-configuring-cics-execute-rules-zrule-execution-server-zos)

##### 資源定義追加

ODM811.WORK.CICS.SHBRJCL(HBRCSD)に生成されるJCLをサブミットします。

<details><summary><font color="blue">参考: ODM811.WORK.CICS.SHBRJCL(HBRCSD)</font></summary><div>

```xxx:ODM811.WORK.CICS.SHBRJCL(HBRCSD)
//HBRCSD JOB MSGCLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//**********************************************************************
//* <copyright                                                         *
//* notice="lm-source-program"                                         *
//* pids="5655-Y31"                                                    *
//* years="2012,2021"                                                  *
//* crc="3502305522" >                                                 *
//* Licensed Materials - Property of IBM                               *
//*                                                                    *
//* 5655-Y31                                                           *
//*                                                                    *
//* (C) Copyright IBM Corp. 2012, 2021 All Rights Reserved.            *
//*                                                                    *
//* US Government Users Restricted Rights - Use, duplication or        *
//* disclosure restricted by GSA ADP Schedule Contract with            *
//* IBM Corp.                                                          *
//* </copyright>                                                       *
//**********************************************************************
//*                                                                    *
//* This job will define the CICS resources required by                *
//* IBM ODM for zOS                                                    *
//*                                                                    *
//* CAUTION: This is not a complete job.                               *
//* Before submitting this job, make the following modifications:      *
//*                                                                    *
//* 1) Add the job parameters to meet your system requirements.        *
//*                                                                    *
//* 2) Change ++CICSHLQ++ to the appropriate high level quailifier     *
//*    for CICS - for example:                                         *
//*    change '++CICSHLQ++' to 'CTS320.CICS'                           *
//*                                                                    *
//* 3) Change ++CICSCSDDSN++ to the appropriate high level qualifier   *
//*    for the CICS system - for example:                              *
//*    change '++CICSCSDDSN++' to 'CTS320.APPLID.DFHCSD'               *
//*                                                                    *
//* 4) Change '++CICSLIST++' to your CICS startup GRPLIST for example: *
//*    change '++CICSLIST++' to 'HBRLIST'                              *
//*                                                                    *
//* Note: Some ++variables++ in this job will be substituted with the  *
//* values specified in the HBRINST member as part of the              *
//* configuration process. See the documentation for more details.     *
//*                                                                    *
//* Expected return code: 4 on first invocation as HBRGROUP does not   *
//*                         exist.                                     *
//*                                                                    *
//*                       0 on subsequent executions.                  *
//*                                                                    *
//**********************************************************************
//*   DEFINE CICS RESOURCES                                            *
//**********************************************************************
//*
//DEFCSD  EXEC PGM=DFHCSDUP,REGION=4M
//STEPLIB  DD DISP=SHR,DSN=DFH560.CICS.SDFHLOAD
//DFHCSD   DD DISP=SHR,DSN=DFH560.CICS.DFHCSD
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
* IBM ODM for zOS resources
 DELETE GROUP(HBRGROUP) ALL

* ODM API calls for applications using dynamic binding
 DEFINE PROGRAM(HBRCONN)       GROUP(HBRGROUP)
      LANGUAGE(ASSEMBLER)      RELOAD(NO)             EXECKEY(USER)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(NO)               DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS)
 DEFINE PROGRAM(HBRRULE)       GROUP(HBRGROUP)
      LANGUAGE(ASSEMBLER)      RELOAD(NO)             EXECKEY(USER)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(NO)               DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS)
 DEFINE PROGRAM(HBRDISC)       GROUP(HBRGROUP)
      LANGUAGE(ASSEMBLER)      RELOAD(NO)             EXECKEY(USER)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(NO)               DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS)

* ODM transactions and programs
 DEFINE TRANSACTION(HBRC)      GROUP(HBRGROUP)        PROGRAM(HBRCCON)
        DESCRIPTION(IBM ODM for zOS)
        TWASIZE(0)             PROFILE(DFHCICST)
                               STATUS(ENABLED)
        PRIORITY(1)            TASKDATALOC(ANY)       TASKDATAKEY(CICS)
                                                      RESTART(NO)
        SPURGE(NO)             TPURGE(NO)             DUMP(YES)
        TRACE(YES)
        RESSEC(YES)
 DEFINE TRANSACTION(HBRD)      GROUP(HBRGROUP)        PROGRAM(HBRCDSCO)
        DESCRIPTION(IBM ODM for zOS)
        TWASIZE(0)             PROFILE(DFHCICST)
                               STATUS(ENABLED)
        PRIORITY(1)            TASKDATALOC(ANY)       TASKDATAKEY(CICS)
                                                      RESTART(NO)
        SPURGE(NO)             TPURGE(NO)             DUMP(YES)
        TRACE(YES)
        RESSEC(YES)
 DEFINE PROGRAM(HBRCCON)       GROUP(HBRGROUP)
      LANGUAGE(ASSEMBLER)      RELOAD(NO)             EXECKEY(CICS)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(YES)              DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS)
 DEFINE PROGRAM(HBRCDSCO)      GROUP(HBRGROUP)
      LANGUAGE(ASSEMBLER)      RELOAD(NO)             EXECKEY(CICS)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(YES)              DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS)
 DEFINE PROGRAM(HBRCCMSG)      GROUP(HBRGROUP)
      LANGUAGE(ASSEMBLER)      RELOAD(NO)             EXECKEY(USER)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(YES)              DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS)
 DEFINE PROGRAM(HBRCTRUA)      GROUP(HBRGROUP)
      LANGUAGE(ASSEMBLER)      RELOAD(NO)             EXECKEY(USER)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(YES)              DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS)
 DEFINE PROGRAM(HBRCTRUE)      GROUP(HBRGROUP)
      LANGUAGE(ASSEMBLER)      RELOAD(NO)             EXECKEY(USER)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(YES)              DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS)

*
* Uncomment and customise this definition if you are configuring a
* CICS AOR.   Ensure that you customise the REMOTESYSTEM
*
*  DEFINE PROGRAM(HBRCJVMS)       GROUP(HBRGROUP)
*      STATUS(ENABLED)            DYNAMIC(NO)
*      REMOTESYSTEM(<ROR CONNECTION ID>) REMOTENAME(HBRCJVMS)
*      DESCRIPTION(IBM ODM for zOS)
*

 DEFINE TDQUEUE(HBRC)          GROUP(HBRGROUP)
      DESCRIPTION(IBM ODM for zOS)
      TYPE(EXTRA)              TYPEFILE(OUTPUT)
      RECORDSIZE(496)          BLOCKSIZE(27776)
      RECORDFORMAT(VARIABLE)   BLOCKFORMAT(UNBLOCKED)
      DDNAME(HBRPRINT)         OPENTIME(INITIAL)

*
 DEFINE TDQUEUE(HBRE)          GROUP(HBRGROUP)
      DESCRIPTION(IBM ODM for zOS)
      TYPE(EXTRA)              TYPEFILE(INPUT)
      RECORDSIZE(496)          BLOCKSIZE(27776)
      RECORDFORMAT(FIXED)      BLOCKFORMAT(BLOCKED)
      DDNAME(HBRENVPR)         OPENTIME(DEFERRED)

*
 DEFINE TDQUEUE(SCEN)          GROUP(HBRGROUP)
      DESCRIPTION(IBM ODM for zOS)
      TYPE(EXTRA)              TYPEFILE(INPUT)
      RECORDSIZE(496)           BLOCKSIZE(27776)
      RECORDFORMAT(FIXED)      BLOCKFORMAT(BLOCKED)
      DDNAME(SCENARIO)         OPENTIME(DEFERRED)


 DEFINE PROGRAM(HBRMINC)       GROUP(HBRGROUP)
      LANGUAGE(COBOL)      RELOAD(NO)             EXECKEY(USER)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(YES)              DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS COBOL MiniLoan demo)

 DEFINE PROGRAM(HBRMINCP)       GROUP(HBRGROUP)
      LANGUAGE(PLI)        RELOAD(NO)             EXECKEY(USER)
      RESIDENT(NO)             USAGE(NORMAL)          USELPACOPY(NO)
      STATUS(ENABLED)          CEDF(YES)              DATALOCATION(ANY)
      CONCURRENCY(THREADSAFE)
      DESCRIPTION(IBM ODM for zOS PLI MiniLoan demo)

 DEFINE TRANSACTION(MINI)      GROUP(HBRGROUP)        PROGRAM(HBRMINC)
      DESCRIPTION(IBM ODM for zOS transaction for demo)
        TWASIZE(0)             PROFILE(DFHCICST)
                               STATUS(ENABLED)
        PRIORITY(1)            TASKDATALOC(ANY)       TASKDATAKEY(USER)
                                                      RESTART(NO)
        SPURGE(NO)             TPURGE(NO)             DUMP(YES)
        TRACE(YES)
        RESSEC(YES)

 DEFINE TRANSACTION(MINP)      GROUP(HBRGROUP)        PROGRAM(HBRMINCP)
      DESCRIPTION(IBM ODM for zOS transaction for demo)
        TWASIZE(0)             PROFILE(DFHCICST)
                               STATUS(ENABLED)
        PRIORITY(1)            TASKDATALOC(ANY)       TASKDATAKEY(USER)
                                                      RESTART(NO)
        SPURGE(NO)             TPURGE(NO)             DUMP(YES)
        TRACE(YES)
        RESSEC(YES)
*
* Add Group HBRGROUP to your start up list
ADD GROUP(HBRGROUP) LIST(HBRLIST)
*
/*
//*
```

</div></details>

これで、CSDにODMアクセスに必要な資源が含まれた資源グループが追加されます。

##### 起動プロシージャー変更

次に、CICS起動プロシージャーを編集し、以下の変更を行います。

- CICS起動プロシージャーのDFHRPL DDに ODM811.TLIB.SHBRCICS を追加
- HBRENVPR DD、SCENARIO DDを追加

```xxx:FEU.Z24D.PROCLIB(CICSTS56)抜粋
...

//DFHRPL   DD DSN=&INDEX2..SDFHLOAD,DISP=SHR
//         DD DSN=&INDEX3..SEYULOAD,DISP=SHR
//         DD DSN=CEE.SCEECICS,DISP=SHR
//         DD DSN=CEE.SCEERUN2,DISP=SHR
//         DD DSN=CEE.SCEERUN,DISP=SHR
//         DD DSN=TCPIP.SEZATCP,DISP=SHR
//         DD DSN=EQAF00.SEQAMOD,DISP=SHR
//         DD DSN=SYS1.MIGLIB,DISP=SHR
//         DD DSN=SYS1.SIEAMIGE,DISP=SHR
//         DD DSN=DFH560.EQAIVP.LOAD,DISP=SHR
//         DD DSN=ODM811.TLIB.SHBRCICS,DISP=SHR

...

//* ODM811
//HBRENVPR DD DISP=SHR,DSN=ODM811.WORK.CICS.SHBRPARM(HBRCICSZ)
//         DD DISP=SHR,DSN=ODM811.WORK.CICS.SHBRPARM(HBRCMMN)
//SCENARIO DD DISP=SHR,DSN=ODM811.WORK.CICS.SHBRPARM(HBRSCEN)

...

```

##### RACF設定

CICS実行ユーザーからODMアクセスできるようRACF設定を行う。

```
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B1 CLASS(HBRCONN) ID(CICSUSER) ACCESS(UPDATE)"
PERMIT O8B1 CLASS(HBRCONN) ID(CICSUSER) ACCESS(UPDATE)
TAGUCHI:/u/TAGUCHI/ODM811/Config: >tsocmd "PERMIT O8B2 CLASS(HBRCONN) ID(CICSUSER) ACCESS(UPDATE)"
PERMIT O8B2 CLASS(HBRCONN) ID(CICSUSER) ACCESS(UPDATE)
```

#### サンプル・トランザクション実行

##### 1. 資源定義
CICS端末エミュレーターに接続し、資源グループ"HBRGROUP"をインストールする。

##### 2. 接続
ODMとの接続用のトランザクション "HBRC"を実行！
画面上に`GBRZC9001I RC=0000`が返されればOKです。

##### 3.サンプル実行
Mini Loanのサンプルアプリケーション"MINI"を実行します。

以下のように処理内容が画面に表示されます。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/132331/7c767561-c00e-53dd-4059-fdaffb5485d0.png)

3270画面だと見にくいので、JOBLOGのCEEMSGを確認します。

```CEEMSG
0023MINI 20220131234956 MINICICS -Miniloan Demo on CICS                                             
0023MINI 20220131234956 MINICICS --connecting to rule execution server                              
0023MINI 20220131234956 MINICICS --Loan customer 0000000001                                         
0023MINI 20220131234956 MINICICS --about to call rule execution server                              
0023MINI 20220131235022 MINICICS -- Rule executed in-O8B1                                           
0023MINI 20220131235022 MINICICS--Execution ID-d17e5005-6029-4a36-87a0-e29e80c5fdee0                
0023MINI 20220131235022 MINICICS--name-Joe                 loan amount-0000500000-approved-T        
0023MINI 20220131235022 MINICICS --Loan customer 0000000002                                         
0023MINI 20220131235022 MINICICS --about to call rule execution server                              
0023MINI 20220131235022 MINICICS -- Rule executed in-O8B1                                           
0023MINI 20220131235022 MINICICS--Execution ID-d17e5005-6029-4a36-87a0-e29e80c5fdee1                
0023MINI 20220131235022 MINICICS--name-John                loan amount-0000250000-approved-F        
0023MINI 20220131235022 MINICICS--msg-The age exceeds the maximum.                                  
0023MINI 20220131235022 MINICICS --Loan customer 0000000003                                         
0023MINI 20220131235022 MINICICS --about to call rule execution server                              
0023MINI 20220131235022 MINICICS -- Rule executed in-O8B1                                           
0023MINI 20220131235022 MINICICS--Execution ID-d17e5005-6029-4a36-87a0-e29e80c5fdee2                
0023MINI 20220131235022 MINICICS--name-Sarah               loan amount-0000500000-approved-F        
0023MINI 20220131235022 MINICICS--msg-Debt-to-income too high compared to credit score              
0023MINI 20220131235022 MINICICS --Loan customer 0000000004                                         
0023MINI 20220131235022 MINICICS --about to call rule execution server                         
0023MINI 20220131235022 MINICICS -- Rule executed in-O8B1                                      
0023MINI 20220131235022 MINICICS--Execution ID-d17e5005-6029-4a36-87a0-e29e80c5fdee3           
0023MINI 20220131235022 MINICICS--name-Andy                loan amount-0000500000-approved-F   
0023MINI 20220131235022 MINICICS--msg-Debt-to-income ratio is greater than 49%                 
0023MINI 20220131235022 MINICICS --Loan customer 0000000005                                    
0023MINI 20220131235022 MINICICS --about to call rule execution server                         
0023MINI 20220131235022 MINICICS -- Rule executed in-O8B1                                      
0023MINI 20220131235022 MINICICS--Execution ID-d17e5005-6029-4a36-87a0-e29e80c5fdee4           
0023MINI 20220131235022 MINICICS--name-David               loan amount-0000250000-approved-F   
0023MINI 20220131235022 MINICICS--msg-The yearly income is lower than the basic request        
0023MINI 20220131235022 MINICICS --Loan customer 0000000006                                    
0023MINI 20220131235022 MINICICS --about to call rule execution server                         
0023MINI 20220131235022 MINICICS -- Rule executed in-O8B1                                      
0023MINI 20220131235022 MINICICS--Execution ID-d17e5005-6029-4a36-87a0-e29e80c5fdee5           
0023MINI 20220131235022 MINICICS--name-Michelle            loan amount-0001000100-approved-F   
0023MINI 20220131235022 MINICICS--msg-The loan cannot exceed 1000000                           
0023MINI 20220131235022 MINICICS --Disconnect from rule execution server                       
0023MINI 20220131235027 MINICICS --SUCCESSFUL COMPLETION of demo                               
```

CICSアプリからもルール呼び出しが正常に行えました！

##### 4. 切断
ODMとの切断用のトランザクション "HBRD"を実行！
画面上に`GBRZC9002I RC=0000`が返されればOKです。