![]() |
VOOZH | about |
The CData Cmdlets for SAP are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to SAP.
CData provides the easiest way to access and integrate live data from SAP. Customers use CData connectivity to:
While most users leverage our tools to replicate SAP data to databases or data warehouses, many also integrate live SAP data with analytics tools such as Tableau, Power BI, and Excel.
The Cmdlets are not only a PowerShell interface to SAP, but also an SQL interface; this tutorial shows how to use both to retrieve SAP data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for SAP ERP. To access SAP data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for SAP ERP.
Once you have acquired the necessary connection properties, accessing SAP data in PowerShell can be enabled in three steps.
You can connect to SAP systems using either librfc32.dll, librfc32u.dll, NetWeaver, or Web Services (SOAP). Set the ConnectionType connection property to CLASSIC (librfc32.dll), CLASSIC_UNICODE (librfc32u.dll), NETWEAVER, or SOAP.
If you are using the SOAP interface, set the Client, RFCUrl, SystemNumber, User, and Password properties, under the Authentication section.
Otherwise, set Host, User, Password, Client, and SystemNumber.
Note: We do not distribute the librfc32.dll or other SAP assemblies. You must find them from your SAP installation and install them on your machine.
For more information, see this guide on obtaining the connection properties needed to connect to any SAP system.
Install the module:
Install-Module SAPERPCmdlets
Connect:
$saperp = Connect-SAPERP -Host "$Host" -User "$User" -Password "$Password" -Client "$Client" -System Number "$System Number" -ConnectionType "$ConnectionType" -Location "$Location"
Search for and retrieve data:
$ernam = "BEHRMANN" $mara = Select-SAPERP -Connection $saperp -Table "MARA" -Where "ERNAM = `'$ERNAM`'" $mara
You can also use the Invoke-SAPERP cmdlet to execute SQL commands:
$mara = Invoke-SAPERP -Connection $saperp -Query 'SELECT * FROM MARA WHERE ERNAM = @ERNAM' -Params @{'@ERNAM'='BEHRMANN'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for SAP ERP\lib\System.Data.CData.SAPERP.dll")
Connect to SAP:
$conn= New-Object System.Data.CData.SAPERP.SAPERPConnection("Host=sap.mydomain.com;User=EXT90033;Password=xxx;Client=800;System Number=09;ConnectionType=Classic;Location=C:/mysapschemafolder;")
$conn.Open()
Instantiate the SAPERPDataAdapter, execute an SQL query, and output the results:
$sql="SELECT MANDT, MBRSH from MARA"
$da= New-Object System.Data.CData.SAPERP.SAPERPDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.mandt $_.mbrsh
}
Download a free trial of the SAP ERP Data Provider to get started:
Download NowLearn more:
👁 SAP ERP IconStraightforward SAP ERP integration. Now accessing SAP RFC's from .NET applications is as easy as querying SQL Server.