SAP — Get text
SAP — Get text
Section titled “SAP — Get text”Type: sap-get-text · Package: SAP Activities v1.0.5 · Output: string
Reads the text of an SAP element: a field’s value, a label, a window title. It is the way to bring into your flow a piece of data SAP shows on screen —a document number, a name, a status— to store it, compare it or send it to another system.
How it works
Section titled “How it works”It waits for SAP to finish processing, looks up the element by its selector (waiting for it to appear, up to timeout) and returns its text exactly as SAP shows it. If the element has no text, it returns an empty string.
If the element doesn’t appear in time, it fails and tells you which screen the session is on.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | Element to read. Ex: "wnd[0]/usr/txtRSYST-BNAME" or "wnd[0]/titl" (window title). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanSapSession | — | SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on. |
timeout | number | — | Seconds to wait for the element to appear. Overrides the scope’s elementTimeout. Empty uses the scope value (30 by default); 0 fails on the first try. Decimals allowed. |
Output
Section titled “Output”Returns a string with the element’s text, as SAP shows it (spaces are not trimmed). If the element has no text, or is of a type without a text property, it returns "".
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Component '…' does not exist in the SAP session. Waited … s for it to appear. The current screen is … dynpro … (transaction …). … | The element did not appear in time. The message says which screen the session is on: it is almost always a different one than expected (a dialog in front, a step that didn’t happen). If the screen is slow, raise timeout. |
Plus the errors common to all activities.
Example
Section titled “Example”SAP Run Transaction code = "SE16"SAP Get Text selector = "wnd[0]/titl" → output: titleLog message = "Current screen: " + titleRelated activities
Section titled “Related activities”- SAP — Read status bar — read the status bar message.
- SAP — Read table — read a whole table.
- SAP — Element exists — check first whether the element is there.