There are many tools which offer this function for SharePoint. Try using BCS Business Connectivity Service and LINQ to get data from SAP to SharePoint list and then use that data in workflow.
To write your own custom workflow, you can check this link:
Custom Activity Workflow for implementing Item Level Security in SharePoint Designer 2007
To create a Visual Studio 2008 Workflow Activity Library project, you need to follow below steps: