Use the screen copy method to copy text to and from SAP screen blocks. This includes long text fields in SAP. Both the append and the appendline options are available when copying to a screen block.
Note: Do not use the fromtext option when copying text to screen blocks. You must use the fromstring option instead. The fromtext option will change the scope of the control to a string, resulting in the operation's failure.
-
Go to the IW32 screen and click the Show long text window button.
The button is located to the right of the Order description field and appears as follows:
The IW32 screen now appears as shown below:
-
Open the SAPLCOIH.3000.sjs script file. Create the file if it does not already exist.
-
Create a new textbox on the IW32 screen. The code is as follows:
textbox([2,87], [7,121],{ "name":"iw32_text", "textfont":"Arial", "textheight":"12", "textweight":"5"});
-
Create a toolbar pushbutton and a related function to perform the copy operation. The code is as follows:
pushbutton([TOOLBAR], "Screen Copy",{ "process":copy_test});
function copy_test(){
onscreen 'SAPLCOIH.3000'
copytext({"fromstring":"iw32_text","toscreen":"X[LTEXT]"});
enter();
}
The screen now appears as follows:
-
Enter some text in the new textbox you have created and click the pushbutton.
The screen now appears as shown below:
-
Change the function as follows to copy the text from the screen block:
pushbutton([TOOLBAR], "Screen Copy",{ "process":copy_test});
function copy_test(){
onscreen 'SAPLCOIH.3000'
copytext({"fromstring":"iw32_text","toscreen":"X[LTEXT]"});
enter();
}
You can use either of the following syntaxes:
copytext({"tostring":"iw32_text","fromscreen":"X[LTEXT]"});
copytext({"totext":"iw32_text","fromscreen":"X[LTEXT]"});
The first example is used for copying into a string variable. The second is sued for copying into a textbox.