copytext

The copytext command copies text between files, screen areas or text variables.

There are several possible syntaxes, depending on the source and desitnation of the text to be copied. These syntaxes are as follows:

Syntax Description
copytext({"fromtext":"textbox_name", "totext":"textbox_name"});
Copies from one text box to another. Textboxes can be native SAP elements or user-created elements.
copytext({"fromtext":"textbox_name", "tostring":"variable_name", "line":x});
Copies text from a textbox to a string variable.
copytext({"fromtext":"textbox_name", "toscreen":"X[area_name]"}); Copies text from a textbox to a screen element such as a long text field.
copytext({"fromstring":"variable_name", "toscreen":"X[area_name]"}); Copies text from a string variable to a screen element such as a long text field.
copytext({"fromstring":"variable_name", "tostring":"variable name"}); Copies text from a string variable to a different string variable.
copytext({"fromstring":"variable_name", "totext":"textbox name"}); Copies text from a string variable to a text box.
copytext({"fromscreen":"X[area_name]", "totext":"textbox_name"}); Copies text from a screen element such as a long text field to a text box.
copytext({"fromscreen":"X[area_name]", "tostring":"textbox_name"}); Copies text from a screen element such as a long text field to a string variable.

Sources and Destinations

The copytext command can copy text between the following sources and destinations:

Source
Definition
Screens
Text can be copied from a native SAP screen element using the fromscreen syntax. Please note that the copy action actually will occur when the screen in question is displayed or upon the ensuing enter command in a script.
Textboxes
Text can be copied from user-created textboxes using the fromtext syntax.
Variables:
Text can be copied from a string variable using the fromstring syntax.

In addition, the copytext command can copy text into the following areas:

Destination
Definition
Screens
Text can be copied into a SAP screen element using the toscreen syntax. The area into which the text will be copied must be specified in the command. See the examples for additional information.
Textboxes
Text can be copied into a user-created textbox using the totext syntax.
Variables
Text can be copied into any string variable using the tostring syntax.

Options

fromscreen

Specifies that the text will be copied from a user-specified screen element such as a long text field.

{"fromscreen":"X[area_name]"}
fromstring

Specifies that the text will be copied from a string variable.

{"fromstring":"var_name"}
fromtext

Specifies that the text will be copied from a native or user-created textbox on a SAP screen.

{"fromtext":"textbox_name"}
toscreen

Specifies that the text will be copied into a user-designated screen element such as a long text field. The 'append' and 'appendline' options can be used in this case.

{"toscreen":"X[area_name]"}
tostring

Specifies that the text will be copied into a string variable.

{"tostring":"var_name"}
totext

Specifies that the text will be copied into a user-created or a native SAP textbox on a SAP screen. The append and appendline options can be used in this case.

{"totext":"textbox_name"}
append

The copytext command will normally over-write any content in the destination field. To avoid over-wrioting, the append or appendline options can be used. The append option appends the content to the end of the last line in the target text. The syntax is:

{"append":true}
appendline

The appendline option works very similarly to the append option, but will add the source text to the destination text as a new line. The syntax is shown below:

{"appendline":true}
delimiter

This option specifies the character used to separate text to be copied. The character to be used as a delimiter would be placed in the quotes. The syntax is below:

{"delimiter":""}
line

This option enables users to specify the number of the desired line to be copied into the string, starting with '1'.

Note: This option can only be used when copying to a string.
{"line": X}

Please see the following examples for more information.