'-Begin-----------------------------------------------------------------
'-Includes------------------------------------------------------------
#Include Once "windows.bi"
'-Constants-----------------------------------------------------------
Enum
RFC_OK = 0
RFC_RETRY = 14
End Enum
'-Structures----------------------------------------------------------
'-RFC_ERROR_INFO----------------------------------------------------
Type RFC_ERROR_INFO
code As Integer
group As Integer
key As WString * 128
message As WString * 512
abapMsgClass As WString * 21
abapMsgType As WString * 2
abapMsgNumber As WString * 4
abapMsgV1 As WString * 51
abapMsgV2 As WString * 51
abapMsgV3 As WString * 51
abapMsgV4 As WString * 51
End Type
'-RFC_CONNECTION_PARAMETER------------------------------------------
Type RFC_CONNECTION_PARAMETER
name As WString Ptr
value As WString Ptr
End Type
'-Declarations--------------------------------------------------------
Declare Function RfcCloseConnection StdCall Lib "sapnwrfc" _
Alias "RfcCloseConnection" (ByVal rfcHandle As Integer, _
errorInfo As RFC_ERROR_INFO) As Integer
Declare Function RfcCreateFunction StdCall Lib "sapnwrfc" _
Alias "RfcCreateFunction" (ByVal funcDescHandle As Integer, _
errorInfo As RFC_ERROR_INFO) As Integer
Declare Function RfcCreateFunctionDesc StdCall Lib "sapnwrfc" _
Alias "RfcCreateFunctionDesc" (name As WString, _
errorInfo As RFC_ERROR_INFO) As Integer
Declare Function RfcGetChars StdCall Lib "sapnwrfc" _
Alias "RfcGetChars" (ByVal dataHandle As Integer, _
name As WString, ByVal charBuffer As WString Ptr, _
bufferLength As Integer, errorInfo As RFC_ERROR_INFO) As Integer
Declare Function RfcGetStructure StdCall Lib "sapnwrfc" _
Alias "RfcGetStructure" (ByVal dataHandle As Integer, _
name As WString, ByVal strucHandle As Integer, _
errorInfo As RFC_ERROR_INFO) As Integer
Declare Function RfcDestroyFunction StdCall Lib "sapnwrfc" _
Alias "RfcDestroyFunction" (ByVal funcHandle As Integer, _
errorInfo As RFC_ERROR_INFO) As Integer
Declare Function RfcGetFunctionDesc StdCall Lib "sapnwrfc" _
Alias "RfcGetFunctionDesc" (ByVal rfcHandle As Integer, _
funcName As WString, errorInfo As RFC_ERROR_INFO) _
As Integer
Declare Function RfcGetVersion StdCall Lib "sapnwrfc" _
Alias "RfcGetVersion" (ByVal MajorVersion As Long Ptr, _
ByVal MinorVersion As Long Ptr, ByVal PatchLevel As Long Ptr) _
As WString Ptr
Declare Function RfcInstallServerFunction StdCall Lib "sapnwrfc" _
Alias "RfcInstallServerFunction" (sysID As WString, _
ByVal funcDescHandle As Integer, ByVal serverFunction As Integer, _
errorInfo As RFC_ERROR_INFO) As Integer
Declare Function RfcInvoke StdCall Lib "sapnwrfc" _
Alias "RfcInvoke" (ByVal rfcHandle As Integer, _
ByVal funcHandle As Integer, errorInfo As RFC_ERROR_INFO) _
As Integer
Declare Function RfcListenAndDispatch StdCall Lib "sapnwrfc" _
Alias "RfcListenAndDispatch" (ByVal rfcHandle As Integer, _
ByVal timeout As Integer, errorInfo As RFC_ERROR_INFO) _
As Integer
Declare Function RfcOpenConnection StdCall Lib "sapnwrfc" _
Alias "RfcOpenConnection" (ByVal connectionParams As Integer, _
ByVal paramCount As Integer, errorInfo As RFC_ERROR_INFO) _
As Integer
Declare Function RfcPing StdCall Lib "sapnwrfc" _
Alias "RfcPing" (ByVal rfcHandle As Integer, _
errorInfo As RFC_ERROR_INFO) As Integer
Declare Function RfcRegisterServer StdCall Lib "sapnwrfc" _
Alias "RfcRegisterServer" (ByVal connectionParams As Integer, _
ByVal paramCount As Integer, errorInfo As RFC_ERROR_INFO) _
As Integer
'-Macros--------------------------------------------------------------
#Macro RfcErrorHandler()
If RfcErrorInfo.code <> RFC_OK Then
MessageBox(null, RfcErrorInfo.message, "RFC Error Message", _
MB_OK Or MB_ICONERROR)
End If
#EndMacro
'-End-------------------------------------------------------------------
'-Begin-----------------------------------------------------------------
'-Includes------------------------------------------------------------
#Include Once "sapnwrfc.inc"
'-Variables-----------------------------------------------------------
Dim RfcErrorInfo As RFC_ERROR_INFO
Dim connParams(6) AS RFC_CONNECTION_PARAMETER
Dim hRFC As Integer
Dim As WString * 16 nASHost, nSysNr, nClient, nUser, nPassWd, nLang
Dim As WString * 16 vASHost, vSysNr, vClient, vUser, vPassWd, vLang
'-Main----------------------------------------------------------------
nASHost = "ASHOST" : vASHost = "ABAP"
nSysNr = "SYSNR" : vSysNr = "00"
nClient = "CLIENT" : vClient = "001"
nUser = "USER" : vUser = "BCUSER"
nPassWd = "PASSWD" : vPassWd = "minisap"
nLang = "LANG" : vLang = "EN"
connParams(0).name = @nASHost : connParams(0).value = @vASHost
connParams(1).name = @nSysNr : connParams(1).value = @vSysNr
connParams(2).name = @nClient : connParams(2).value = @vClient
connParams(3).name = @nUser : connParams(3).value = @vUser
connParams(4).name = @nPassWd : connParams(4).value = @vPassWd
connParams(5).name = @nLang : connParams(5).value = @vLang
hRFC = RfcOpenConnection(@connParams(0), 6, RfcErrorInfo)
RfcErrorHandler()
If hRFC <> 0 And RfcErrorInfo.code = RFC_OK Then
MessageBox(null, "Check connection with TAC SMGW in the " & _
"SAP system", "", MB_OK Or MB_ICONINFORMATION)
RfcCloseConnection hRFC, RfcErrorInfo
RfcErrorHandler()
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 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |