Audit (3.0)
allows you to output information to user-defined database tables. This means that several workflows may output information about the same batch to the same table, which makes it possible to trace batches/UDRs between workflows. To increase this traceability, it is highly recommended to add fields to the UDRs, to make it possible to identify their origin. Useful values may be:
Name of the switch
Name of the original file name
Time stamp of the original file
You define the audit table column types in an Audit profile configuration.
The Audit profile is loaded when you start a workflow that depends on it. Changes to the profile become effective when you restart the workflow.
The Audit profile configuration contains the following settings:
Setting | Description |
---|---|
Database | This is the database that the agent is to connect and send data to. Click the Browse... button to get a list of all the database profiles that are available. For further information see Database (3.0). The Audit functionality is supported for use with a PostgreSQL database. |
Refresh | Select Refresh to reload the meta data for the tables residing in the selected database. |
Table | A list of selected audit tables. For further information about adding and editing tables, see the section below, Adding and Editing a Table Mapping. |
Adding and Editing a Table Mapping
From the Add and Edit Audit Table Attributes dialogs, the existing table columns are mapped to valid types in .
Item | Description |
---|---|
Table | A list from which you select the audit table. |
Column Name | The name of the columns in the selected table. |
Type | Clicking the cell, displays a list of valid  types. Each column must be mapped against a type. Valid types are:
|
Key Sequence | A key sequence is a defined way to assign a Key value, to identify in which order you need to send along key values when you use the Each key in a table must have a sequence number in order to be identified when passed on as parameters to the APL audit functions. The first key is identified as 1, the second as 2, and so on. The key sequence will uniquely identify all audit log entries to be inserted per batch. |
Audit Profile
In the Audit profile configuration, the column types are configured. To create a new Audit profile configuration, click the Configuration button in the navigation panel to the left in the  Desktop window, and then select Audit Profile from the menu. Select the database in which the table(s) reside, then select Add.
Adding the Table Mapping
From the Add and Edit Audit Table Attributes dialogs, the existing table columns are mapped to  valid types.
The data to insert, will be put in the UDRs column. Setting it to type Counter, makes it possible to use the auditAdd
 function to increment the corresponding column value. If Value is used, the auditSet
 function can be used to assign a value.
 Workflow Properties - Audit Tab
The Audit tab in the Workflow Properties dialog defines the type of data entered in the table by the workflow. This is either MIM types or anything sent on with the APL audit functions.
The COMPLETE, INVALID and PARTIALS columns in the Audit table are populated by using the APL audit functions. COLLECTION_DATE and FILENAME are populated by the workflow MIM values. The CANCELED column name might be mapped directly to an existing MIM value or populated by the APL audit functions using the Analysis Agent.
 Populating Audit Tables
There are two ways of populating audit tables; either by using the auditAdd
 function, which automatically increments the value of Counter columns, or by setting fixed values to columns of type Valuewith the auditSet
function. Note that Counter columns are automatically set to 0 (zero) when a batch is canceled. This is not the case for Value columns.
Note!
In terms of performance, it does not matter how many times an audit function is called. Each call is saved in memory and a summary for each key is committed at End Batch.
Counter Increment
By using the auditAdd
 function, the user does not have to keep track of the number to increment a counter column with. At Cancel Batch, the value is set to 0 (zero).
Fixed Values
Using the auditSet
 function for the same example as discussed in the previous section, means the user has to keep track of the number of records in the APL code. Note that the profile must be updated; the Counter column must be redefined to Value.
Value columns are not reset when a batch is canceled. Hence there will be entries made in the table for the UDRs column for all batches.
Example - Use of auditAdd and auditSet
In this example code, each UDR is validated with respect to the contents of the causeForOutput
 field. The audit table is updated to hold information on the numbers of Complete, Partial and Invalid UDRs sent on the routes.
// Define counters int complete = 0; int partials = 0; int invalid = 0; //Publish a new MIM mimPublish(trailer, "My Trailer",string); consume { // Check if the UDR is of type complete if(input.causeForOutput == 0){ // Increment complete counter complete = complete + 1; // Increment value of column COMPLETE auditAdd( "Default.PRF_AUDIT","MZADMIN.MZ_AUDIT","COMPLETE",1 ); // Route UDR on outgoing route "COMPLETE" udrRoute(input, "COMPLETE"); } // Check if the UDR is of type partial else if(input.causeForOutput == 1 ||input.causeForOutput == 2){ // Increment partial counter partials = partials + 1; // Increment value of column PARTIAL auditAdd( "Default.PRF_AUDIT","MZADMIN.MZ_AUDIT","PARTIAL",1 ); // Route UDR on outgoing route "PARTIALS" udrRoute(input, "PARTIALS"); } else{ // Increment invalid counter invalid = invalid + 1; // Set the value of column INVALID auditSet( "Default.PRF_AUDIT","MZADMIN.MZ_AUDIT","INVALID",invalid ); } }