Initiate request accounting

  1. On the Administration tab, click System Administration.
  2. Click the system object and, in the Accounting section on the right, set the OnRequestCompletion parameter to a script that has the RequestAccounting context.

    When the parameter is set, the configured script is called automatically whenever a request is completed.

For requests that do not contain abandoned items, the request accounting exit point is called immediately after the last output for a request is distributed by KCM B&OM. This happens in either of the following cases:

  • When the CCM_Conversion standard process produces a print file, which contains the remaining communications of a request.
  • When the CCM_Communication standard process decides that no communications are distributed for a correspondence, and all other correspondences of the request are either already processed or do not produce output.
  • When the CCM_Application standard process decides that all application events of the request are ignored.

For requests that do contain abandoned items, the request accounting exit point is called when the request is cleaned up by the CCM_CleanUpAll process.

The RequestAccounting context property makes the following information available to the configured exit point:

  • Request.Reference. Reference of the completed request.
  • Request.RegistrationTime. Time when the completed request was picked up by the CCM_Registration process. The UTC time standard is used.
  • Request.CompletionTime. Time when the request was completed. The UTC time standard is used.
  • Request.DistributedCommunicationsCount. The number of communications distributed for the completed request.
  • Request.Success. Flag that indicates whether components of the request were abandoned. If the request does not contain abandoned correspondences or communications, it is set to True. If the request contains abandoned correspondences or communications, it is set to False.
  • Request.PrintedPageCount. The number of pages printed for the completed request. This number does not include communications created for electronic delivery, disposed or envelope cover letters, or extra pages added during streaming.

  • AccountingDatabase. Name of the database alias configured on the system for the accounting database. When no database is configured, this is an empty string.

Example request accounting script

; Store accounting information in database, but only if an accounting database has been configured on the system.
If (AccountingDatabase <> "")

  ; Retrieve information from distributed communication.
  Reference = Request.Reference
  RegistrationTime = Request.RegistrationTime.ToString()
  CompletionTime = Request.CompletionTime.ToString()

  ; Create INSERT query.
  StringListClear("Sql")
  StringListClear("SqlParameters")
  StringListAdd("Sql", "INSERT INTO AccountedRequest VALUES (:Reference, :RegistrationTime, :CompletionTime)")
  StringListSetValue("SqlParameters", "Reference", "is")
  StringListSetValue("SqlParameters", "RegistrationTime", "i@")
  StringListSetValue("SqlParameters", "CompletionTime", "i@")

  ; Execute INSERT query.
  InitDatabase(AccountingDatabase)
  InitDataSet("DataSet", AccountingDatabase)
  SetExecSQL("DataSet", "Sql", "SqlParameters")
  CloseDatabase(AccountingDatabase)

End-If

This sample script is included in a B&OM installation. To use this script, you still must configure it on the system.