5 3 Online and Batch Report Production

LANSA Application Design

5.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:

  • It is assumed that the field #REPMODE (report production mode) is defined in the dictionary. There is no need to define it in this program. It probably has a default value of B (batch production).
  • The system variables *PROCESS and *FUNCTION used in the SUBMIT commands ensure that this (ie: the current) process/function is invoked by the batch job.
  • The system variables *BATCHJOB and *NIGHTJOB are used as the JOBQ (job queue) parameter values in the SUBMIT commands.

    It is assumed that these have been previously set up as LANSA system variables prior to coding the program. By using this form to identify the job queue there is no need to "hard code" the job queue names into the program.

    Additionally, the actual values used can be changed externally without having to modify or re-compile the program.
  • The built-in function CLR_MESSAGES is used to clear/remove the operating system message which results from executing a SUBMIT command. A more "user friendly" message is issued to replace it.