如何使用RFC获取PowerShell的SAP表中的行数?

时间:2017-02-07 09:29:38

标签: powershell sap saprfc

我尝试使用powershell在SAP表MARA中达到数字ob行。我调用了EM_GET_NUMBER_OF_ENTRIES函数。我不太了解PowerShell并且在正确传递TABNAME值方面存在问题。我认为该行" $ rfctableOut.SetValue(" TABNAME"," MARA")"是不正确的。

这是我的剧本:

Function Invoke-SAPFunctionModule {
#-Loads NCo libraries-------------------------------------------------
$rc = [Reflection.Assembly]::LoadFile("C:\SAP\64\sapnco.dll")
$rc = [Reflection.Assembly]::LoadFile("C:\SAP\64\sapnco_utils.dll")

#-Sets connection parameters------------------------------------------
$cfgParams = New-Object SAP.Middleware.Connector.RfcConfigParameters

$cfgParams.Add("ASHOST", "SOME IP")
$cfgParams.Add("SYSNR", "20")
$cfgParams.Add("NAME", "SOME SYSTEM")
$cfgParams.Add("USER", "SOME USER")
$cfgParams.Add("PASSWD", "SOME PASS@")
$cfgParams.Add("CLIENT", "400")
$cfgParams.Add("LANG", "PL")
$cfgParams.Add("POOL_SIZE", "5") 


$destination =          [SAP.Middleware.Connector.RfcDestinationManager]::GetDestination($cfgParams)
[SAP.Middleware.Connector.IRfcFunction]$rfcFunction =   $destination.Repository.CreateFunction("EM_GET_NUMBER_OF_ENTRIES")

[SAP.Middleware.Connector.IRfcStructure] $rfctableOut = $rfcFunction.GetTable("IT_TABLES")
$rfctableOut.SetValue("TABNAME","MARA")
Write-Host $rfcFunction.GetValue("TABROWS")

}

#-Main----------------------------------------------------------------
Invoke-SAPFunctionModule
#-End-----------------------------------------------------------------

我有一个错误: enter image description here

24行是:

[SAP.Middleware.Connector.IRfcFunction]$rfcFunction =    
$destination.Repository.CreateFunction("EM_GET_NUMBER_OF_ENTRIES")
  

您无法在空值表达式上调用方法

0 个答案:

没有答案