...
APL code is divided into different function blocks that serve as execution entry-points that are applicable to the various workflow states.
initialize
The initialize function block is executed once for each invocation of the workflow and enables you to assign, for example, an argument with an initial value.
Note | ||
---|---|---|
| ||
Avoid reading MIM parameters from within The udrRoute function cannot be used in the |
beginBatch and endBatch
Note | ||
---|---|---|
| ||
beginBatch and endBatch are applicable for batch workflows only. |
The beginBatch
and endBatch
function blocks are executed at the beginning and end of each batch respectively. Rules are that the beginBatch block is called when a batch collection agent emits a Begin Batch call. This occurs either at file start, or when a hintEndBatch
call is received from any agent capable of utilizing APL code. See hintEndBatch in Workflow Functions(3.0) for more information.
The endBatch
block is called every time a batch collection agent emits an End Batch. This occurs either at file end, or when a hintEndBatch
call is received from any agent capable of utilizing APL code.
Note | ||
---|---|---|
| ||
The |
consume
The consume
function block is executed for each UDR or bytearray passing the agent. Within a consume
block, validation, modification and routing can be performed. Each UDR or bytearray is referred to by the special input variable.
Built-in Variables
Variable | Description | Example |
---|---|---|
input | Read-only variable containing the current UDR. Only available in the consume function block. | input.ANumber = 1234567; udrRoute(input); |
When handling several types of UDRs in the same Analysis agent, the APL code must first determine what type is currently handled, then cast it to the correct type. For an example, see Data Types(3.0).
drain
Note | ||
---|---|---|
| ||
Drain is applicable for batch workflows only. |
...
Info | ||
---|---|---|
| ||
|
cancelBatch
Note | ||
---|---|---|
| ||
|
...
If the cancelBatch
function block is called and the Cancel Batch behavior is set to Abort Immediately the workflow will immediately abort without the cancelBatch
function block being called. The block is only called when the preferences are set to Abort After or Never Abort. For further information about the Abort related configurations, see Workflow Properties(3.0) in the Desktop user's guide.
commit
Note | ||
---|---|---|
| ||
|
...
Note |
---|
The |
Built-in Variables
Variable | Description | Example |
---|---|---|
transaction | This is a read-only variable containing the current transaction. The variable is available in the commit and rollback function blocks. | debug("commit of txn " + transaction.id); |
rollback
Note | ||
---|---|---|
| ||
|
...
Note | ||
---|---|---|
| ||
If a transaction fails during commit, it will try to commit again, and will not be sent to the The |
deinitialize
The deinitialize
function block is executed right before the workflow stops.
If the deinitialize
block is used in a real-time workflow it could be used to clean and close resources, for instance external connections.
exceptionHandling
The exceptionHandling
function block enables you to divert exceptions from the workflow's main processing course to a separate course, where exceptions are processed according to your needs.
exceptionHandling in Batch Workflows
For example: When a workflow occasionally aborts due to an exception in the APL code, use exceptionHandling to cancel the batch.
...
Note | ||
---|---|---|
| ||
The |
Exception Handling in Batch and Real-Time Workflows
The try-catch
, throw
and finally
statements can be used to handle exceptions in batch and real-time.
...
Info | ||
---|---|---|
| ||
|
ExceptionDetails
The ExceptionDetails
UDR stores the information for an exception that is caught in a catch block in batch or real-time.
Field | Description |
---|---|
| The message included in the exception |
stackTrace (string) | The function call hierarchy from where the exception occurred |
type (string) | Type of exception |
OriginalData (bytearray) | This field is always empty. |
Function Blocks Example
Info | ||
---|---|---|
| ||
|
...