SAP — Log on
SAP — Log on
Section titled “SAP — Log on”Type: sap-logon · Package: SAP Activities v1.0.5 · Output: ZoanSapSession
Opens an SAP connection and logs on for you. It is the starting point of an unattended robot: it doesn’t depend on someone having left SAP open, because it logs on by itself with the user you give it and the password stored as a Zoan Cloud credential. If the session is already open and you just want to use it, use SAP — Attach.
How it works
Section titled “How it works”- Opens the connection. The SAP Logon program (
saplogon.exe) must be running; the activity opens a connection, not the program. Launch it first, for example with Open App: if SAP Logon is still starting, the activity waits up to 30 seconds (checking every half second) for it to become available. If it still isn’t open after that, it fails with a message that says so.connectioncan be the name of the SAP Logon entry or, if it starts with/, a/H/server/S/3200connection string, which bypasses the SAP Logon entries. - Fills in the logon screen. It types the client (if given) into
wnd[0]/usr/txtRSYST-MANDT, the user intotxtRSYST-BNAME, the password intopwdRSYST-BCODEand the language (if given) intotxtRSYST-LANGU, and presses Enter. If the connection logs straight in without asking for credentials (SSO or SNC), it writes that to the log and moves on. - Handles the known dialogs that show up right after (up to three in a row):
- Multiple logon (the user already has another session open): it answers according to
ifAlreadyLoggedOnand leaves a warning in the log. - Mandatory password change: it stops with an error. Changing the password from a robot would mean deciding for the account owner and would leave the credential out of date.
- Any other dialog (for example, system messages) is left open and reported in the log so you can close it with SAP — Close modal.
- Multiple logon (the user already has another session open): it answers according to
- Checks that it got in. If the session ends up with no user, it fails with whatever message SAP left in the status bar. If it logged on with a different user than requested, it warns in the log.
If the logon fails at any point, the activity closes the connection it opened, so no logon screen is left holding a dialog process on the system.
The elementTimeout you set here travels with the session: it is how long every activity that uses it waits for its element. If you leave it empty, the timeout from the project settings applies and, if that is not set either, 30 seconds.
With body, the activities inside inherit the session and, when they finish (successfully or with an error), the connection is closed unless you turn on keepOpen. Without body, the session is returned as output to use in the session parameter of other activities.
The password comes in as a credential: it is not stored in the playbook and doesn’t show up in the logs.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
connection | string | — | Name of the entry in that machine’s SAP Logon —the Name column, not the system ID— or a /H/server/S/3200 connection string. Ex: "DEVELOP". |
user | string | — | SAP user. |
password | credential | — | Password, from the credential store. Use credential(...). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
client | string | — | Client, leading zeros included. Ex: "001". Empty leaves whatever the screen proposes. |
language | string | — | Logon language (EN, ES…). Empty uses the system default. It decides the language of every message the flow reads afterwards. |
ifAlreadyLoggedOn | string | "Keep other sessions" | What to answer when SAP reports the user already has a session open: Keep other sessions (keeps the others; SAP records a multiple logon), End other sessions (closes them) or Cancel logon (the activity fails). |
keepOpen | bool | false | Leave the SAP window open when the body ends. Off closes the connection this activity opened. Also accepts an expression that returns true or false. |
elementTimeout | number | 30 | Seconds every activity waits for its element to appear. Empty uses the project settings value or, if there is none, 30. With 0 they fail on the first try, useful while debugging a selector. |
Sub-flows
Section titled “Sub-flows”Activities to run with this session. They inherit the session without setting session. On leaving the body, the connection is closed (unless keepOpen) and whatever scope session there was before is restored.
Output
Section titled “Output”Returns the session (ZoanSapSession) when you do not use body (or the body is empty). With body, the session is used inside and the activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
SAP Logon is not running: there is no SAPGUI object in the Running Object Table. sap-logon opens a CONNECTION, not the program; start saplogon.exe first (with open-app, for instance). Waited 30 s for it. | SAP Logon did not start within 30 seconds. Open it first with Open App. |
SAP GUI answers but does not hand over the scripting engine. … | Scripting is disabled on the server or on the client. See Requirements. |
Could not open the connection. If it is a name, it must be the one in the Name column of SAP Logon on THIS machine, exactly; if it is a string, it looks like /H/server/S/3200. (…) | connection matches no SAP Logon entry on that machine, or the string is malformed. Copy it exactly from the Name column. |
The connection opened but exposed no session. | SAP GUI opened the connection without a session window. Retry; if it persists, check the entry in SAP Logon. |
The logon screen does not expose the password field. … | The system profile forbids writing the password from scripting. Log on by hand (or via SSO) and use SAP — Attach. |
SAP requires a password change before logging on. Change it by hand and then update the credential in the store. | The password expired or is an initial one. Change it by hand and update the credential. |
The user already had another session open and ifAlreadyLoggedOn = "Cancel logon". | You asked to cancel on a multiple logon. Close the other session or change ifAlreadyLoggedOn. |
The logon did not complete. SAP said: [E] … | SAP refused the logon (wrong user or password, locked user, unknown client…). The text is the status bar’s. If SAP left no message, it is just The logon did not complete. |
'connection' is required. · 'user' is required. | The connection or the user is missing. |
Plus the errors common to all activities. Since a failed logon closes the connection, you can retry it with Retry without leaving logon screens open.
Example
Section titled “Example”Open App path = "C:/Program Files (x86)/SAP/FrontEnd/SAPgui/saplogon.exe"SAP Logon connection = "DEVELOP" client = "001" language = "EN" user = credential("sap-dev")["user"] password = credential("sap-dev") └─ body: SAP Close Modal SAP Run Transaction code = "SE16" ... rest of the flow ...Without body, keeping the session to use it later:
SAP Logon connection = "DEVELOP" client = "001" language = "EN" user = credential("sap-dev")["user"] password = credential("sap-dev") → output: sapSAP Run Transaction session = sap code = "SE16"Related activities
Section titled “Related activities”- SAP — Attach — use a session that is already open.
- SAP — Close modal — close the system messages after logon.
- SAP — Run transaction — the usual next step.