Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel1

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
titleNote!

Avoid reading MIM parameters from within initialize. The order by which agents are initialized is undefined and MIM parameters are therefore not necessarily set during the initialize phase.

The udrRoute function cannot be used in the initialize block.

beginBatch and endBatch

Note
titleNote!

beginBatch and endBatch are applicable for batch workflows only. 

...

Note
titleNote!

The udrRoute function cannot be used in the beginBatch and endBatch blocks. 

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

VariableDescriptionExample
inputRead-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[hide]3.0[/hide].

drain

Note
titleNote!

Drain is applicable for batch workflows only.

...

Info
titleExample - How to use drain


Code Block
int UDRCounter;
int file_count;
consume {
 UDRCounter=UDRCounter+1;
 udrRoute(input);
}
drain {
 myFolder.myUFDLFile.myTrailerFormat myTrailer;
 myTrailer=udrCreate(myFolder.myUFDLFile.myTrailerFormat);
 myTrailer.closingdate=dateCreateNow();
 myTrailer.numberOfUDRs=UDRCounter;
 myTrailer.sourceFileName=(string)mimGet("Disk_1",
 "Source Filename");
 udrRoute(myTrailer);
}
 
endBatch{
 file_count = file_count + 1;
 debug( "Number of UDRs in file:" + UDR_count );
}


cancelBatch

Note
titleNote!

cancelBatch is applicable for batch workflows only.

...

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[hide]3.0[/hide] in the Desktop user's guide.

commit

Note
titleNote!

commit is applicable for batch workflows only.

...

Note

The udrRoute function cannot be used in the commit block.

Built-in Variables

VariableDescriptionExample
transactionThis 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
titleNote!

Rollback is applicable for batch workflows only.

...

Note
titleNote!

 If a transaction fails during commit, it will try to commit again, and will not be sent to the rollback block.

The udrRoute function cannot be used in the rollback block.

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
titleNote!

The exceptionHandling function block for batch workflows is a legacy statement that is retained for backward compatibility. It is recommended that you use try-catch, throw and finally statements instead. These are described in the next section. 

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
titleExample - Using the try-catch statement


Code Block
consume { 
    int b = 0;
    try { 
       debug("Hello: " + 100/b); 
    }
    catch (ExceptionDetails exception) { 
       debug("EXCEPTION: " + exception.message);
       // To throw exception caught, write 'throw exception'. 
       throw testCreate(); 
       // This will cause execution of the (legacy) exceptionHandling if declared (only available in batch workflows), otherwise 
       the workflow aborts.
    } 
    finally {
       debug("In finally clause " + b);
    }
}
ExceptionDetails testCreate() {
    ExceptionDetails ed = udrCreate(ExceptionDetails);
    ed.message = "DONE";
    return ed;
}


ExceptionDetails

The ExceptionDetails UDR stores the information for an exception that is caught in a catch block in batch or real-time.

FieldDescription

message (string)

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
titleExample - Function Blocks Example


Code Block
int file_count;
int UDR_count;
initialize {
 file_count = 0;
}
beginBatch {
 UDR_count = 0;
}
consume {
 udrRoute( input );
 UDR_count = UDR_count + 1;
}
endBatch {
 file_count = file_count + 1;
 debug( "Number of UDRs in file:" + UDR_count );
}
deinitialize {
 debug(" Number of executed files:" + file_count );
}
exceptionHandling {
 debug(" Exception occurred, stacktrace: " 
 + exception.stackTrace); 
}


...