Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →Connect to SAP Ariba Procurement Data from PowerBuilder
This article demonstrates how to access SAP Ariba Procurement data from Appeon PowerBuilder using the CData ADO.NET Provider for SAP Ariba Procurement.
This article demonstrates using the CData ADO.NET Provider for SAP Ariba Procurement in PowerBuilder, showcasing the ease of use and compatibility of these standards-based controls across various platforms and development technologies that support Microsoft .NET, including Appeon PowerBuilder.
This article shows how to create a basic PowerBuilder application that uses the CData ADO.NET Provider for SAP Ariba Procurement to retrieve data.
- In a new WPF Window Application solution, add all the Visual Controls needed for the connection properties. Below is a typical connection string:
ANID=AN02000000280;API=PurchaseOrdersBuyerAPI-V1;APIKey=wWVLn7WTAXrIRMAzZ6VnuEj7Ekot5jnU;AuthScheme=OAuthClient;InitiateOAuth=GETANDREFRESH
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.
- Add the DataGrid control from the .NET controls.
-
Configure the columns of the DataGrid control. Below are several columns from the Account table:
<DataGrid AutoGenerateColumns="False" Margin="13,249,12,14" Name="datagrid1" TabIndex="70" ItemsSource="{Binding}"> <DataGrid.Columns> <DataGridTextColumn x:Name="idColumn" Binding="{Binding Path=Id}" Header="Id" Width="SizeToHeader" /> <DataGridTextColumn x:Name="nameColumn" Binding="{Binding Path=DocumentNumber}" Header="DocumentNumber" Width="SizeToHeader" /> ... </DataGrid.Columns> </DataGrid>
- Add a reference to the CData ADO.NET Provider for SAP Ariba Procurement assembly.
Connect the DataGrid
Once the visual elements have been configured, you can use standard ADO.NET objects like Connection, Command, and DataAdapter to populate a DataTable with the results of an SQL query:
System.Data.CData.SAPAribaProcurement.SAPAribaProcurementConnection conn
conn = create System.Data.CData.SAPAribaProcurement.SAPAribaProcurementConnection(connectionString)
System.Data.CData.SAPAribaProcurement.SAPAribaProcurementCommand comm
comm = create System.Data.CData.SAPAribaProcurement.SAPAribaProcurementCommand(command, conn)
System.Data.DataTable table
table = create System.Data.DataTable
System.Data.CData.SAPAribaProcurement.SAPAribaProcurementDataAdapter dataAdapter
dataAdapter = create System.Data.CData.SAPAribaProcurement.SAPAribaProcurementDataAdapter(comm)
dataAdapter.Fill(table)
datagrid1.ItemsSource=table.DefaultView
The code above can be used to bind data from the specified query to the DataGrid.