SAP
The SAP connector supports SAP Systems of Release 4.6C and higher and the SAP NetWeaver RFC SDK 7.50. For more information, see SAP NetWeaver Remote Function Call (RFC) Software Development Kit (SDK).
The SAP connector uses the Remote Function Call (RFC) enabled Function Modules (FMs) to communicate with the target SAP system. RFC is a mechanism that allows business applications to communicate and exchange information in predefined formats with other systems. SAP uses Common Programming Interface for Communication (CPIC) protocol to transfer data between systems. CPIC is a SAP specific protocol. RFC is a communications interface based on CPIC. It has more functions and it is easier for application programmers to use.
Prerequisites for using the SAP Actions
Windows
1. On the machine where the ThingWorx Flow server is installed, follow this link to install the SAP libraries.
2. Add these libraries to the system PATH.
3. Use the echo %PATH% command in a new Command Prompt window to verify that the path is updated.
4. Run the pm2 restart all --update-env command.
5. Refresh the ThingWorx Flow browser page.
* 
Whenever your machine restarts, run the pm2 restart all --update-env command.
Linux
1. On the machine where the ThingWorx Flow server is installed, follow this link to install the SAP libraries.
2. Create the flow.sh file under the /etc/profile.d directory.
3. In the flow.sh file, add the path to the SAP library.
export LD_LIBRARY_PATH=/opt/sap
4. Use the echo $LD_LIBRARY_PATH command in a new Command Prompt window to verify that the path is updated.
5. Run the pm2 restart all --update-env command.
6. Refresh the ThingWorx Flow browser page.
Connector Release Version
SAP connector was delivered in the 8.4.1 release.
Supported Actions
Supported Triggers
None
Supported Authorization
Basic
Adding a SAP Connection
Connections are a combination of a system identifier (URL) and the system account authorization that you want ThingWorx to use to access a system. SAP connection is required for each SAP connector action.
To add a new SAP connection, do the following:
1. In the SAP Connection field, select Add New. The Add Connection window opens.
2. In the Add Connection window, enter the following details:
Label—Autopopulated. You can provide the connection label of your choice.
* 
Labels are case-sensitive. Do not use spaces, some special characters, and leading numbers.
Host—The SAP host IP or alias. Host is also referred to as “Application server” or “Group/Server” in NetWeaver.
User Name
Password
System Number—Unique identifier of a SAP system. System Number is also called Instance Number which can be found in connection properties while connecting through NetWeaver as the property. Instance Number is a two digit number ranging between 00-97. Alternately you can also use FM GET_SYSTEM_NUMBER to get the system number.
Client—The SAP client id. The RFC client SDK is available from SAP Marketplace and the SAP Marketplace is inaccessible with trial accounts.
Language—The language details such as EN for English, FR for French, and so on.
3. Click ADD. A new connection is added to the list.
4. Click TEST to validate the added connection.
* 
If you are unable to add a SAP connection on RHEL, then refer to the workaround for the SAP known issue documented here.
Examples
Let us say we have a requirement to configure an alert to get material ID and material data, and then send an SMS to the operator about the Cross-Plant Material Status.
1. Use ThingWorx trigger to configure an alert
2. Get material ID from ThingWorx for a given Thing and then get material data from SAP
3. Send an SMS to the operator about the Cross-Plant Material Status using Twilio
Use ThingWorx Trigger to Configure an Alert
Let us set up a ThingWorx trigger that fires off each time a new alert is created in the ThingWorx account.
1. Place the pointer on the start icon, and then click or double-click the start icon. A list of triggers appears.
2. Select the ThingWorx trigger, and then create a new event. The ThingWorx trigger configuration window opens.
* 
If a trigger is already created, select the existing trigger, and then click SAVE. To create a new trigger, click Create a new event for ThingWorx, and then proceed with the steps further.
3. Enter the information in the trigger configuration window, and then click SAVE.
Get Material ID from ThingWorx for a Given Thing and then Get Material Data from SAP
We will now configure the Get Thing Properties action in ThingWorx and Get Records action in Dynamics 365 CRM. Whenever a new alert is created, you get the customer asset code automatically. To configure the Get Thing Properties action and Get Records action, do the following:
1. Drag the Get Thing Properties action under the ThingWorx connector to the canvas, place the pointer on the action, and then click or double-click the action. The Get Thing Properties action window opens.
2. In the Get Thing Properties action window, enter the information that follows:
a. In the Find By list, select Selection.
b. In the Thing field, select a Thing such as SAPThing on which the property is to be set. A list for first 500 items is displayed. To view more items, click LOAD MORE.
* 
For the Thing, Template, or Shape lookups, first 2000 items are queried and if the item that is searched for is not in the list, then apply an initial filtering to get the item in the result set.
c. In the Property field, select the materialId property to get the material ID.
d. Click Done.
3. Drag the Get Material Data action under the SAP connector to the canvas, place the pointer on the action, and then click or double-click the action. The Get Material Data action window opens.
4. In the Get Material Data action window, enter the information that follows:
a. In the Material ID field, map the SAPThing materialId under the trigger data section.
b. In the Plant field, select an available plant for the provided material ID.
5. Click Done.
Send an SMS to the Operator Using Twilio
We will configure the Send an SMS action in Twilio. Once you get the material ID and material data, the operator is notified and receives an SMS. To configure the Send an SMS action, do the following:
1. Drag the Send an SMS action under the Twilio connector to the canvas, place the pointer over the action, and then click or double-click the action. The Send an SMS action window opens.
2. In the To Number field, enter the destination phone number with plus sign and country code. If you do not provide the plus sign and country code, Twilio uses the same country code from the From Number field.
3. In the From Number field, enter the Twilio phone number or alphanumeric sender ID enabled for the type of message to send. The phone numbers or short codes purchased from Twilio work here. For example, you cannot spoof messages from your own cell number.
4. In the Message field, enter the text message to send. You can map the Cross-Plant Material Status under the trigger data section to this field.
5. Click Done.
* 
SAP® is a registered trademark of SAP SE.