﻿--  category:  IBM i Services for BRMS
--  description:  Application - BRMS Enterprise Procedures
--  minvrm: V7R3M0
--  Requires BRMS PTFs - 7.5 SI80273, 7.4 SI80272, 7.3 SI80271
--  last updated: 3/14/2023

--  
-- Optional: Initialize BRMS SQL services 
--  
-- Ensures the BRMS SQL services are enabled and available to use 
--  
CL: INZBRM OPTION(*SQLSRVINZ);

--
-- Change hub procedure
--
-- CALL QUSRBRM.CHANGE_ENTERPRISE_HUB(
-- HUB_CONTACT=> hub-contact,                      Optional
-- SEND_ERROR_EMAIL=> send-error-email,            Optional
-- SEND_REPORT_EMAIL=> send-report-email,          Optional
-- REFRESH_RATE=> refresh-rate);                   Optional
--
-- Example: change the refresh rate to 60 minutes
--
CALL QUSRBRM.CHANGE_ENTERPRISE_HUB(
    REFRESH_RATE => '60'
);

-- Add contact procedure
--
-- CALL QUSRBRM.ADD_ENTERPRISE_CONTACT(
-- CONTACT_USER_NAME=> contact-user-name,     Required
-- EMAIL_ADDRESS=> email-address,             Optional
-- FIRST_NAME=> first-name,                   Optional
-- LAST_NAME=> last-name,                     Optional
-- PRIMARY_PHONE=> primary-phone,             Optional
-- SECONDARY_PHONE=> secondary-phone,         Optional
-- DESCRIPTION=> description);                Optional
--
-- Add contact name example:
--
CALL QUSRBRM.ADD_ENTERPRISE_CONTACT(
    CONTACT_USER_NAME => 'CONTACT',
    EMAIL_ADDRESS => 'CONTACT.USERID@COMPANY.COM',
    first_name => 'FIRST',
    last_name => 'LAST',
    PRIMARY_PHONE => '111-222-3333',
    SECONDARY_PHONE => '444-555-6666',
    DESCRIPTION => 'BRMS ENTERPRISE CONTACT'
);

--
-- Change contact procedure
--
-- CALL QUSRBRM.CHANGE_ENTERPRISE_CONTACT(
-- CONTACT_USER_NAME=> contact-user-name,     Required
-- EMAIL_ADDRESS=> email-address,             Optional
-- FIRST_NAME=> first-name,                   Optional
-- LAST_NAME=> last-name,                     Optional
-- PRIMARY_PHONE=> primary-phone,             Optional
-- SECONDARY_PHONE=> secondary-phone,         Optional
-- DESCRIPTION=> description);                Optional
--
-- example: change the email address to use for user name CONTACT
--
CALL QUSRBRM.CHANGE_ENTERPRISE_CONTACT(
    CONTACT_USER_NAME => 'CONTACT',
    EMAIL_ADDRESS => 'NEW.USERID@COMPANY.COM'
);

--
-- Remove contact procedure
--
-- CALL QUSRBRM.REMOVE_ENTERPRISE_CONTACT(
-- CONTACT_USER_NAME=> contact-user-name);    Required
--
-- Example: removing user name CONTACT
--
CALL QUSRBRM.REMOVE_ENTERPRISE_CONTACT(
    CONTACT_USER_NAME => 'CONTACT'
);

-- Add node procedure
--
-- CALL QUSRBRM.ADD_ENTERPRISE_NODE(
-- SYSTEM_NAME=> system-name,                                       Required
-- RELATIONAL_DATABASE_NAME=> relational-database-name,             Required
-- ADD_NETWORK_SYSTEMS => add-network-systems,                      Optional
-- PRIMARY_CONTACT=> primary-contact,                               Optional
-- SECONDARY_CONTACT=> secondary-contact,                           Optional
-- HUB_OUTPUT_QUEUE_LIBRARY=> hub-output-queue-library,             Optional
-- HUB_OUTPUT_QUEUE=> hub-output-queue,                             Optional
-- NODE_OUTPUT_QUEUE_LIBRARY=> node-output-queue-library,           Optional
-- NODE_OUTPUT_QUEUE=> node-output-queue,                           Optional
-- DESCRIPTION=> description)                                       Optional
--
-- Example: Adding a single node
--
CALL QUSRBRM.ADD_ENTERPRISE_NODE(
    SYSTEM_NAME => 'APPN.BRMS1',
    RELATIONAL_DATABASE_NAME => 'BRMS1',
    ADD_NETWORK_SYSTEMS => 'NO',
    PRIMARY_CONTACT => 'CONTACT'
);

--
-- Change node procedure
--
-- CALL QUSRBRM.CHANGE_ENTERPRISE_NODE(
-- SYSTEM_NAME=> system-name,                                        Required
-- RELATIONAL_DATABASE_NAME=> relational-database-name,              Optional
-- PRIMARY_CONTACT=> primary-contact,                                Optional
-- SECONDARY_CONTACT=> secondary-contact,                            Optional
-- HUB_OUTPUT_QUEUE_LIBRARY=> hub-output-queue-library,              Optional
-- HUB_OUTPUT_QUEUE=> hub-output-queue,                              Optional
-- NODE_OUTPUT_QUEUE_LIBRARY=> node-output-queue-library,            Optional
-- NODE_OUTPUT_QUEUE=> node-output-queue,                            Optional
-- DESCRIPTION=> description);                                       Optional
--
-- Example: change the primary contact name
--
CALL QUSRBRM.CHANGE_ENTERPRISE_NODE(
    SYSTEM_NAME => 'APPN.BRMS1',
    PRIMARY_CONTACT => 'CONTACT1'
);

--
-- Remove node procedure
--
-- CALL QUSRBRM.REMOVE_ENTERPRISE_NODE(
-- SYSTEM_NAME=> system-name);                                       Required
--
-- Example: remove node
--
CALL QUSRBRM.REMOVE_ENTERPRISE_NODE(
    SYSTEM_NAME => 'APPN.BRMS1'
);

--
-- Add report definition procedure
--
-- CALL QUSRBRM.ADD_ENTERPRISE_REPORT_DEFINITION(
-- REPORT_DEFINITION=> report-definition,                  Required
-- SYSTEM_NAME=> system-name,                              Required
-- GENERATION_TIME=> generation-time,                      Required
-- COMMAND=> command,                                      Required
-- NUMBER_REPORTS=> number-reports,                        Optional
-- SEND_ERROR_EMAIL=> send-error-email,                    Optional
-- SEND_REPORT_EMAIL=> send-report-email,                  Optional
-- FREQUENCY_INTERVAL=> frequency-interval,                Optional
-- WEEK_DAYS=> week-days,                                  Optional
-- WAIT_DAYS=> wait-days,                                  Optional
-- DESCRIPTION=> description);                             Optional
--
-- Example: run STRMNTBRM daily
--
CALL QUSRBRM.ADD_ENTERPRISE_REPORT_DEFINITION(
    REPORT_DEFINITION => 'BRMSMNT',
    SYSTEM_NAME => 'APPN.BRMS1',
    GENERATION_TIME => '100000',
    COMMAND => 'STRMNTBRM PRTEXPMED(*YES) PRTBKUACT(*YES) PRTRCYRPT(*ALL)',
    FREQUENCY_INTERVAL => 'DAYS',
    WAIT_DAYS => '1',
    SEND_ERROR_EMAIL => 'YES',
    NUMBER_REPORTS => '7',
    SEND_REPORT_EMAIL => 'YES',
    DESCRIPTION => 'RUN EVERY DAY'
);

--
-- Change report definition procedure
--
-- CALL QUSRBRM.CHANGE_ENTERPRISE_REPORT_DEFINITION(
-- REPORT_DEFINITION=> report-definition,                  Required
-- SYSTEM_NAME=> system-name,                              Required
-- GENERATION_TIME=> generation-time,                      Optional
-- COMMAND=> command,                                      Optional
-- NUMBER_REPORTS=> number-reports,                        Optional
-- SEND_ERROR_EMAIL=> send-error-email,                    Optional
-- SEND_REPORT_EMAIL=> send-report-email,                  Optional
-- FREQUENCY_INTERVAL=> frequency-interval,                Optional
-- WEEK_DAYS=> week-days,                                  Optional
-- WAIT_DAYS=> wait-days,                                  Optional
-- DESCRIPTION=> description);                             Optional
--
-- Example: Change time to run to 6am
--
CALL QUSRBRM.CHANGE_ENTERPRISE_REPORT_DEFINITION(
    REPORT_DEFINITION => 'BRMSMNT',
    SYSTEM_NAME => 'APPN.BRMS1',
    GENERATION_TIME => '060000'
);

--
-- Remove report definition procedure
--
-- CALL QUSRBRM.REMOVE_ENTERPRISE_REPORT_DEFINITION(
-- REPORT_DEFINITION=> report-definition,                  Required
-- SYSTEM_NAME=> system-name);                             Required
--
-- Example: Remove report definition
--
CALL QUSRBRM.REMOVE_ENTERPRISE_REPORT_DEFINITION(
    REPORT_DEFINITION => 'BRMSMNT',
    SYSTEM_NAME => 'APPN.BRMS1'
);

--
-- Manually run a report definition
--
-- CALL QUSRBRM.RUN_ENTERPRISE_REPORT_DEFINITION(
-- REPORT_DEFINITION=> report-definition,                     Required
-- SYSTEM_NAME=> system-name);                                Required
--
-- Run report definition example
--
CALL QUSRBRM.RUN_ENTERPRISE_REPORT_DEFINITION(
    REPORT_DEFINITION => 'BRMSMNT',
    SYSTEM_NAME => 'APPN.BRMS1'
);