Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →How to pipe SAP Ariba Procurement Data to CSV in PowerShell
Use standard PowerShell cmdlets to access SAP Ariba Procurement tables.
The CData Cmdlets Module for SAP Ariba Procurement is a standard PowerShell module offering straightforward integration with SAP Ariba Procurement. Below, you will find examples of using our SAPAribaProcurement Cmdlets with native PowerShell cmdlets.
Creating a Connection to Your SAP Ariba Procurement Data
In order to connect with SAP Ariba Procurement, set the following:
- ANID: Your Ariba Network ID.
- ANID: Specify which API you would like the provider to retrieve SAP Ariba data from. Select the Buyer or Supplier API based on your business role (possible values are PurchaseOrdersBuyerAPIV1 or PurchaseOrdersSupplierAPIV1).
- Environment: Indicate whether you are connecting to a test or production environment (possible values are TEST or PRODUCTION).
Authenticating with OAuth
After setting connection properties, you need to configure OAuth connectivity to authenticate.
- Set AuthScheme to OAuthClient.
- Register an application with the service to obtain the APIKey, OAuthClientId and OAuthClientSecret.
For more information on creating an OAuth application, refer to the Help documentation.
Automatic OAuth
After setting the following, you are ready to connect:
-
APIKey: The Application key in your app settings.
OAuthClientId: The OAuth Client Id in your app settings.
OAuthClientSecret: The OAuth Secret in your app settings.
When you connect, the provider automatically completes the OAuth process:
- The provider obtains an access token from SAP Ariba and uses it to request data.
- The provider refreshes the access token automatically when it expires.
- The OAuth values are saved in memory relative to the location specified in OAuthSettingsLocation.
$conn = Connect-SAPAribaProcurement -ANID "$ANID" -API "$API" -APIKey "$APIKey" -AuthScheme "$AuthScheme"
Selecting Data
Follow the steps below to retrieve data from the Orders table and pipe the result into to a CSV file:
Select-SAPAribaProcurement -Connection $conn -Table Orders | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myOrdersData.csv -NoTypeInformation
You will notice that we piped the results from Select-SAPAribaProcurement into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.
The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.