13.3 Online and Batch Report Production

Report production programs usually perform a large number of database I/Os. As such they are usually unsuitable for online execution because they impact the performance of other online tasks too much.

This section describes some techniques which can be used to control when and where reports are produced.

The following generalized method for report production could be set up as an application template, and used to generate the initial version of any new report production programs:

 

  ********** =============================

  ********** If this job is running online

  ********** =============================

  IF         COND('*JOBMODE = I')

  ********** Get user to specify mode and report parameters

  REQUEST    (#REPMODE + other report production parameters)

  ********** Validate mode and any other run parameters here

  BEGINCHECK

  VALUECHECK FIELD(#REPMODE) WITH_LIST(I B N)

    MSGTXT('Report mode must be I (inter), B (batch) or N (overnight)')

  ENDCHECK

  ********** Produce report or submit a batch job to do it

  CASE       OF_FIELD(#MODE)

  WHEN       VALUE_IS('= I')

  MESSAGE    MSGTXT('Report xxxxxxxx is being produced ... please wait')

   TYPE(*STATUS)

  EXECUTE    SUBROUTINE(PRINT)

  WHEN       VALUE_IS('= B')

  SUBMIT     PROCESS(*PROCESS) FUNCTION(*FUNCTION) JOBQ(*BATCHJOB)

   EXCHANGE(#XXXXXX #XXXXXX #XXXXXX #XXXXXX #XXXXXX)

  USE        BUILTIN(CLR_MESSAGES)

  MESSAGE    MSGTXT('Report xxxxxxxx submitted for batch production')

  WHEN       VALUE_IS('= N')

  SUBMIT     PROCESS(*PROCESS) FUNCTION(*FUNCTION) JOBQ(*NIGHTJOB)

   EXCHANGE(#XXXXXX #XXXXXX #XXXXXX #XXXXXX #XXXXXX)

  USE        BUILTIN(CLR_MESSAGES)

  MESSAGE    MSGTXT('Report xxxxxxx submitted for overnight production')

  ENDCASE

  ********** ====================================

  ********** Else if this job is running in batch

  ********** ====================================

  ELSE

  EXECUTE    SUBROUTINE(PRINT)

  ENDIF

  ********** =================================

  ********** Subroutine PRINT : Produce report

  ********** =================================

  SUBROUTINE NAME(PRINT)

  **********

  ********** Define all print lines here

  **********

 

  **********

  ********** Produce report here

  **********

 

  **********

  ********** Close report and issue completion message

  **********

  ENDPRINT

  MESSAGE    MSGTXT('Report xxxxxxxx successfully produced')

  ENDROUTINE

 

Some points to note about this example are: