With text(), you can display text on the screen.
You can use the text() command to display text on a SAP screen, use text in variables, and add icons to SAP elements.
Text command help in changing the name of the SAP elements; checkbox, context menus, inputfield, pushbutton, radiobutton, and tab.
- startrow, startcol - row and column co-ordinates
- Label name- name of the text label
- @0Y@Label name - name of the field with icon
- @4V\\Qlabel Tip@Label name - name of the field with tool tip and icon
You can use the following options with the text:
"comment":true - The text is displayed in different font and color.
"fixedfont":true - The text is displayed in fixed font.
"intensified":true - The text is displayed in blue color.
"left":true - Draws a line from text to the next nearest element.
The following examples demonstrate the usage of text() command.
Text display using variable
text([7,30],"Enter Notification Information");
Tips and Tricks
Changing the screen element name
The text command may also be used to change the name of an existing field, pushbutton, or radiobutton. In this example, we will change the name of Sales Organization field on the va01 initial screen. navigate to initial va01 screen and enter the following code.
text("F[Sales Organization]","Sales Org.");
As per the code, the name of the Sales Organization will change to "Sales Org.".
Displaying text from variables
To use the text command to display text stored in a variable, please navigate to va01 screen. Then open the script file, and enter the following code.
var z_txt = "create sales order screen!"; text([12,4],"You are on: "+z_txt);
As per the code, the output is You are on: create sales order screen!. This text is displayed on va01 initial screen.
Replace the field name
If you want to replace a field name throughout the SAP system, you can do it by means of the SAP repository or with the command GlobalTextReplace. For example:
Enter the following code in ESESSION.sjs file.
As per the code, the text "Order" is replaced throughout the SAPGUI with "Request".