Appearance
Several sessions at once
An agent can work in several SAP sessions at the same time: one task per session, each named by its id on every call. This page says how to get more sessions, how to keep track of them, and what to do when SAP or the browser says no.
One task, one session, one id
sap_sessions lists every session with its id (id=chrome:..., id=sapgui:...). Pass that id as session on every call of a task:
json
{"session": "chrome:6A1F", "do": "set", "id": "ctxtVBAK-VBELN", "value": "4711"}- Calls on different sessions run at once. Calls on the same session wait their turn, and the answer of one that waited says how long.
- A call keeps to the session it named, even if another one becomes the active one meanwhile (
sap_use, a logon, an/ocommand). - Without
session, a call goes to the active session (*in the list). That is fine for one task; with several, always name the id.
The same rule holds for the CLI (--session <id>) and the SDK (connect({ session })).
Open another session
| From | How | What you get |
|---|---|---|
| SAP GUI for Windows | sap_act {"newSession":"VA03","session":"<source-id>"} | a new window of the same logon, opened with /oVA03 |
Web GUI (launch or attach) | the same call | a new Web GUI tab of the same system, sent to VA03 |
| Fiori | not with newSession: open a second launchpad tab, or sap_logon with newSession: true | |
| any registered system, with the extension | sap_logon {"system":"S4H","newSession":true} | a new window, logged on by the extension, even when the system is open already |
newSession goes on its own in the call, with the source session and nothing else. The answer gives both ids, the source and the child, and says whether it could identify the child; pass the child's id on each call for the new task. With SAP_STRUCTURED=on, sessionOpen holds source, outcome and child.
The answer's outcome:
| Outcome | Means | Do |
|---|---|---|
opened | the new session is there, on the transaction | work in it by its id |
needs_attention (Web GUI) | the tab exists but is not on the transaction yet: a logon, a popup, a page still loading | inspect that tab by its id with sap_sessions and sap_look, and sort it out there, before you open another |
limit (SAP GUI) | SAP reports its limit of sessions for this logon (often six) | close SAP's information popup on the source; do not send /o again while it shows. Reuse an idle session of your task, or close one you own when its work is done |
ambiguous (SAP GUI) | several new windows match this logon | list the sessions and check which one you mean before you go on |
timeout (SAP GUI) | no new window appeared in time; the call is still on the source session | list the sessions before you try again: the window may have come late |
sap_logon with newSession says whether the session is new or reused, its id, and whether SAP shows the logon's system, client and user (verified). SAP may ask about the user's other logons: ask the user, as for any logon, and pass otherLogons: "keep" only when they say so.
Keep the ids
- Keep the full ids the open call returned. A closed tab's id expires; a tab that replaces it gets a new one.
- After the MCP server restarts, with the same Chrome still running, list the sessions again and read each surviving tab by its id to see which order or document it holds. If a screen is still loading, read it again before you act.
- A Web GUI tab where SAP shows no system yet (still loading, a popup) is marked
not verifiedin the list: do not work in it until it is.
When SAP GUI opens windows for someone else
SAP GUI for Windows says which logon a new window belongs to, not which window opened it. Servers on the same desktop coordinate their open requests, across scripting and the network reader: if another one is opening a window, wait until it is done before you try again. When a person or another tool opens windows on the same desktop, agree with them who opens when. If several new windows appear, list the sessions and check the one you mean before you go on.
When Web GUI refuses /o
Some Web GUI systems refuse /o even from a single tab, and show an information popup. Close the popup, open the system's usual Web GUI start address in a separate tab, and check its id with sap_sessions. The number of tabs open does not tell whether SAP will refuse (SAP KBA 2525757).
Limits
- How many sessions a logon may have is SAP's setting, often six; a browser's tab count does not tell.
- Fiori has no
newSession. - With the network reader, every connection goes through the shared background DIAG router; a second session of a logon comes with
/o(Network reader). - What each method supports, with the tests and dated checks behind it: Capabilities by method.
