﻿--  category:  IBM i Services for BRMS
--  description:  Application - BRMS Network Procedures
--  minvrm: V7R3M0
--  Requires BRMS PTFs - 7.5 SI82234, 7.4 SI82233, 7.3 SI82232
--  last updated: 3/15/2023

--  
-- Step 1: Verify system communication (Recommended guidance)
--  
-- Communication needs to be established outside of BRMS for the remote system to connect and be available for use.
-- BRMS Networking uses relational database (RDB) entries for all of its network operations. 
--  
-- Considerations to help set up communications
-- Check TCP/IP: Use the following command to verify TCP/IP is running on the Node:
-- replace 'node-tcpip-name' with your remote system tcpip name 
CL: PING RMTSYS(node-tcpip-name);
-- If TCP/IP is not running, then you will need to configure and/or start TCP/IP on the Node.
-- SET TCP/IP DDM Connection for secure connections
-- Use ONE of the following commands to change the TCP/IP DDM attributes for secured operations:
CL: CHGDDMTCPA PWDRQD(*YES);
CL: CHGDDMTCPA PWDRQD(*USRIDPWD);
-- Change the QRETSVRSEC system value so that passwords used for authentication can be stored
CL: CHGSYSVAL QRETSVRSEC VALUE('1');
-- Use Server Authentication support
-- Add server authentication entries for each user who will be authorized to perform secured TCP/IP operations to the Nodes
-- NOTE: "QDDMDRDASERVER" must be uppercase
-- replace 'user-profile' , node-user-profile and 'node-user-profile-password' with your desired individual information
CL: ADDSVRAUTE USRPRF(user-profile) SERVER(QDDMDRDASERVER) USRID(node-user-profile) PASSWORD(node-user-profile-password);
CL: ADDSVRAUTE USRPRF(QBRMS) SERVER(QDDMDRDASERVER) USRID(node-user-profile) PASSWORD(node-user-profile-password);
-- INZBRM *VFYSYS example to verify expected communications are enabled for BRMS remote system being added
-- replace 'APPN.PROD1' with your remote system name in the format netId.sysName
CL: INZBRM OPTION(*VFYSYS) SYSNAME('APPN.PROD1');

--
-- Step 2: Add the system to the BRMS network
--
-- call QUSRBRM.ADD_NETWORK_SYSTEM(
--      SYSTEM_NAME=> 'system-name,
--      RELATIONAL_DATABASE_NAME=> relational-database-name,
--      LOCAL_RECEIVES_HISTORY=> local-receives-history,
--      REMOTE_RECEIVES_HISTORY=>  remote-receives-history);
--
-- Example: Add a new remote system named APPN.PROD1
--          with relational database name PROD1RDB
--          with local receives history YES and
--          remote receives history NO
CALL QUSRBRM.ADD_NETWORK_SYSTEM(
    SYSTEM_NAME => 'APPN.PROD1',
    RELATIONAL_DATABASE_NAME => 'PROD1RDB',
    LOCAL_RECEIVES_HISTORY => 'YES',
    REMOTE_RECEIVES_HISTORY => 'NO'
);

--
-- Step 3: Activate the system to the BRMS network
--
-- CALL QUSRBRM.ACTIVATE_NETWORK_SYSTEM(SYSTEM_NAME=> system-name);
--
-- Example: Activate new remote system named APPN.PROD1
CALL QUSRBRM.ACTIVATE_NETWORK_SYSTEM(
    SYSTEM_NAME => 'APPN.PROD1'
);

--
-- Removing a system from the BRMS network
--
-- CALL QUSRBRM.REMOVE_NETWORK_SYSTEM(
--      SYSTEM_NAME=> system-name,                          Required
--      MEDIA_ACTION=> media-action,                        Optional
--      HISTORY_ACTION=> history-action,                    Optional
--      NEW_SYSTEM_NAME=> new-system-name);                 Optional
--
-- Example: Remove a remote system named APPN.PROD1 keeping the media and history information the same:
CALL QUSRBRM.REMOVE_NETWORK_SYSTEM(
    SYSTEM_NAME => 'APPN.PROD1'
);

--
-- Example: Remove a remote system named APPN.PROD1 renaming the media and history information to the system name of APPN.NEWSYS:
CALL QUSRBRM.REMOVE_NETWORK_SYSTEM(
    SYSTEM_NAME => 'APPN.PROD1',
    MEDIA_ACTION => 'RENAME',
    NEW_SYSTEM_NAME => 'APPN.NEWSYS'
);
