FUNCTION ZRFCINTERFACETEST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" VALUE(E_RETURN) TYPE STRING
*"----------------------------------------------------------------------
E_RETURN = 'This is a test'.
ENDFUNCTION.
'-Begin-----------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Variables-----------------------------------------------------------
Dim rfcFunc, rfcCon, Func
'-Sub Main------------------------------------------------------------
Sub Main()
Set rfcFunc = CreateObject("SAP.Functions")
'Set rfcFunc = CreateObject("SAP.Functions.Unicode")
If Not IsObject(rfcFunc) Then
Exit Sub
End If
Set rfcCon = rfcFunc.Connection
rfcCon.ApplicationServer = "BCP"
rfcCon.System = "BCP"
rfcCon.SystemNumber = "65"
rfcCon.User = "HUGO"
rfcCon.Client = "099"
rfcCon.Language = "EN"
If Not rfcCon.Logon(0, False) Then
Exit Sub
End If
Set Func = rfcFunc.Add("ZRFCINTERFACETEST")
'-Error here: SAP data type not supported
If Func.Call Then
MsgBox Func.Imports("E_RETURN")
Else
MsgBox Func.Exception
End If
rfcCon.Logoff
Set rfcCon = Nothing
End Sub
'-Main----------------------------------------------------------------
Main
'-End-------------------------------------------------------------------
'-Begin-----------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Constants-----------------------------------------------------------
Const RFC_OK = 0
'-Variables-----------------------------------------------------------
Dim SAP, hRFC, rc, hFuncDesc, hFunc, charBuffer, strLen
'-Main----------------------------------------------------------------
Set SAP = CreateObject("COMNWRFC")
If IsObject(SAP) Then
hRFC = SAP.RfcOpenConnection("ASHOST=ABAP, SYSNR=00, " & _
"CLIENT=001, USER=BCUSER")
If hRFC Then
hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, "ZRFCINTERFACETEST")
If hFuncDesc Then
hFunc = SAP.RfcCreateFunction(hFuncDesc)
If hFunc Then
If SAP.RfcInvoke(hRFC, hFunc) = RFC_OK Then
rc = SAP.RfcGetString(hFunc, "E_RETURN", charBuffer, _
255, strLen)
MsgBox charBuffer
End If
rc = SAP.RfcDestroyFunction(hFunc)
End If
End If
rc = SAP.RfcCloseConnection(hRFC)
End If
Set SAP = Nothing
End If
'-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 |