Share this page

# lr.set_transaction

Creates a completed transaction.

    int lr.set_transaction( String name, double duration, int status);

Transaction Functions | Java Syntax

## Arguments

Name | Comments
--- | ---
name | A name for the transaction.
duration | Transaction duration in seconds.
status | The transaction completion status. One of the Transaction Status constants for pass, fail, or stop. The auto status is not applicable.

The lr.set_transaction function creates a transaction, its duration, and status in a single call. Use it where the business process you want to capture in a transaction does not consist of sequential steps, or where you may or may not want to create a transaction, depending on conditions that are known only during the test.

To create a transaction for non-sequential steps, capture the duration of each series of steps that participate in the business process. Sum the durations and create the transaction with lr.set_transaction.

To capture durations in C language scripts, use lr.start_timer and lr.end_timer. For other languages, use the native language time functions.

lr.set_transaction can also be used to report the duration of a failed transaction by saving the duration before the transaction fails with lr.get_transaction_duration then using lr.set_transaction to create a new transaction for reporting that time.

lr.set_transaction creates and closes the transaction. Therefore, no functions that work only on open transactions are applicable.

Note: For information on allowed characters and maximum length for transaction names, see Transaction guidelines in the Virtual User Generator Help Center.

## Return Values

This function returns lr.PASS (0) on success, and lr.FAIL (1) on failure. Note that in many cases, this return value indicates the technical success of the function, and not the result. For example, a function that registers a string to be found in a subsequent step returns lr.PASS to indicate that the registration was successful. This does not indicate that the string was found in the server response.

## Parameterization

All string arguments (char type) can be parameterized using standard parameterization.

## Example

This example creates a transaction, "Multiple_Orders", with a 45.3 second duration.

lr.set_transaction("Multiple_Orders", 45.3, lr.PASS);

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: