on 06-23-2009 12:21 PM
Hi,
I am getting following error when i try to connect to SAP machine using Python script:
ERROR illegal parameter value ( function=SAP_CMTIMEOUT2 /
parameter=conversation_ID / value=59726258 )
Script i am using:
import saprfc
conn = saprfc.conn(ashost='localhost', sysnr='00', client='000',
user='developer', passwd='developer', trace=1)
conn.connect()
print "am I connected: ", conn.is_connected()
print "sysinfo is: ", conn.sapinfo()
iface = conn.discover("RFC_READ_TABLE")
iface.query_table.setValue("TRDIR")
iface.ROWCOUNT.setValue(10)
iface.OPTIONS.setValue( ["NAME LIKE 'SAPL%RFC%'"] )
conn.callrfc( iface )
print "NO. PROGS: ", iface.DATA.rowCount(), " \n"
print "PROGS DATA RAW: ", iface.DATA.value, " \n"
get the SAP Data Dictionary structure for TRDIR
str = conn.structure("TRDIR")
various ways for iterating over the results in an
interface table
for x in iface.data.value:
print "Doing: " + str.toHash(x)['NAME']
print "PROGS HASH ROWS: "
for i in iface.DATA.hashRows():
print "next row: ", i
conn.close()
I have given correct SAP server details in my script and i am able to connect using SAP client
Any idea how to solve this issue?
Thanks,
Amit
Hi Amit,
You are passing a value into "OPTIONS" as an import parameter when it is a table in the function module. I think it's trying to interpret this as a table and saying it's an illegal parameter.
Are you on Windows? I don't have a compiled copy of SAPRFC for WIN32 and no C compiler (I can't find a compiled version anywhere!)
I've done a small example of what I think your trying to achieve using the other Python library which doesn't need compilation. You can see I pass the OPTIONS argument in as a list. Each entry in the list represents a line in the table.
Hope that helps.
Gregor
import pysap
import pyabap
import time
import sys
conn='LCHECK=1 ASHOST=127.0.0.1 CLIENT=666 SYSNR=00 USER=FOO PASSWD=BAR'
sap_conn=pysap.Rfc_connection(conn)
try:
sap_conn.open()
except pysap.SapRfcError,desc:
print desc
sys.exit(1)
func=sap_conn.get_interface('RFC_READ_TABLE')
func['QUERY_TABLE'] = 'T100'
func['ROWCOUNT'] = '10'
func['OPTIONS'] = [ 'NAME LIKE \'SAPL\%RFC%\'' ]
try:
rc=func('QUERY_TABLE', 'ROWCOUNT', 'DATA')
except pysap.SapRfcError,desc:
print "Error : %s" % desc
stuff = func['DATA'].to_list( )
print stuff
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
All the existing Python connectors do not use the new NW RFC SDK libraries from SAP except for sapnwrfc for Python. You can get this from http://pypi.python.org/pypi/sapnwrfc/ documentation at http://www.piersharding.com/download/python/sapnwrfc/doc/html/ and download at http://www.piersharding.com/download/python/sapnwrfc/.
Cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
When i try to build it i am getting following error:
C:\Documents and Settings\amgupta\Desktop\sapnwrfc-0.06>python setup.py build_ex
t -IC:\nwrfcsdk\include -LC:\nwrfcsdk\lib
selecting win32 libraries...
running build_ext
In my own BUILD_EXTENSIONS...
building 'nwsaprfcutil' extension
D:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
3 /GS- /DNDEBUG -D_LARGEFILE_SOURCE -DSAPwithUNICODE -D_CONSOLE -DWIN32 -DSAPonN
T -DSAP_PLATFORM_MAKENAME=ntintel -DUNICODE -D_UNICODE -Isrc/rfcsdk/include -IC:
\nwrfcsdk\include -IC:\Python26\include -IC:\Python26\PC /Tcsrc/nwsaprfcutil.c /
Fobuild\temp.win32-2.6\Release\src/nwsaprfcutil.obj -mno-3dnow -fno-strict-alias
ing -pipe -fexceptions -funsigned-char -Wall -Wno-uninitialized -Wno-long-long -
Wcast-align
cl : Command line error D8021 : invalid numeric argument '/Wno-uninitialized'
error: command '"D:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' fa
iled with exit status 2
Any idea how to resolve it?
Thanks,
Amit
Hi -
You need to adjust the compile arguments to work for win32.
In setup.py there is a line like:
compile_args = ['-mno-3dnow', '-fno-strict-aliasing', '-pipe', '-fexceptions', '-funsigned-char', '-Wall', '-Wno-uninitialized', '-Wno-long-long', '-Wcast-align']
Notice that it complained about no-uninitialized - try removing this, and see what happens (you may need to remove others).
Also look at https://service.sap.com/sap/support/notes/1056696 and the notes available in the NW RFC SDK for what compile options you may need for your environment.
Let me know what you come up with, and I can change the distribution.
Cheers.
After removing the compiler options i got following error:
C:\Documents and Settings\amgupta\Desktop\sapnwrfc-0.06>python setup.py build_ex
t -IC:\nwrfcsdk\include -LC:\nwrfcsdk\lib
selecting win32 libraries...
running build_ext
In my own BUILD_EXTENSIONS...
building 'nwsaprfcutil' extension
D:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
3 /GS- /DNDEBUG -D_LARGEFILE_SOURCE -DSAPwithUNICODE -D_CONSOLE -DWIN32 -DSAPonN
T -DSAP_PLATFORM_MAKENAME=ntintel -DUNICODE -D_UNICODE -Isrc/rfcsdk/include -IC:
\nwrfcsdk\include -IC:\Python26\include -IC:\Python26\PC /Tcsrc/nwsaprfcutil.c /
Fobuild\temp.win32-2.6\Release\src/nwsaprfcutil.obj -mno-3dnow -fno-strict-alias
ing -pipe -fexceptions -funsigned-char -Wall
cl : Command line warning D9002 : ignoring unknown option '-mno-3dnow'
cl : Command line warning D9002 : ignoring unknown option '-fno-strict-aliasing'
cl : Command line warning D9002 : ignoring unknown option '-pipe'
cl : Command line warning D9002 : ignoring unknown option '-fexceptions'
cl : Command line warning D9002 : ignoring unknown option '-funsigned-char'
nwsaprfcutil.c
D:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(60) : warning C4820
: '_finddata32i64_t' : '4' bytes padding added after data member 'name'
D:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(64) : warning C4820
: '_finddata64i32_t' : '4' bytes padding added after data member 'attrib'
D:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(73) : warning C4820
: '__finddata64_t' : '4' bytes padding added after data member 'attrib'
D:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(78) : warning C4820
: '__finddata64_t' : '4' bytes padding added after data member 'name'
D:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(126) : warning C482
0: '_wfinddata64i32_t' : '4' bytes padding added after data member 'attrib'
D:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(131) : warning C482
0: '_wfinddata64i32_t' : '4' bytes padding added after data member 'name'
D:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\io.h(135) : warning C482
0: '_wfinddata64_t' : '4' bytes padding added after data member 'attrib'
c:\python26\include\pyconfig.h(233) : fatal error C1083: Cannot open include fil
e: 'basetsd.h': No such file or directory
error: command '"D:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' fa
iled with exit status 2
Now basetsd.h is required but not avilable in the include directory.
Thanks,
Amit
I got the header from and copied into include folder after that when i try to compile i got following error:
es padding added after data member 'name'
C:\nwrfcsdk\include\sapnwrfc.h(267) : warning C4820: '_RFC_PARAMETER_DESC' : '2'
bytes padding added after data member 'name'
C:\nwrfcsdk\include\sapnwrfc.h(276) : warning C4820: '_RFC_PARAMETER_DESC' : '1'
bytes padding added after data member 'optional'
C:\nwrfcsdk\include\sapnwrfc.h(325) : warning C4255: 'RfcInit' : no function pro
totype given: converting '()' to '(void)'
src/nwsaprfcutil.c(23) : fatal error C1083: Cannot open include file: 'windows.h
': No such file or directory
error: command '"D:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' fa
iled with exit status 2
I installed the Windows SDK and Visual studio 2008. also i am setting env variable using a batch file:
SET APPVER=5.01
SET Basemake=c:\Program Files\Microsoft SDK\include\BkOffice.Mak
SET Bkoffice=c:\Program Files\Microsoft SDK
SET CPU=i386
SET DevEnvDir=D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE
SET FrameworkDir=c:\WINDOWS\Microsoft.NET\Framework
SET FrameworkSDKDir=D:\Program Files\Microsoft Visual Studio 9.0\SDK\v2.0
SET FrameworkVersion=v2.0.50727
SET Include=D:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE;D:\Program Files\Microsoft Platform SDK\Include;
SET INETSDK=c:\Program Files\Microsoft SDK
SET Lib=C:\Program Files\Microsoft SDK\include;D:\Program Files\Microsoft Visual Studio 9.0\VC\LIB;D:\Program Files\Microsoft Visual Studio 9.0\SDK\v2.0\lib;c:\Program Files\Microsoft SDK\Lib;
SET LIBPATH=C:\Program Files\Microsoft SDK\include;c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
SET MSSdk=c:\Program Files\Microsoft SDK
SET Mstools=c:\Program Files\Microsoft SDK
SET NODEBUG=1
SET Path=C:\Program Files\Microsoft SDK\include;C:\Python26;D:\Program Files\Microsoft Visual Studio 8\VC;D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;D:\Program Files\Microsoft Visual Studio 9.0\VC\BIN;D:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools;D:\Program Files\Microsoft Visual Studio 9.0\SDK\v3.5\Bin;c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;D:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages;c:\Program Files\Microsoft SDK\Bin;c:\Program Files\Microsoft SDK\Bin\WinNT;c:\perl\bin;%PATH%
SET TARGETOS=WINNT
SET VCINSTALLDIR=D:\Program Files\Microsoft Visual Studio 9.0\VC
SET VS80COMNTOOLS=D:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools
SET VSINSTALLDIR=D:\Program Files\Microsoft Visual Studio 9.0
Any idea what is wrong here?
Thanks,
Amit
Hi,
I am able to resolve the header file issue but got following :
src/nwsaprfcutil.c(2302) : error C2375: 'initnwsaprfcutil' : redefinition; diffe
rent linkage
src/nwsaprfcutil.c(90) : see declaration of 'initnwsaprfcutil'
error: command '"D:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' fa
iled with exit status 2
Any idea how to resolve this?
Thanks,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.