enter

The enter command simulates user actions within SAP screens.

The enter command can be used to trigger function codes (fcodes), SAP transactions, functions, and other such actions. This command also is often used in conjunction with the onscreen and onUIEvents commands. The syntax is as follows:

enter('action');

Parameters

There are a number of parameters that can be passed to the enter command. These parameters are as follows:

Parameter Definition
Function key code

Each function key is mapped to a specifc code. This code can be passed as a parameter to the enter command. In the following example, we will pass the code for the F3 function key:

enter('/3');
SAP transaction code

You can also pass a SAP transaction code to the enter command. In the following example, we will pass the code for the VA01 transaction:

enter('/nva01');
Function names

You can pass function names associated with menu items or pushbuttons. In the following example, we will pass the name of a function entitled 'HEAD':

enter('=HEAD');
SAP system status window

To launch the system status window, you can use the following code:

enter('?STAT');
No parameters

To perform a simple enter command without passing any parameters, use the following syntax:

enter();
ScrollToLine

You can scroll to a specific line in a table by using this parameter. The 'absrow' variable in the following example is the absolute row number of the row to which you will be scrolling, and the 'tablename' variable is the name of the table.

enter('ScrollToLine=&V[absrow]', {"table":"T[tableName]"});
Note: The scrolltoline parameter is always used with the table option and will not work on an empty table.
Tab code

SAP tabs also are associated with unique codes that can be passed to an enter command as shown below:

enter('=SP19');

You can also use the alternate syntax shown below to pass a tab code:

enter('=T\\03');
Menu items

You can use enter to navigate to a specific menu item as well. In the following example, we will pass the code for the Log off menu item:

enter('/Menu=5,13');

Options

The enter command takes the following option:

table

Specifies a table control that we will operate on. This option is always used with the scrolltoline parameter. The syntax is shown below:

enter('ScrollToLine=&V[absrow]', {"table":"T[tableName]"});
Note: The scrolltoline option will not work on an empty table.

Please see the following examples for more information.

Examples

Sending a function code

To send the code for the F11 function key with the enter command, please enter the following code into the CO11N script file:

onscreen 'SAPLCORU_S.0100'		
		enter('/11');

Sending a transaction code

To send the SAP tcode for the CO11n transaction with the enter command, please use the following code:

enter('/nco11n');

Calling a function

To call a function with the enter command, please do the following:

  1. In the SAPMV45A.E0102.sjs script file for the VA01 transaction, enter the following code:

    onUIIevents['Enter']={"fcode":"/nva02", "process":testUIEvent};
    Note: See the onUIEvents section for details on using the onUIEvents command.
  2. Write a function that will execute when the pushbutton is pressed. An example function is as follows:

    function test_UIEvent() {
    	onscreen 'SAPMV45A.0102'
    		set("F[Order]", "14200");
    	enter();
    	onscreen 'SAPMV45A.4001'
    	enter();
    }
  3. Press the pushbutton to trigger the process. the function will execute, taking you to the referenced transaction and filling in the specified fields. The results will be as shown below: