Automate SAP Concur Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access SAP Concur data from PowerShell? This article demonstrates how to utilize the SAP Concur Cmdlets for tasks like connecting to SAP Concur data, automating operations, downloading data, and more.

The CData ADO.NET Provider for SAP Concur is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to SAP Concur.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for SAP Concur; this tutorial shows how to use the Provider to create, retrieve, update, and delete SAP Concur data.

Once you have acquired the necessary connection properties, accessing SAP Concur data in PowerShell can be enabled in three steps.

SAP Concur uses the OAuth 2 authentication standard. obtain the OAuthClientId and OAuthClientSecret by registering an app with SAP Concur. See the Getting Started section of the help documentation for an authentication guide.

  1. Load the provider's assembly:

    
    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for SAP Concur\lib\System.Data.CData.SAPConcur.dll")
        
  2. Connect to SAP Concur:

     
    $conn= New-Object System.Data.CData.SAPConcur.SAPConcurConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;InitiateOAuth=GETANDREFRESH;")
    $conn.Open()
    
  3. Instantiate the SAPConcurDataAdapter, execute an SQL query, and output the results:

    
    $sql="SELECT Id, OfficeId from Departments"
    
    $da= New-Object System.Data.CData.SAPConcur.SAPConcurDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
    	Write-Host $_.id $_.officeid
    }
      

Update SAP Concur Data


$cmd =  New-Object System.Data.CData.SAPConcur.SAPConcurCommand("UPDATE Departments SET Id='1668776136772254' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SAPConcur.SAPConcurParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert SAP Concur Data


$cmd =  New-Object System.Data.CData.SAPConcur.SAPConcurCommand("INSERT INTO Departments (Id) VALUES (@myId)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SAPConcur.SAPConcurParameter("@myId","1668776136772254")))
$cmd.ExecuteNonQuery()

Delete SAP Concur Data


$cmd =  New-Object System.Data.CData.SAPConcur.SAPConcurCommand("DELETE FROM Departments WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SAPConcur.SAPConcurParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

Download a free trial of the SAP Concur Data Provider to get started:

 Download Now

Learn more:

SAP Concur Icon SAP Concur ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with SAP Concur data including Attendees, Entries, Lists, Items, and more!