cancel
Showing results for 
Search instead for 
Did you mean: 

RFC Python Script throws illegal parameter value ( function=SAP_CMTIMEOUT2

Former Member
0 Kudos

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"

  1. get the SAP Data Dictionary structure for TRDIR

str = conn.structure("TRDIR")

  1. various ways for iterating over the results in an

  1. 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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks so much for reply Gregor,

I dont have these libraries:

import pysap

import pyabap

Can you please provide me the URL from i can download these library.

Thanks Again,

Amit

Former Member
0 Kudos

You can take the reference to pyabap out, it's not needed (but included in pysap if you need it in future)

You can download pysap here: [http://pysaprfc.sourceforge.net/]

Answers (1)

Answers (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

Again - these are compiling issues relating to your environment - it's looking for the basetsd.h header file and you need to add this to your include path.

Cheers.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

If possible can any one provide me compiled script so that i can add it to my python library. I am using 2.6 version of Python.

Thanks,

Amit