1

I try to return "bills" from SAP with Powershell. The connection is working, my function is callable, but the Invoke method does not:

Ausnahme beim Aufrufen von "Invoke" mit 1 Argument(en):  "Callbacks from ABAP are not supported"
In C:\Users\test\Desktop\script.ps1:75 Zeichen:10
+          $myFun.Invoke($destination)
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : RfcAbapRuntimeException

Upon investigation they say that SAP .NET connector doesn't support the "invoke" call.

Is there an other function that do the similar? I found a post that is almost 5 years ago in c#, and i cant reproduce that.

my powershell script:

    #load .net sap connector
Function Load-NCo {
    $CurrentDir = Get-Location
    [System.IO.Directory]::SetCurrentDirectory($CurrentDir.Path)
    $rc = [Reflection.Assembly]::LoadFile("C:\Program Files\SAP\SAP_DotNetConnector3_Net40_x64\" + "sapnco.dll")
    $rc = [Reflection.Assembly]::LoadFile("C:\Program Files\SAP\SAP_DotNetConnector3_Net40_x64\" + "sapnco_utils.dll")
}


Function Get-Destination2  {
    #-Verbindungsparamter---------------------------------------------
    $cfgParams = New-Object SAP.Middleware.Connector.RfcConfigParameters

    $cfgParams.Add("NAME", "SAPconnect")
    $cfgParams.Add("ASHOST", "xxx.xx.xxx.xx")
    $cfgParams.Add("SYSNR", "25")
    $cfgParams.Add("CLIENT", "111")
    $cfgParams.Add("USER", "test")
    $cfgParams.Add("SYSID ","T30")
    $cfgParams.Add("LANG","DE")
    $cfgParams.Add("PASSWD", "test")

    $destination = [SAP.Middleware.Connector.RfcDestinationManager]::GetDestination($cfgParams) 
    $rfcRepository = [SAP.Middleware.Connector.RfcDestination]
    $rfcRepository = $destination.Repository

    $myFun =  [SAP.Middleware.Connector.IRfcFunction]
    $myFun = $rfcRepository.CreateFunction("Z_GET_ARCHIVE_FILE")
    $myFun.setValue("SAP_OBJECT" , "test2020")
    $myFun.setValue("OBJECT_ID" , "64562254")
    $myFun.setValue("ARCHIV_TAB" , "TOAST02")
    $myFun.setValue("ARCHIV_ID" , "I8")
    $myFun.setValue("AR_OBJECT" , "ZIMT05")
    $myFun.Invoke($destination) // error 

    $table = $myFun.GetTable("T_URLS") 
}
Suncatcher
  • 10,355
  • 10
  • 52
  • 90
du7ri
  • 67
  • 1
  • 10

1 Answers1

0

The problem you encounter is the similar to what is described in this question:

Exception: RFC callback server not available while calling RFC

I don't see the callback parameter in your module interface (callbacks are not supported in NCo), but I see this is your custom-developed module written from scratch, and it supposedly downloads an archive file from the SAP backend.

My assumption is you coded this RFC function using module like GUI_DOWNLOAD or method cl_gui_frontend_services=>gui_download or something similar which works fine in GUI mode when it has access to frontend filesystem, but fails in RFC (NCo) mode.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90