Skip to content

SAP — Run transaction

Type: sap-run-transaction  ·  Package: SAP Activities v1.0.5

Opens an SAP transaction by its code, just like typing SE16 in the command field and pressing Enter. It is the usual step to reach the screen you are going to automate, without depending on menus or favorites. It also checks that the transaction really opened, something SAP doesn’t always make clear.

  1. It waits for SAP to finish processing and looks for the command field (wnd[0]/tbar[0]/okcd). If it can’t find it, it fails: almost always because a modal window is in front; close it first with SAP — Close modal.
  2. It types the code with the /n prefix (replaces the current transaction) or /o if you turn on newWindow (opens it in a new mode), and presses Enter. If you type /n or /o at the start yourself, it is kept. Codes with a namespace, such as /SCWM/MON, also get their prefix (/n/SCWM/MON), so you write them just as they appear in SAP. Other command-field commands starting with / (for example /*SE16) are typed as is.
  3. It checks the result:
    • If the status bar shows a message of type E or A, the activity fails with SAP’s text.
    • If the session is still on the same transaction as before and SAP left a message, the activity fails saying the transaction didn’t open. This catches cases such as “Transaction XXXX does not exist” or missing authorization, which SAP announces with a message of type S (success).
    • Any other message is written to the log.

With newWindow on, the transaction opens in another mode and the current session doesn’t change, so step 3’s check is skipped in that case.

ParameterTypeDefaultDescription
codestring—Transaction code, without the /n prefix. Ex: "SE16", "/SCWM/MON". If you type /n or /o at the start yourself, it is kept. It also accepts parameters after the code (anything after the first space is ignored by the check).
ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
newWindowboolfalseOpen it in a new SAP mode (/o) instead of replacing the current one (/n). Also accepts an expression that returns true or false.

This activity does not return a value. It logs the transaction it opened (Transaction … opened.) and, if SAP left a notice in the status bar, its type and code.

MessageCause and fix
Transaction '…' did not open: the session is still on '…'. SAP said [S …]: …The code doesn’t exist or the user lacks authorization: SAP announces it with a type S message and the session stays where it was. Check the code and the user’s permissions.
SAP replied [E …]: …SAP rejected the command with an error.
The command field (wnd[0]/tbar[0]/okcd) was not found. Is a modal window open in front? Close it with sap-close-modal.A dialog covers the main window. Close it first with SAP — Close modal.
'code' is required.code arrived empty.

Plus the errors common to all activities.

SAP Attach system = "DEV" client = "001"
└─ body:
SAP Run Transaction code = "SE16"
SAP Set Text selector = "wnd[0]/usr/ctxtDATABROWSE-TABLENAME" value = "T000"
SAP Send Key key = Enter