Storing parts of a text/string in SAP GUI

One of the key Qualibrate features is the ability to store information from the applications under test. Sometimes, users are interested in storing portions of large texts generated by the application, and Qualibrate gives users the ability to search parts of the text that they would like to store.
In this example, we will show you how to store the PO number from the full text displayed in an SAP status bar control. In the case of SAP applications, the code language supported is .NET (for Web applications, we use Javascript).

Example

Full Text

RMC - Standard PO 4500017748 changed

To Store

4500017748

Procedure

To store the number, we can use an advanced .NET code snippet to save only the portion needed from the full text. To do that, follow this procedure.

  1. Open the Recorder widget

  2. When the text you want to store appears, click the Store button in the Recording widget

  3. Select the control where the text appears (status bar, text field, etc.)

  4. After the “Store” step is added:

    1. Expand the recording control

    2. Change the User Action to “Custom”

    3. Click the “Configuration” button

  5. In the code editor, paste the following code:

    1 2 3 4 string[] txt; string[] sep = new string[] {" "}; txt = obj.Text.Split(sep,StringSplitOptions.None); return txt[4];
  6. Save the configuration

  7. Click “Save” in the recording widget

Want other parts of the text?

The code above splits the text into parts divided by a space key (“ “). Each part is saved into a text array which elements can be accessed by their index (enclosed in brackets). The text from this example is composed by 6 parts, which can be accessed as follows:

Full Text

RMC - Standard PO 4500017748 changed

RMC

txt[0]

-

txt[1]

Standard

txt[2]

PO

txt[3]

4500017748

txt[4]

changed

txt[5]