Asset does not exist

Hi guys,

I would like to read out the activation data of an assest from transaction AS02 in Powershell, but unfortunately the scripts tells me that the asset does not exist, but when I use it in SAP GUI I find the asset.

 

 

 

[Reflection.Assembly]::LoadFile(“C:WindowsMicrosoft.NETassemblyGAC_64sapncov4.0_3.1.0.42__50436dca5c7f7d23sapnco.dll”) > $Null
[Reflection.Assembly]::LoadFile(“C:WindowsMicrosoft.NETassemblyGAC_64sapnco_utilsv4.0_3.1.0.42__50436dca5c7f7d23sapnco_utils.dll”) > $Null

Function Get-Destination {

#-Connect paramters———————————————–

$cfgParams = New-Object SAP.Middleware.Connector.RfcConfigParameters

#—TEST—
$cfgParams.Add(“NAME”, “SAP”)
$cfgParams.Add(“ASHOST”, “xx.xx.xxx.xx”)

$cfgParams.Add(“SYSNR”, “00”)
$cfgParams.Add(“CLIENT”, “100”)

$cfgParams.Add(“USER”, “user”)
$cfgParams.Add(“PASSWD”, “password”)

Return [SAP.Middleware.Connector.RfcDestinationManager]::GetDestination($cfgParams)

}

#-Sub Invoke-SAPFunctionModule—————————————-
$destination = Get-Destination

[SAP.Middleware.Connector.IRfcFunction]$bapiChangeAsset = $destination.Repository.CreateFunction(“BAPI_FIXEDASSET_GETDETAIL”)

$bapiChangeAsset.SetValue(“COMPANYCODE”, “0001”)
$bapiChangeAsset.SetValue(“ASSET”, “31745”)

$bapiChangeAsset.Invoke($destination)

[SAP.Middleware.Connector.IRfcStructure]$return = $bapiChangeAsset.GetStructure(“RETURN”)

Write-Host $return.GetValue(“MESSAGE”)

 

 

Scroll to Top