Liquid UI - Documentation - 5.11 text()

5.11 text()


Purpose

The text() is used to display various types of text on the SAP screen, including single-line text, text in variables, icons for SAP elements, and creating comments. Additionally, text() allows you to modify existing SAP screen elements such as checkboxes, context menus, input fields, push buttons, radio buttons, and tabs.

 

Note: Click here for more details on how to position the screen elements.

 

Syntax

You can create text using different formats depending on your requirements, as explained below:

Format 1: Basic Text placement

To create a text with a label at the specified position and options.

 
// Creates a text with a label at specified row and column coordinates
text([row,col],"label name",{option:"options,values"});
// Creates a text using the size option text([7,25],"Enter Notification Information"{size:30}); // Creates a text with intensified option text([1,10],"shipping conditions",{"intensified":true});
 

Format 2: Text without options

// Creates a text without options
text([row,col],"label name");
// Creates a text with label name text([7,25],"Enter Notification Information"{size:30}); // Creates a text using a variable text([12,4],"You are on: "+z_txt);
 

Format 3: Replace SAP screen element name

 
// Renames screen element
text(F[screen element],"screen element name");
// Replaces the screen element name with the label name text("F[Sales Organization]","Sales Org.");
 

Format 4: Text with respect to other screen elements

 
// Creates a text with reference to the other fields on the same screen
text("F[screen element]+[row,col]","label name");
//Creates a text with respect to other field elements on the screen text(F[Material]+[0,46],"Raw Material");
 

Properties

  • row, col - Row and column coordinates
  • label name- Visible name of the text/li>
  • @0Y@label name - Name of the field with icon
  • @4V\\Qlabel Tip@label name - Name of the field with tooltip and icon
  • screen element - Field name
 

Available Options

You can use the following options with the text:

"comment":".."

"comment":true - Displays the text in different fonts and colors.

"fixedfont":".."

"fixedfont":true - Displays the text in a fixed font.

"intensified":".."

"intensified":true - Displays the text in blue color.

"left":".."

"left":true - Draws a line from the text to the next nearest element.

"size":".."

"size":value - Specifies the size of text.

Options Detail

The following options demonstrate the usage of text() in customizing the SAP screens.

comment

  1. The comment option will change the text color and font.
     
    text([20,12],"The notification information appears on the Create PM screen",{"comment":true});
     
    Changes the text and font color
     
  2. The difference between the comment and intensified options lies in their effects: the comment option alters both color and font, while the intensified option affects only the color of the text.

fixedfont

  1. This option will display the text in a fixed font.
     
    // Creates a text in a fixed font
    text([F[Notification type]],"Select Notification type",{"fixedfont":true});
     
    Displays text in a fixed font
     
  2. As per the code, the text font is fixed.

intensified

  1. The intensified option will display text in blue color.
     
    // Displays text in blue colour
    text([2,33],"Do you want to create a new class?",{"intensified":true});
     
     Display text in blue color
     
  2. As per the code, the text will appear in blue while maintaining the same font.

left

  1. The left option will draw a line from the text to the closest screen element, positioned to the right of the text.
     
    text([2,3],"Requisitions with line items and release codes",{"left":true});
     
    Draws a line from the text to the closest screen element
     
  2. As per the code, a line is drawn from the text to the right.

size

  1. The size option permits you to allocate a specific number of character spaces for the text on the screen.
     
    // Specifies the number of character spaces
    text([1,4],"Select Notification type",{"size":26});
     
    Defines the number of character spaces allocated for the text
     
  2. As per the code, text is displayed with a specified number of character spaces.

Example 1: Display text using a variable in format 2

The following example demonstrates how to create a text without options.

 
//Creates a text without options 
text([7,30],"Enter Notification Information"); 
 
Creates a text withput options
 

Click here for details on how to create a text.

Example 2: Display text concerning an input field using format 4

The following example demonstrates how to create a text with respect to an input field.

 
// Creates a text concerning the input field
text("F[Material]+[0,46]","Raw Material");
 
Creates a text with respect to input field
 

Example 3: Display text with the size option using format 1

The following example demonstrates the usage of the text() command with the size option.

 
// Creates a text concerning the input field
text([7,25],"Enter Notification Information"{size:30});
 
Creates a text with specified size
 

Click here for details on how to copy text to other screen elements.

Usage Details Tips and Tricks

Changing the screen element name

The text command can also be utilized to rename an existing field, push button, or radio button. In this example, we will modify the name of the Sales Organization field on the Create Sales Order: Initial Screen (VA01).

//Create the SAPMV45A.E4001.sjs file inside your scripts folder for customizing the Change Sales Order: Initial Screen
// Now, add the Liquid UI script to the above file

 
  1. Logon to SAP and navigate to the VA01 Initial screen. Now, you can see the name of the Sales Organization is changed to Sales Org, as shown in the image below.
     
    // Changes the name of Sales Organization input field to Sales Org.
    text("F[Sales Organization]","Sales Org.");
     
    Renames the text
     
Displaying text from variables

The text command is used to display the text stored in a variable.

  1. Navigate to the VA01 screen, you can see the text You are on: create sales order screen! , as shown below.
     
    // Displays the text stored in variable
    var z_txt = "create  sales order screen!";
    text([12,4],"You are on: "+z_txt);
     
    Displays the text stored in variable
     
Replace the field name

If you want to replace a field name throughout the SAP system, you can do it using the SAP repository or with the command GlobalTextReplace

  1. Navigate to the VA01 screen, and you can see that the text Order is replaced throughout the SAP GUI with Request.
     
    // Replaces the text Order to Request
    globaltextreplace(/Order/,'Request',{"ocx":true});
     
    Replaces the text Order to Request
     
  2. As per the code, the text Order is replaced throughout the SAP GUI with Request.

Usage Details


Can't find the answers you're looking for?