Thursday 2 November 2017

How To Use SAP HANA ABAP Source Search via PowerShell

Here a tiny example how to use SAP HANA ABAP Source Search via PowerShell. After my question here, in the ABAP in Eclipse forum, I see how easy it is to use the ABAP Source Search from outside an SAP system. After the activation of the business function SRIS_SOURCE_SEARCH is it also possible with only one http get request to use it.

#-Begin-----------------------------------------------------------------

  $User = "BCUSER"
  $Password = Read-Host -Prompt "Passwort" -AsSecureString
  $Cred = New-Object System.Management.Automation.PSCredential($User, $Password)

  $System = "http://nsp.mysystem.de:8650/"
  $TextSearch = "sap/bc/adt/repository/informationsystem/textsearch"
  $SearchString = "?searchString=Record"
  $Params = "&searchFromIndex=1&searchToIndex=10"

  $RequestURI = $System + $TextSearch + $SearchString + $Params
  [XML]$SearchResult = Invoke-RestMethod -Uri $RequestURI -Credential $Cred -Method Get

  $Cnt = $SearchResult.textSearchResult.textSearchObjects.textSearchObject.Count
  For ($i = 0; $i -lt $Cnt; $i++ ) {
    $Obj = $SearchResult.textSearchResult.textSearchObjects.textSearchObject[$i]
    Write-Host $Obj.adtMainObject.description " - " $Obj.adtMainObject.name
  }

#-End-------------------------------------------------------------------

In my example I search the word Record with a maximum of 10 hits.

How To Use SAP HANA ABAP Source Search via PowerShell

1 comment:

  1. Really I like your post.It was Nice post and very useful information
    SAP HANA Online Access

    ReplyDelete