IBM Support

How-To Automate journal receiver (*JRNRCV) deletion

Question & Answer


Question

Is there a way to automate the deletion (DLTJRNRCV) of journal receivers on the system?  Does IBM have any sample code that demonstrates how to do this?

Cause

The following article provides some good information on how to automate journal receiver deletion.  The sample code, however, is flawed and it does not work over month/year boundaries.

[ ] Automate journal receiver (*JRNRCV) deletion
     ==> https://www.ibm.com/support/pages/automate-journal-receiver-jrnrcv-deletion

The above page ultimately links to:
==> https://www.ibm.com/developerworks/ibmi/library/i-automate-journal-receiver-deletion/index.html

Development had provided another CLLE sample, which is listed below.  Note - the logic to delete the 
receiver is at the very end of the program and uses 5 days as the criteria for deletion.  The criteria 
may be updated based on your needs.

Source can be found in QMGTOOLS's QMGDBSQL source physical files (as of late 2020)


 

Answer


PROVIDED AS-IS Support cannot assist with modifying and or troubleshooting this code. 



/*************************************************************************/
/*                                                                       */
/*  Sample exit program to delay deleting a journal receiver             */
/*                                                                       */
/*  This sample will compare the number of days between detach date      */
/*  and current date in days to determine if receiver is eligible for    */
/*  delete.                                                              */
/*                                                                       */

/*  Provided AS-IS   Support cannot assist with modifying and or         */
/*  troubleshooting                                                      */

/*                                                                       */
/*  QMGTOOLS/QMGDBSQL.DLTJRNRCV2                                         */
/*                                                                       */
/*************************************************************************/

             PGM        PARM(&INPUT &OUTPUT)
             DCL        VAR(&INPUT) TYPE(*CHAR) LEN(200)
             DCL        VAR(&OUTPUT) TYPE(*CHAR) LEN(5)
/* VARIABLE FOR INPUT STRUCTURES                                     */
             DCL        VAR(&INPUT1) TYPE(*CHAR) LEN(200)
/* VARIABLES FOR DATE TIME AND FOR CONVERTING IT TO STARTARD FMT     */
             DCL        VAR(&DTCHSYS) TYPE(*CHAR) STG(*DEFINED) +
                          LEN(6) DEFVAR(&INPUT1 81)
             DCL        VAR(&DTCHINT) TYPE(*INT) LEN(4)
/* SETUP JRN NAME AND LIB                                             */
             DCL        VAR(&JRNNAME) TYPE(*CHAR) STG(*DEFINED) +
                          LEN(10) DEFVAR(&INPUT1 53)
             DCL        VAR(&JRNLIB) TYPE(*CHAR) STG(*DEFINED) +
                          LEN(10) DEFVAR(&INPUT1 63)
 /* SETUP CURRENT YEAR MONTH DAY FROM SYSTEM                          */
             DCL        VAR(&RTVCURDATE) TYPE(*CHAR) LEN(6)
             DCL        VAR(&CURDATE) TYPE(*CHAR) LEN(6)
             DCL        VAR(&CURINT) TYPE(*INT) LEN(4)
/* SETUP OUTPUT TO REURN INFO                                   */
             DCL        VAR(&OUTPUT1) TYPE(*CHAR) LEN(5)
             DCL        VAR(&OUTPUTLGTH) TYPE(*INT) STG(*DEFINED) +
                          LEN(4) DEFVAR(&OUTPUT)
             DCL        VAR(&OUTPUTSTS) TYPE(*CHAR) STG(*DEFINED) +
                          LEN(1) DEFVAR(&OUTPUT 5)
/* LILLIAN PICTURE STRING                                          */
             DCL        VAR(&PICSTR) TYPE(*CHAR) LEN(6) VALUE('YYMMDD')
/******************************************************************/
/*  ADD CODE IN HERE IF YOU WANT TO CHECK FOR A JRN NAME AND LIB  */
/*  AGAINST A LIST OF JRNS TO BE RETAINED.  &JRNNAME AND &JRNLIB  */
/*  HAVE BEEN PASSED IN BY THE EXIT POINT                         */
/******************************************************************/
/* MOVE INPUT PARM INTO DEFINED VARS AND SET STS TO DEFAULT TO     */
/* ALLOW THE RECEIVER TO BE DELETED                                */
             CHGVAR     VAR(&INPUT1) VALUE(&INPUT)
             CHGVAR     VAR(&OUTPUTLGTH) VALUE(5)
             CHGVAR     VAR(&OUTPUTSTS) VALUE('1')
/* RTV SYSTEM DATE AND CONVERT TO LILLIAN DATE                   */
             RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&RTVCURDATE)
             CVTDAT     DATE(&RTVCURDATE) TOVAR(&CURDATE) +
                          FROMFMT(*JOB) TOFMT(*YMD) TOSEP(*NONE)
             CALLPRC    PRC(CEEDAYS) PARM(&CURDATE &PICSTR &CURINT)
/* CONVERT DETACH DATE TO LILLIAN DATE                           */
             CALLPRC    PRC(CEEDAYS) PARM(&DTCHSYS &PICSTR &DTCHINT)

/*******************************************************************/
/*  IF CURRENT - DETACH DAY IS NOT > 5 THEN DISALLOW THE DETACH    */
/*******************************************************************/
             IF         COND((&CURINT - &DTCHINT) > 5) THEN(GOTO +
                          CMDLBL(END))
             ELSE       CMD(CHGVAR VAR(&OUTPUTSTS) VALUE('0'))
END:
ENDPGM

[{"Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CGIAA2","label":"IBM i Db2->Journal"}],"ARM Case Number":"TS004195024","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Version(s)"}]

Document Information

Modified date:
05 October 2020

UID

ibm16342913