Attach SAP Session
Attaches to 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.
attachSAPSession --sessionid(String) (SAPSession)=sapsession (Window)=value (Numeric)=processId (Boolean)=success
Dependencies
- 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. |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
SAP Session | sapsession |
SAP Session |
Returns the current attached SAP session. |
Window | value |
Window |
SAP window open on connection. |
Process ID | processId |
Number |
SAP application process id. |
Success | success |
Boolean |
Returns true if the session was attached, otherwise returns false . |
Example
Lists the quantity of instances and use the Attach SAP Session command to attach the first instance.
defVar --name value --type Window
defVar --name processID --type Numeric
defVar --name success --type Boolean
defVar --name sapSession1 --type SAPSession
defVar --name sapSessions --type List --innertype SAPSession
defVar --name sapSessionOut --type SAPSession
defVar --name sapSession2 --type SAPSession
defVar --name sapSession --type SAPSession
defVar --name successAttach --type Boolean
// Starts two SAP application to use and log a message in the studio if the applications was started.
startSAPSession --applicationpath "path\\sap.exe" --connectionstring "Connection string" --clientid 001 --username username --password password --language en sapSession1=sapsession windowApplication=value idApplication=processId success=success
logMessage --message "Session 1 opened: ${success}\r\n---------------------------------------------------------" --type "Info"
startSAPSession --applicationpath "path\\sap.exe" --connectionstring "Connection string" --clientid 001 --username username --password password --language en sapSession2=sapsession windowApplication=value idApplication=processId success=success
logMessage --message "Session 2 opened: ${success}\r\n--------------------------------------------------------" --type "Info"
// List the number of SAP Sessions are active, and log in the studio the result.
listSAPSessions success=success sapSessions=value
logMessage --message "Number of instances: ${sapSessions.Count}\r\n\r\n-------------------------------------------------------" --type "Info"
// Get the first instance of SAP.
get --collection "${sapSessions}" --index 1 sapSession=value
// Attach the instanste for maniputation.
attachSAPSession --sessionid "${sapSession.Id}" sapSessionOut=sapsession value=value processID=processId successAttach=success
// Open a task using transaction code.
sapTransaction --transactionCode "TRANSACTION CODE"