onTcodeTerminate

The 'onTcodeTerminate' event handler is executed only when the specific transaction in which you are working exits. This exit triggers an action. The syntax is as follows.

onTcodeTerminate[_transaction] = function() { 
	\\some logic here 
}
Note: The '_transaction' is a system variable - it contains the current transaction code.

Options

The onTcodeTerminate command does not take any options.

Example

In the following example, we will demontrate how the 'onTcodeTerminate' event handler works. Please do the following.

  1. Navigate to the VA01 transaction if you are not already there.
  2. Open the SAPMV45A.E0101.sjs script file and use the set command to create two variables as shown by the following code.

    set("V[z_test]" , "test");
    set("V[z_test2]" , "test2");
  3. dd the onTcodeTermiante event handler to trigger an action when the VA01 transaction exits, as shown below. Also add some println commands to show output in the console.

    onTCodeTerminate[_transaction] = function() {set("V[z_*]" , ""); }
    println("-----------Value of z_test in va01----" + z_test);
    println("-----------Value of z_test2 in va01----" + z_test2);
  4. Save your changes in the script file and then exit the transaction. The script essentially will zero out the values in all variables that start with 'z_'. Verify that the values are zeroed by checking the console - it will display the new values for the variables.