Skip to content

SAP — Set text

Type: sap-set-text  ·  Package: SAP Activities v1.0.5

Types a value into an SAP field: a table name, an order number, a date, a client. It is the activity you will use most to fill in selection screens and forms. It works with regular text fields, fields with a search help (the ones with the F4 button) and password fields.

Waits for SAP to finish whatever it is processing, finds the field by its selector and replaces its content with value. It does not append text: whatever was in the field is replaced.

If the field is not on the screen yet, the activity waits for it up to the configured limit (the activity’s timeout or, if you leave it empty, the elementTimeout of SAP — Attach or SAP — Log on, 30 seconds by default). If the time runs out, the error states which program, screen (dynpro) and transaction the session is on, so you can quickly see whether SAP reached a different screen than expected.

The selector can be a selector captured with the Designer or the raw SAP id as text, for example wnd[0]/usr/ctxtDATABROWSE-TABLENAME.

ParameterTypeDefaultDescription
selectorselector—Field to fill in: text (txt), with search help (ctxt) or password (pwd).
valuestring—Text to type. If it is longer than the field, SAP truncates it to the field’s length. Empty clears the field.
ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
timeoutnumber—Seconds to wait for the field to appear. Overrides the scope’s elementTimeout. Empty uses the scope value (30 by default); 0 fails on the first try. Decimals allowed.

This activity does not return a value.

MessageCause 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.
SAP GUI error when setting the textThe element is not an editable field (for example, a label or a field that is read-only on that screen). Check the selector or the transaction mode.

Plus the errors common to all activities.

Query table T000 in transaction SE16:

SAP — Attach system = "A4H" client = "001"
└─ body:
SAP — Run transaction code = "SE16"
SAP — Set text selector = "wnd[0]/usr/ctxtDATABROWSE-TABLENAME" value = "T000"
SAP — Send key key = Enter