![]() |
VOOZH | about |
The CData Cmdlets for SAP Fieldglass 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 Fieldglass.
The Cmdlets are not only a PowerShell interface to SAP Fieldglass, but also an SQL interface; this tutorial shows how to use both to retrieve SAP Fieldglass data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for SAP Fieldglass. To access SAP Fieldglass data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for SAP Fieldglass.
Once you have acquired the necessary connection properties, accessing SAP Fieldglass data in PowerShell can be enabled in three steps.
To authenticate, specify the Username, Password, APIKey, and EnvironmentURL connection properties.
To obtain an APIKey, log in to the SAP API Business Hub and click on Get API Key.
Install the module:
Install-Module SAPFieldglassCmdlets
Connect:
$sapfieldglass = Connect-SAPFieldglass -EnvironmentURL "$EnvironmentURL" -Username "$Username" -Password "$Password" -APIKey "$APIKey" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$company = "CData" $audittrails = Select-SAPFieldglass -Connection $sapfieldglass -Table "AuditTrails" -Where "Company = `'$Company`'" $audittrails
You can also use the Invoke-SAPFieldglass cmdlet to execute SQL commands:
$audittrails = Invoke-SAPFieldglass -Connection $sapfieldglass -Query 'SELECT * FROM AuditTrails WHERE Company = @Company' -Params @{'@Company'='CData'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for SAP Fieldglass\lib\System.Data.CData.SAPFieldglass.dll")
Connect to SAP Fieldglass:
$conn= New-Object System.Data.CData.SAPFieldglass.SAPFieldglassConnection("EnvironmentURL='https://myinstance.com';Username=myuser;Password=mypassword;APIKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the SAPFieldglassDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, Category from AuditTrails"
$da= New-Object System.Data.CData.SAPFieldglass.SAPFieldglassDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.category
}
Download a free trial of the SAP Fieldglass Data Provider to get started:
Download NowLearn more:
👁 SAP Fieldglass IconProvides .NET developers with the power to easily connect their Web, Desktop, and Mobile applications to data to SAP Fieldglass Approvals, Audit Trails, Analytics, and more!