Automate SAP ByDesign Integration Tasks from PowerShell

Ready to get started?

Download a free trial:

Download Now

Learn more:

SAP ByDesign ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with SAP ByDesign.



Are you looking for a quick and easy way to access SAP ByDesign data from PowerShell? We show how to use the Cmdlets for SAP ByDesign and the CData ADO.NET Provider for SAP ByDesign to connect to SAP ByDesign data and synchronize, automate, download, and more.

The CData Cmdlets for SAP ByDesign 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 ByDesign.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the SAP ByDesign API, but also an SQL interface; this tutorial shows how to use both to retrieve SAP ByDesign data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for SAP ByDesign. To access SAP ByDesign data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for SAP ByDesign.

After obtaining the needed connection properties, accessing SAP ByDesign data in PowerShell consists of three basic steps.

Set the following connection properties to connect to SAP ByDesign.

  • Url: Set this to the Url of your SAP ByDesign site. For example, https://test.sapbydesign.com
  • User: Set this to the username of your account.
  • Password: Set this to the password of your account.
  • CustomService or AnalyticsService: Only one of these must be specified. If you have a custom service you want to retrieve data from, specify CustomService. If you want to retrieve the reports of a analytical service, specify AnalyticsService.
    If neither is specified, 'cc_home_analytics.svc' will used as a default for the AnalyticsService property. If you are not sure what service to specify, you can always query the Services view to list available services.

PowerShell

  1. Install the module:

    Install-Module SAPByDesignCmdlets
  2. Connect:

    $sapbydesign = Connect-SAPByDesign -URL "$URL" -User "$User" -Password "$Password" -CustomService "$CustomService"
  3. Search for and retrieve data:

    $productcategoryid = "1234567" $[inventory balance] = Select-SAPByDesign -Connection $sapbydesign -Table "[Inventory Balance]" -Where "ProductCategoryID = `'$ProductCategoryID`'" $[inventory balance]

    You can also use the Invoke-SAPByDesign cmdlet to execute SQL commands:

    $[inventory balance] = Invoke-SAPByDesign -Connection $sapbydesign -Query 'SELECT * FROM [Inventory Balance] WHERE ProductCategoryID = @ProductCategoryID' -Params @{'@ProductCategoryID'='1234567'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.SAPByDesign.SAPByDesignConnection("URL=https://my999999.sapbydesign.com;User=username;Password=password;CustomService=servicename;") $conn.Open()
  3. Instantiate the SAPByDesignDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT ID, ProductCategoryID from [Inventory Balance]" $da= New-Object System.Data.CData.SAPByDesign.SAPByDesignDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.productcategoryid }