Share this page

# lr.end_sub_transaction

Marks the end of a sub-transaction.

## JavaScript

    function lr.end_sub_transaction(  sub_transaction, status  )

## VBScript

    Function lr.end_sub_transaction(  sub_transaction, status  )

Transaction Functions

## Arguments

Name | Comments
--- | ---
sub_transaction | A string indicating the name of an existing sub-transaction.
status | The transaction status.

The lr.end_sub_transaction function marks the end of a sub-transaction. To mark the beginning of the sub-transaction, use the lr.start_sub_transaction function. You insert these functions immediately before and after the sub-transaction steps.

Multiple sub-transactions can be nested within a parent transaction, but each lr.end_sub_transaction statement must match an lr.start_sub_transaction statement or it will be interpreted as an illegal command.

## Return Values

On success, returns 0. Returns -1 if the transaction name is illegal or if there is no prior call to lr.start_transaction with a transaction of the same name.

## Parameterization

Standard parameterization is not available for this function.

## VBScript Example

This example shows how the durations of nested sub-transactions are reported.

Several sub-transactions are started with start_sub_transaction and ended with end_sub_transaction. These sub-transactions are nested and overlapped in various ways. The output below the example shows that the duration of each sub-transaction is the time between the start and end of that individual sub-transaction, entirely independent of what other sub-transactions are active at the same time.

    Dim i as Integer
    Dim baseIter as Integer

    baseIt(er = 1000)

    ' Start Parent
    lr.start_transaction "Master"

    ' Start first sub transaction
    lr.start_sub_transaction "FirstT", "Master"

    ' Start nested child of first sub transaction
    lr.start_sub_transaction "FirstT_Child1", "FirstT"

    ' Pause between scripts
    lr.think_time 1.5

    ' Start a sub transaction while FirstT_Child1 is still active.
    lr.start_sub_transaction "FirstT_OverLap_Child1And2", "FirstT"

    ' Create some elapsed time
    lr.think_time 0.5

    ' End FirstT_Child1.
    ' FirstT_OverLap_Child1And2 is still active
    lr.end_sub_transaction "FirstT_Child1",lr.AUTO

    ' Start second nested child
    lr.start_sub_transaction "FirstT_Child2", "FirstT"

    ' Pause between scripts
    lr.think_time 1

    ' End the overlapping sub transaction
    lr.end_sub_transaction "FirstT_OverLap_Child1And2",lr.AUTO

    ' Pause between scripts
    lr.think_time 1.75
    lr.end_sub_transaction "FirstT_Child2",lr.AUTO
    lr.end_sub_transaction "FirstT",lr.AUTO

    ' Start a second sub transaction
    lr.start_sub_transaction "SecondT", "Master"

    ' Pause between scripts
    lr.think_time 2
    lr.end_sub_transaction "SecondT",lr.AUTO
    lr.end_transaction "Master", lr.AUTO

    Example: Output:
    Notify: Transaction Master started.
    Notify: Transaction FirstT started.
    Notify: Transaction FirstT_Child1 started.
    lr_think_time: 1.50 seconds.
    Notify: Transaction FirstT_OverLap_Child1And2 started.
    lr_think_time: 0.50 seconds.
    Notify: Transaction FirstT_Child1 ended with Pass status (Duration: 2.0029 Think Time: 2.0029).
    Notify: Transaction FirstT_Child2 started.
    lr_think_time: 1.00 seconds.
    Notify: Transaction FirstT_OverLap_Child1And2 ended with Pass status (Duration: 1.5022 Think Time: 1.5022).
    lr_think_time: 1.75 seconds.
    Notify: Transaction FirstT_Child2 ended with Pass status (Duration: 2.7540 Think Time: 2.7540).
    Notify: Transaction FirstT ended with Pass status (Duration: 4.7669 Think Time: 4.7568).
    Notify: Transaction SecondT started.
    lr_think_time: 2.00 seconds.
    Notify: Transaction SecondT ended with Pass status (Duration: 2.0029 Think Time: 2.0029).
    Notify: Transaction Master ended with Pass status (Duration: 6.7797 Think Time: 6.7597).

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: