![]() |
VOOZH | about |
The CData Cmdlets for SAP SuccessFactors are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to SAP SuccessFactors.
The Cmdlets are not only a PowerShell interface to SAP SuccessFactors, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete SAP SuccessFactors data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for SAP SuccessFactors. To access SAP SuccessFactors data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for SAP SuccessFactors.
Once you have acquired the necessary connection properties, accessing SAP SuccessFactors data in PowerShell can be enabled in three steps.
You can authenticate to SAP Success Factors using Basic authentication or OAuth with SAML assertion.
You must provide values for the following properties to successfully authenticate to SAP Success Factors. Note that the provider will reuse the session opened by SAP Success Factors using cookies. Which means that your credentials will be used only on the first request to open the session. After that, cookies returned from SAP Success Factors will be used for authentication.
You must provide values for the following properties, which will be used to get the access token.
Install the module:
Install-Module SAPSuccessFactorsCmdlets
Connect:
$sapsuccessfactors = Connect-SAPSuccessFactors -User "$User" -Password "$Password" -CompanyId "$CompanyId" -Url "$Url"
Search for and retrieve data:
$city = "Springfield" $extaddressinfo = Select-SAPSuccessFactors -Connection $sapsuccessfactors -Table "ExtAddressInfo" -Where "city = `'$city`'" $extaddressinfo
You can also use the Invoke-SAPSuccessFactors cmdlet to execute SQL commands:
$extaddressinfo = Invoke-SAPSuccessFactors -Connection $sapsuccessfactors -Query 'SELECT * FROM ExtAddressInfo WHERE city = @city' -Params @{'@city'='Springfield'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for SAP SuccessFactors\lib\System.Data.CData.SAPSuccessFactors.dll")
Connect to SAP SuccessFactors:
$conn= New-Object System.Data.CData.SAPSuccessFactors.SAPSuccessFactorsConnection("User=username;Password=password;CompanyId=CompanyId;Url=https://api4.successfactors.com;")
$conn.Open()
Instantiate the SAPSuccessFactorsDataAdapter, execute an SQL query, and output the results:
$sql="SELECT address1, zipCode from ExtAddressInfo"
$da= New-Object System.Data.CData.SAPSuccessFactors.SAPSuccessFactorsDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.address1 $_.zipcode
}
Update-SAPSuccessFactors -Connection $SAPSuccessFactors -Columns @('address1','zipCode') -Values @('Myaddress1', 'MyzipCode') -Table ExtAddressInfo -Id "MyId"
$cmd = New-Object System.Data.CData.SAPSuccessFactors.SAPSuccessFactorsCommand("UPDATE ExtAddressInfo SET city='Springfield' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SAPSuccessFactors.SAPSuccessFactorsParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-SAPSuccessFactors -Connection $SAPSuccessFactors -Table ExtAddressInfo -Columns @("address1", "zipCode") -Values @("Myaddress1", "MyzipCode")
$cmd = New-Object System.Data.CData.SAPSuccessFactors.SAPSuccessFactorsCommand("INSERT INTO ExtAddressInfo (city) VALUES (@mycity)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SAPSuccessFactors.SAPSuccessFactorsParameter("@mycity","Springfield")))
$cmd.ExecuteNonQuery()
Remove-SAPSuccessFactors -Connection $SAPSuccessFactors -Table "ExtAddressInfo" -Id "MyId"
$cmd = New-Object System.Data.CData.SAPSuccessFactors.SAPSuccessFactorsCommand("DELETE FROM ExtAddressInfo WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SAPSuccessFactors.SAPSuccessFactorsParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the SAP SuccessFactors Data Provider to get started:
Download NowLearn more:
👁 SAP SuccessFactors IconRapidly create and deploy powerful .NET applications that integrate with SAP SuccessFactors.