Purpose
With copytext(), you can copy text between files, screen areas or text variables.
The copytext command replaces any text to the intended destination. This command works both on native SAP fields and on user-created fields.
Syntax
copytext({"source/destination command":"location","source/destination command":"location"});
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":", "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":", "tostring":"textbox_name"}); |
Copies text from a screen element such as a long text field to a string variable. |
Properties
Source - location from where to copy text
- Screen - from a native SAP screen element using the fromscreen option
- Textbox - from a user-created textbox using fromtext option
- Variables - from a variable using fromstring option
Destination - location to where to copy text
- Screen - to a native SAP screen element using the toscreen option
- Textbox - to a user-created textboxes using totext option
- Variables - to a variable using tostring option
Available Options
You can use the following options with the copytext:
"append":true - The source text is appended to the target text. |
|
"appendline":true - The source text is appended to the target text in a new line. |
|
"delimiter":"X" - Works only in combination with toString= and line=. Instead of "line feed" the specified character is considered as delimiter. |
|
"fromscreen":X[area_name] - To copy text from a user-specified screen element, such as a long text field. |
|
"fromstring":"var_name" - To copy text from a string variable. |
|
"fromtext":"textbox_name" - To copy text from a native or user-created textbox on a SAP screen. |
|
"line":X - You can only use this option in combination with toString=. You can specify the desired line number, starting with 1. |
|
"toscreen":"X[area_name]" - To copy text into a user-created screen element such as a long text field. |
|
"tostring":"var_name" - To copy text into a string variable. |
|
"totext":"textbox_name" - To copy text into a user-created or a native SAP textbox. |
Options Detail
Example
The following scenario demonstrates the copytext() command usage.
We will create a notification screen to add notification details. On saving the notification, the details appear on the PM notification screen. On updating the original notification, the updated notification appears on the PM notification home screen.
Script
copytext({"fromtext":"z_iw21_textbox1","toscreen":"X[TEXT]","append":true}); copytext({"totext":"z_iw21_textbox","fromscreen":"X[TEXT]"});
enter("/3");
Usage Details
-
Text editing on same screen
We can edit the text on single screen without navigating to the second screen through copytext command.
copytext({"fromscreen":"X[LONGTEXT_GRUNDD]","totext":"MM02_text"});
Learn more about copytext() command usage.