Skip to Content

These days I got an e-mail about different behaviour after installing the actual SAP GUI for Windows 7.50 with the changed ActiveX controls. This means the old ActiveX controls bases on Classic RFC library and the new ActiveX controls bases on SAP NetWeaver RFC library.

  1. The length of a return value from a table was with the old ActiveX controls corresponding to the content, but with the new ActiveX controls corresponding to the definition.
  2. The setting of a value from a table column doesn’t work anymore with the new version.

For my test scenario I use an enviroment which I described here.

Here my analysis about this behaviour:

Value Length

With the old ActiveX controls delivers the call of RFC_READ_TABLE with the table USR01 exact the length of the table USR01 plus delimiters:

But with the new ActiveX controls delivers the same program the length of the data structure (UC):

If you transfer a great data volum, it could be give some memory problems.

Set Value of a Table Column

With the old ActiveX controls you can set a value of a table column. Here a snippet with AutoIt:

$Row = $ReadTableFunc.Tables("FIELDS").Rows.Add
$Row("FIELDNAME") = "BNAME"
$Row = $ReadTableFunc.Tables("FIELDS").Rows.Add
$Row("FIELDNAME") = "LANGU"

This delivers in the SAP system this:

But with the new ActiveX controls delivers the same program this:

It seems that it is not possible to set the value of a table column at the moment.

 

The Test Program

To test this different behaviour I use an AutoIt script which calls RFC_READ_TABLE with the table USR01. The code is commented and really easy to understand.

;-Begin-----------------------------------------------------------------

  ;-Directives----------------------------------------------------------
  AutoItSetOption("MustDeclareVars", 1)

  ;-Sub Main------------------------------------------------------------
  Func Main()

    ;-Variables---------------------------------------------------------
    Local $SAPFunc = 0, $Connection = 0, $SAPConnection = 0
    Local $ReadTableFunc = 0, $Param = 0, $Table = 0
    Local $RowCount = 0, $DataLine = "", $i = 0

    ;-Get SAP.Functions-------------------------------------------------
    $SAPFunc = ObjCreate("SAP.Functions.Unicode")
    If Not IsObj($SAPFunc) Then
      MsgBox(0, "Hint", "Can't create SAP.Functions.Unicode object")
      Exit
    EndIf

    ;-Get SAP.LogonControl connection-----------------------------------
    $Connection = $SAPFunc.Connection
    If Not IsObj($Connection) Then
      MsgBox(0, "Hint", "Can't get SAP.LogonControl connection")
      Exit
    EndIf

    ;-Set connection parameters-----------------------------------------
    $Connection.Client = "001"
    $Connection.User = "BCUSER"
    $Connection.Password = "minisap"
    $Connection.Language = "EN"
    $Connection.System = "NSP"
    $Connection.HostName = "ABAP"
    $Connection.SystemNumber = 0

    ;-Connect SAP system------------------------------------------------
    $SAPConnection = $Connection.Logon(0, -1)
    If $SAPConnection = 0 Then
      MsgBox(0, "Hint", "Can't logon to the SAP system")
      Exit
    EndIf

    ;-Get ABAP function module RFC_READ_TABLE---------------------------
    $ReadTableFunc = $SAPFunc.Add("RFC_READ_TABLE")
    If Not IsObj($ReadTableFunc) Then
      ;-Logoff----------------------------------------------------------
      $Connection.Logoff()
      MsgBox(0, "Hint", "Can't get the function module")
      Exit
    EndIf

    ;-Define export parameters------------------------------------------
    $ReadTableFunc.Exports("QUERY_TABLE").Value = "USR01"
    $ReadTableFunc.Exports("DELIMITER").Value = "~"

    ;-Call ABAP function module RFC_READ_TABLE to read table USR01------
    $ReadTableFunc.Call()

    ;-Show the content of the table-------------------------------------
    $Table = $ReadTableFunc.Tables("DATA")
    If IsObj($Table) Then
      $RowCount = $Table.RowCount
      For $i = 1 To $RowCount
        $DataLine = $Table.Value($i, "WA")
        MsgBox(0, "Data", "Length: " & StringLen($DataLine) & @CrLf & _
          String($DataLine))
      Next
    EndIf

    ;-Logoff------------------------------------------------------------
    $Connection.Logoff()

  EndFunc

  ;-Main----------------------------------------------------------------
  If @AutoItX64 Then
    MsgBox(0, "Version", "AutoIt " & @AutoItVersion & " x64")
  Else
    MsgBox(0, "Version", "AutoIt " & @AutoItVersion & " x86")
  EndIf

  Main()

;-End-------------------------------------------------------------------

 

I asked about the future of ActiveX controls here. I wrote a recommendation about the ActiveX controls here. And a few tips how to work with it eg. here and here. I was surprised about the further development of the ActiveX controls with the SAP GUI for Windows 7.50, because for a long time it looked as if no changes could be expected.

 

2017/09/26: With the SAP GUI for Windows 7.50 PL 2 from 2017/09/12 the error is fixed. Thanks to Badari, Gaurav and Shruthi for the efforts.

 

Cheers
Stefan

To report this post you need to login first.

9 Comments

You must be Logged on to comment or reply to a post.

  1. Frank Krause

    Hello Stefan,

    thank you for this great post.
    I would like to quickly comment from SAP side:

    • The change you explain above is mentioned in our note “2256415 – Adaptation of RFC controls (Logon, Function, Table and BAPI) to use SAP NetWeaver RFC Library”
    • We do not intend to “revive” these controls, but we are keeping them alive for compatibility
    • The background of the switch to SAP NetWeaver RFC is the fact that the classical RFC library (librfc32.dll) – which had been used by these controls in the past – is no longer supported

    Best regards,
    Frank

    (1) 
    1. Stefan Schnell
      Post author

      Hello Frank,

      thank you very much for your reply.

      Thanks also for the clear words that the controls should not be revived – that is good to know.

      Cheers
      Stefan

      (0) 
  2. Former Member

    Hi Stefan,

    We are from SAP GUI Controls development team and we have developed these new ActiveX controls based on SAP NetWeaver RFC library.

    Thanks a lot for sharing your observations. We have fixed both the issues observed by you.

    We have also released SAP Note 2483700 to address these issues.

    We would like to share test binaries with you so that you can recheck and share your feedback.

    It would be good if you can share you mail id so that we can share test binaries which contains fixes for both the issues.

    Please feel free to share your feedback/observations while using the new ActiveX controls based on SAP NetWeaver RFC library.

    Thanks a lot for your efforts in sharing your feedback.

    Please feel free to reach out to us in case if you need any further clarification about the new NWRFC based ActiveX controls.

    Thanks and Regards,

    Badari Nath, Gaurav and Shruthi.

     

    (1) 
  3. Former Member

    Hi Stefan,

    You are welcome.

    Feel free to get back to us in case if you need any clarification on these new SAPNRFC based activeX controls.

    Thanks and Regards,

    Badari Nat

    (1) 
  4. Former Member

    Hello Everyone,

    I am using VBA code to extract tables data from SAP and I am facing same issues that Stefan described in his blog entry – the RFC call returns incorrect columns lengths and empty data for table cells

    I have patched the SAP Logon with latest patch (3) including hotfix but it did not helped:

     

    the data that I see from SE37 transaction (FM: DB_ORA_TABLESPACE_HISTORY; TAB: HIST1):

    the data that I get in excel VBA:

    8th column even returns sometimes “Automation error” but this does not bother me for now and columns 4-6 are having incorrect length and shows empty data. For example column 6 shows IntLength=8 but the column in SAP is obviously longer:

    I’m not sure if I am missing something obvious or there is some other issue

     

    I would really appreciate any help, advice or hints

     

    PS: I am using same commands to connect to SAP as Stefan stated above in “Test Program” section

     

    thanks again and best retards,

    David Buzinkai

    (0) 
  5. Former Member

    UPDATE:

    I have found that the column length is correct because the actual data type is PACKED for these 3 fields

    But I still dont know why the VBA shows empty string for PACKED variables and incorrect string for INTEGER variables in this specific case

     

    Regards,

    David

    (0) 
  6. Ralf Reckfort

     

    Hi,

    it seems the exception is used differntly in the new ActiveX (SAPGUI 7.50, pl7) – if I call a function in a loop, and react on the sap.functions.exception, the new AxtiveX does not reset the exception text in the next call. Here’s my example:

    For Each…

    ‘ Call SAP FuBa
    If oSapFunction.Call() = False Then ErrorHandler  oSapFunction.Exception: Exit Function
    If Err.Number <> 0 Then ErrorHandler  oSapFunction.Exception: Exit Function

    ‘ check for errors
    If oSapFunction.Exception <> “” Then ErrorHandler oSapFunction.Exception: Exit Function

    Next

    Once an error occurs in the loop, all following oSapFunction.Exception are not empty and leads to errors. Any idea how to reset the oSapFunction.Exception after a call?

    Thanks in advance.

    King regards,

    Ralf

     

     

    (0) 
    1. Stefan Schnell
      Post author

      Hello Ralf,

      I don’t know how the libraries from SAP GUI for Windows < 7.50 works in the case you described, but I can confirm the behaviour. In my opinion you can handle the different behaviour very easily:

      ForEach...
      
        'Call SAP FuBa
        retValue = oSapFunction.Call()
        If retValue = False Or Err.Number <> 0 Then
          ErrorHandler oSapFunction.Exception
          Exit Function
        End If
      
        'check for errors
        If retValue = False Then
          ErrorHandler oSapFunction.Exception
          Exit Function
        End If
       
      Next

      As far as I know is the Exception property only defined as get, so I assume you have no chance to clear that. So you need an auxiliary construct via an additional variable.

      Best regards
      Stefan

       

      (1) 

Leave a Reply