Liquid UI - WS Reference Library

globaltextreplace()


Purpose

With globaltextreplace(), you can replace user-specified text throughout the SAP environment.

This command can be used either to perform the replacement on all screens, or users can specify screens that can be either included or excluded from the replacement process. We recommend using this command in the 'esession.sjs' script file. This will apply the command even if you open a new session from an existing session. If you place the command in the 'elogon.sjs' script file, then the globaltextreplace() command will be read only when you login to SAP.

Note: You must have the wsoffice.dll installed in order to use this command. 


Syntax

There are two basic syntaxes that can be employed, as follows:

  1. This syntax is used in the case of a single screen being designated as needing text replacement. In this case, you must specify the screen dynpro name of the target screen.

    globaltextreplace(/TextToBeReplaced/,'ReplacementText',{"ocx":true,"listscreen":false,"screen":"DynProName"});
  2. This syntax is used in the case of multiple screens being designated as targets for text replacement. For multiple screens, do not include the 'screen' option in the command.

    globaltextreplace(/TextToBeReplaced/,'ReplacementText',{"ocx":true,"listscreen":false,"screen":["DynProName1","DynProName2"]});

Note: The globaltextreplace() command does not support replacing a short word with a longer word.

Please note that if you are replacing a hex number, you must isolate the term by preceding it with the caret mark (^). The following example, demonstrates replacing such a hex number.

globaltextreplace(/DEF/,'RSN');

However, in the above example, you must write /^DEF/ and not simply /DEF/. If the caret is not used, the term may not be correctly isolated and the operation will not succeed. DEF is the text to be replaced and RSN is the replacement text.


Available Options

You can use the following options with the globaltextreplace():

"listscreen":".."

"listscreen":true - The listscreen option is a boolean that specifies whether or not the listscreens will be affected.

"OCX":".."

"OCX":true - This option is a boolean that is used to determine if the globaltextreplace() will affect the ActiveX controls in SAP.

"screen":".."

"screen":"dynpro name" - The screen option specifies the screen name to affect that particular screen.


Options Detail

listscreen

  1. The listscreen option is a boolean that specifies whether or not the listscreens will be affected. If it is not included in the script, the command will automatically assume that the listscreens will be affected.

  2. globaltextreplace(/Priority/,'Level',{"listscreen":true});
  3. Navigate to /nqm10 transaction in SAPGUI. The "Priority" text in the list screen will get replaced with "Level" text.

OCX

  1. This option is a boolean that is used to determine if the globaltextreplace() will affect the ActiveX controls in SAP. When OCX is used, the 'screen' and 'listscreen' options may not be applied.

  2. globaltextreplace(/Favorites/,'List',{"ocx":true});
  3. As per the code, "Favorites" text in OCX control on SAPGUI will be replaced with "List" text.

screen

The screen option specifies the screen name to affect that particular screen. There are two possible uses of this option, which are as described below:

  1. Single Screen : This is used when a single screen is designated for globaltextreplace().

  2. globaltextreplace(/Order/,'Request',{"ocx":true,"screen":"SAPMV45A.4001"});
  3. As per the code, the "Order" text in the screen SAPMV45A.4001 is replaced with "Request".
  1. Multiple Screens : This is used when multiple screens are to be included in the text replacement operation like following:

  2. globaltextreplace(/Order/,'Request',{"ocx":true,"listscreen":false,"screen":["SAPMV45A.4001","SAPMV45A.0101"]});
  3. As per the code, the "Order" text on the screens SAPMV45A.4001 and SAPMV45A.0101 are replaced with "Request".

Note: You can run globaltextreplace() in ESESSION.SJS file for global replacement, or you can open the corresponding script file and execute the options for specific screen.


Example

The following example demonstrates the usage of globaltextreplace() command on OCX fields.

We will use the OCX option to apply the globaltextrepalce command to OCX fields in SAP. In this example, we will use the OCX option to do a text replacement on the Service:Attachment list in the IW32 transaction.


Script

Open the script file for the list screen and insert the following code:

//SAPLCOIH.E0101.sjs

globaltextreplace(/AttachmentFor000000825525/,'Request',{"ocx":true});
pushbutton([TOOLBAR],"Text Replace",{"process":do_gtr});


Tips and Tricks

  • New Nomenclature on SAP Screens

    The user can change the nomenclature throughout the SAP screens with the help of globaltextreplace() command. For example, consider that the concept "order" is used exclusively in the sense "request" in your R/3 system, possibly for a special user group only. If you would like to replace the word "order" by the word "request" throughout, apply globaltextreplace() command in esession.sjs script file.

    globaltextreplace(/Order/,'Request');