Close SAP Session

Closes an active SAP Session.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

closeSAPSession --sessionid(String) (Boolean)=value


  • The environment needs to have the SAP® software.
  • Get the Session Id parameter by the List SAP Sessions (listSAPSessions), Start SAP Session (startSAPSession) commands.

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
SAP Session ID sessionid Required Text Enter the SAP Session ID to be closed.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Success success Boolean Returns true if the session was successfully closed, otherwise returns false.


Starts a new SAP session, closes this session, and logs a message into IBM RPA Studio console with the result of closes attempt.

defVar --name windowApplication --type Window
defVar --name idApplication --type Numeric
defVar --name successStart --type Boolean
defVar --name sapSession --type SAPSession
defVar --name successClose --type Boolean
// Opens the informed SAP application, with username, password and customer id, in English.
startSAPSession --applicationpath "path\\sap.exe" --connectionstring "Connection string" --clientid 001 --username username --password password --language en sapSession=sapsession windowApplication=value idApplication=processId successStart=success
// Closes the SAP application using the ID obtained by the Start SAP Session
closeSAPSession --sessionid "${sapSession.Id}" successClose=value
logMessage --message "${successClose}" --type "Info"