
#-Begin-----------------------------------------------------------------
#-Packages--------------------------------------------------------------
from ctypes import *
#-Structures------------------------------------------------------------
class RFC_ERROR_INFO(Structure):
_fields_ = [("code", c_long),
("group", c_long),
("key", c_wchar * 128),
("message", c_wchar * 512),
("abapMsgClass", c_wchar * 21),
("abapMsgType", c_wchar * 2),
("abapMsgNumber", c_wchar * 4),
("abapMsgV1", c_wchar * 51),
("abapMsgV2", c_wchar * 51),
("abapMsgV3", c_wchar * 51),
("abapMsgV4", c_wchar * 51)]
class RFC_CONNECTION_PARAMETER(Structure):
_fields_ = [("name", c_wchar_p),
("value", c_wchar_p)]
#-Main------------------------------------------------------------------
ErrInf = RFC_ERROR_INFO; RfcErrInf = ErrInf()
ConnParams = RFC_CONNECTION_PARAMETER * 5; RfcConnParams = ConnParams()
SAPNWRFC = "sapnwrfc.dll"
SAP = windll.LoadLibrary(SAPNWRFC)
#-Prototypes------------------------------------------------------------
SAP.RfcOpenConnection.argtypes = [POINTER(ConnParams), c_ulong, \
POINTER(ErrInf)]
SAP.RfcOpenConnection.restype = c_void_p
SAP.RfcCloseConnection.argtypes = [c_void_p, POINTER(ErrInf)]
SAP.RfcCloseConnection.restype = c_ulong
#-Connection parameters-------------------------------------------------
RfcConnParams[0].name = "ASHOST"; RfcConnParams[0].value = "ABAP"
RfcConnParams[1].name = "SYSNR" ; RfcConnParams[1].value = "00"
RfcConnParams[2].name = "CLIENT"; RfcConnParams[2].value = "001"
RfcConnParams[3].name = "USER" ; RfcConnParams[3].value = "BCUSER"
RfcConnParams[4].name = "PASSWD"; RfcConnParams[4].value = "minisap"
hRFC = SAP.RfcOpenConnection(RfcConnParams, 5, RfcErrInf)
if hRFC != None:
windll.user32.MessageBoxW(None, "Check connection with TAC SMGW", \
"", 0)
#---------------------------------------------------------------------
#-
#- Check connection with TAC SMGW in the SAP system
#-
#---------------------------------------------------------------------
rc = SAP.RfcCloseConnection(hRFC, RfcErrInf)
else:
print(RfcErrInf.key)
print(RfcErrInf.message)
#-End-------------------------------------------------------------------
# -*- coding: iso-8859-15 -*-
#-Begin-----------------------------------------------------------------
#-Include---------------------------------------------------------------
FileName = "sapnwrfc.py"
exec(compile(open(FileName).read(), FileName, "exec"))
#-Import----------------------------------------------------------------
import sys
import platform
#-Main------------------------------------------------------------------
MajorVersion = c_ulong(0)
MinorVersion = c_ulong(0)
PatchLevel = c_ulong(0)
Version = SAP.RfcGetVersion(MajorVersion, MinorVersion, PatchLevel)
print("MajorVersion: " + str(MajorVersion.value))
print("MinorVersion: " + str(MinorVersion.value))
print("PatchLevel: " + str(PatchLevel.value))
print("Version: " + Version)
del SAP
PyVer = sys.version_info
print("\nPython version: " + str(PyVer.major) + "." + \
str(PyVer.minor) + "." + str(PyVer.micro) + " " + \
str(platform.architecture()[0]))
print("Operating system: " + str(platform.system()) + " " + \
str(platform.release()) + " " + str(platform.machine()))
#-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 |
---|---|
20 | |
8 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |