SAP / PyRFC

Asynchronous, non-blocking SAP NW RFC SDK bindings for Python
http://sap.github.io/PyRFC
Apache License 2.0
501 stars 133 forks source link

Python SAPNWSDK Install on Windows. #73

Closed vinayver198 closed 6 years ago

vinayver198 commented 6 years ago

Hi,

I am getting issue in installing python connector for SAP. I have downloaded the sdk from sap. The path has of lib folder has also been set. but when I am trying to run setup.py available in "python-sapnwrfc", "cannot include error sapnwrfc.h" is coming.

Please Help.

bsrdjan commented 6 years ago

Hi, please check if SAPNWRFC_HOME environment variable is set, pointing to SAP NW RFC SDK root folder (containing the "include" subdirectory with sapnwrfc.h). The build from source steps are documented here: http://sap.github.io/PyRFC/build.html#building-the-code Regards, Srdjan

vinayver198 commented 6 years ago

Hi,

The previous issue resolved. But now some issue related to "LINK : fatal error LNK1181: cannot open input file 'sapnwrfc.lib" is coming. I dont know how to proceed further.

bsrdjan commented 6 years ago

Could you please copy the full console log, showing the installation steps before the error and the full error output?

vinayver198 commented 6 years ago

Hi,

After running "python setup.py build" this is the log I'm getting.

running build running build_py running build_ext skipping 'src/pyrfc_pyrfc.c' Cython extension (up-to-date) building 'pyrfc._pyrfc' extension C:\Users\vinayver\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -D_LARGEFILE_SOURCE -DSAPwithUNICODE -D_CONSOLE -DWIN32 -DSAPonNT -DSAP_PLATFORM_MAKENAME=ntintel -DUNICODE -D_UNICODE -Ic:\users\vinayver\anaconda2\include -IC:\Users\vinayver\anaconda2\envs\PythonVE\py27-sapwnrfc2\PC /Tcsrc/pyrfc_pyrfc.c /Fobuild\temp.win-amd64-2.7\Release\src/pyrfc_pyrfc.obj -IC:\Users\vinayver\Downloads\SDK\nwrfcsdk\lib\include -Ic:\users\vinayver\anaconda2\Lib\inspect.pyc\Include -Ic:\users\vinayver\anaconda2\Lib\inspect.pyc\Include\PC _pyrfc.c src/pyrfc_pyrfc.c(2785) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data src/pyrfc_pyrfc.c(7469) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data src/pyrfc_pyrfc.c(15571) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data src/pyrfc_pyrfc.c(20655) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data src/pyrfc_pyrfc.c(20702) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data src/pyrfc_pyrfc.c(22286) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data c:\users\vinayver\anaconda2\envs\pythonve\py27-sapwnrfc2\pyrfc\src\pyrfc_pyrfc.c(17907) : warning C4700: uninitialized local variable 'pyx_v_rfcAttributes' used c:\users\vinayver\anaconda2\envs\pythonve\py27-sapwnrfc2\pyrfc\src\pyrfc_pyrfc.c(18094) : warning C4700: uninitialized local variable 'pyx_v_rfcAttributes' used C:\Users\vinayver\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\users\vinayver\anaconda2\Libs /LIBPATH:C:\Users\vinayver\anaconda2\envs\PythonVE\py27-sapwnrfc2\libs /LIBPATH:C:\Users\vinayver\anaconda2\envs\PythonVE\py27-sapwnrfc2\PCbuild\amd64 /LIBPATH:C:\Users\vinayver\anaconda2\envs\PythonVE\py27-sapwnrfc2\PC\VS9.0\amd64 sapnwrfc.lib libsapucum.lib /EXPORT:init_pyrfc build\temp.win-amd64-2.7\Release\src/pyrfc_pyrfc.obj /OUT:build\lib.win-amd64-2.7\pyrfc_pyrfc.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\src/pyrfc_pyrfc.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\src/pyrfc_pyrfc.pyd.manifest -LIBPATH:C:\Users\vinayver\Downloads\SDK\nwrfcsdk\lib\lib -LIBPATH:c:\users\vinayver\anaconda2\Lib\inspect.pyc\PCbuild LINK : fatal error LNK1181: cannot open input file 'sapnwrfc.lib' error: command 'C:\Users\vinayver\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe' failed with exit status 1181

vinayver198 commented 6 years ago

Hi @bsrdjan , I have resolved the issue.

Thanks

JasmeetSingh30 commented 5 years ago

Hi @vinayver198 ,

I am also having same issue. LINK : fatal error LNK1181: cannot open input file 'sapnwrfc.lib'

How did you resolve it?

Thanks

vinayver198 commented 5 years ago

Hi @JasmeetSingh30,

I didn't set the path properly. Check the path ..and in case u r not able to set.. open the SDK and specify the path explicitly.. issue will be solved

sesmac commented 5 years ago

Hi, I'm getting same error, even using explicitly the path, here is the error I'm getting:

C:\Users\SESA503699\Documents\sapnwrfc\python-sapnwrfc>python setup.py build_ext -IC:\nwrfcsdk\include -LC:\nwrfcsdk\lib selecting win32 libraries...

running build_ext In my own BUILD_EXTENSIONS...

building 'nwsaprfcutil' extension C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D_LARGEFILE_SOURCE -DSAPwithUNICODE -D_CONSOLE -DWIN32 -DSAPonNT -DSAP_PLATFORM_MAKENAME=ntintel -DUNICODE -D_UNICODE -Isrc/rfcsdk/include -IC:\nwrfcsdk\include -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcsrc/nwsaprfcutil.c /Fobuild\temp.win-amd64-3.7\Release\src/nwsaprfcutil.obj nwsaprfcutil.c src/nwsaprfcutil.c(149): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data src/nwsaprfcutil.c(191): warning C4244: '=': conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data src/nwsaprfcutil.c(198): warning C4244: 'function': conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data src/nwsaprfcutil.c(418): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data src/nwsaprfcutil.c(1512): warning C4244: 'function': conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data src/nwsaprfcutil.c(1663): warning C4244: 'function': conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:src/rfcsdk/lib /LIBPATH:C:\nwrfcsdk\lib /LIBPATH:C:\ProgramData\Anaconda3\libs /LIBPATH:C:\ProgramData\Anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x64" sapnwrfc.lib libsapucum.lib /EXPORT:PyInit_nwsaprfcutil build\temp.win-amd64-3.7\Release\src/nwsaprfcutil.obj /OUT:build\lib.win-amd64-3.7\nwsaprfcutil.cp37-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.7\Release\src\nwsaprfcutil.cp37-win_amd64.lib LINK : fatal error LNK1181: cannot open input file 'sapnwrfc.lib' error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\bin\HostX86\x64\link.exe' failed with exit status 1181

Thanks,

bsrdjan commented 5 years ago

Could you please check if SAP NWRFC SDK correctly installed, following the documentation? The SAPNWRFC_HOME env variable should point to the root SAP NWRFC SDK folder (one below lib) and the lib folder should be on Windows PATH.

You may also run the rfcexec.exe, to verify the installation.

sesmac commented 5 years ago

Thanks @bsrdjan, the issue was related to some missing SDK libraries, now it's running, but still getting the error below.

_pyrfc._exception.ABAPRuntimeError: RFC_ABAP_RUNTIME_FAILURE (rc=3): key=RFC_NO_AUTHORITY, message=No RFC authorization for function module DDIF_FIELDINFOGET. [MSG: class=, type=, number=, v1-4:=;;;]

I'm not sure if it is related to the wrong parameters or not enough permissions, just trying to run a query from SQ00 via the RSAQ_REMOTE_QUERY_CALL.

Thanks,

from pyrfc import Connection, ABAPApplicationError, ABAPRuntimeError, LogonError, CommunicationError
from configparser import ConfigParser
from pprint import PrettyPrinter

def main():
    try:
        config = ConfigParser()
        config.read('pyrfc.cfg')
        params_connection = config._sections['connection']
        conn = Connection(**params_connection)

        while True:
            print (u"----Begin of Batch---")
            result = conn.call('RSAQ_REMOTE_QUERY_CALL', QUERY = 'query', USERGROUP='usergroup', VARIANT = 'variant', SKIP_SELSCREEN='X', EXTERNAL_PRESENTATION='X', DATA_TO_MEMORY='X' )
            print(result['DATA'])

    except CommunicationError:
        print (u"Could not connect to server.")
        raise
    except LogonError:
        print (u"Could not log in. Wrong credentials?")
        raise
    except (ABAPApplicationError, ABAPRuntimeError):
        print (u"An error occurred.")
        raise

if __name__ == '__main__':
    main()`
bsrdjan commented 5 years ago

It is surely a permission missing for ABAP users, to call the DDIF_FIELDINFO_GET via RFC. Best check with sysadmin, if the permission can be granted.