'-Begin-----------------------------------------------------------------

  '-Directives----------------------------------------------------------
    Option Explicit

  '-Constants-----------------------------------------------------------
    Const RFC_OK = 0

  '-Variables-----------------------------------------------------------
    Dim SAP, hRFC, rc, hFuncDesc, hFunc

  '-Main----------------------------------------------------------------
    Set SAP = CreateObject("COMNWRFC")
    If IsObject(SAP) Then
      hRFC = SAP.RfcOpenConnection("ASHOST=ABAP, SYSNR=00, " & _
        "CLIENT=001, USER=BCUSER")
      If hRFC Then

        '-Variant1------------------------------------------------------
          hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, "RFC_PING")
          If hFuncDesc Then
            hFunc = SAP.RfcCreateFunction(hFuncDesc)
            If hFunc Then
              If SAP.RfcInvoke(hRFC, hFunc) = RFC_OK Then
                MsgBox "Ping successful"
              Else
                MsgBox "Ping not successful"
              End If
              rc = SAP.RfcDestroyFunction(hFunc)
            End If
          End If

        '-Variant2------------------------------------------------------
          If SAP.RfcPing(hRFC) = RFC_OK Then
            MsgBox "Ping successful"
          Else
            MsgBox "Ping not successful"
          End If

        rc = SAP.RfcCloseConnection(hRFC)
      End If
      Set SAP = Nothing
    End If

'-End-------------------------------------------------------------------