SAP - Python sapnwrfc and pyrfc fail
Question: I know that the newest library to connect python and SAP is
[PyRFC](http://sap.github.io/PyRFC/), I am using Windows to develop a django
app and when I try to install the `pyrfc-1.9.3-py2.7-win32.egg` that is what
corresponds to my system, It gives me error while importing the library, the
error is shown because the modules that pyrfc imports are missing, I followed
the whole README doc but I have no idea how to use this library.

I decided to use [sapnwrfc](https://pypi.python.org/pypi/sapnwrfc/) instead,
so I downloaded the source and compile it with MinGW, it installed pretty well
and I can now stablish a connection with SAP, but there are errors calling an
RFC function.

This is my code

    
    
    def results(request):
    
        sapnwrfc.base.config_location = BASE_DIR+'\\sap.yml'
        sapnwrfc.base.load_config()
    
        try:
            conn = sapnwrfc.base.rfc_connect()
            fd = conn.discover("ZRFC_TEST_TODO")
            f = fd.create_function_call()
            f.QUERY_TABLE("IT_SUCS") # ERROR IN THIS LINE
            f.ROWCOUNT(50)
            f.OPTIONS=([{'BUKRS': "TVN"}])
            f.invoke()
    
            d = f.DATA
            todo = {'results': d}
    
            conn.close()
    
        except sapnwrfc.RFCCommunicationError as e:
            todo = {'error':e}
        return render_to_response(json.dumps(todo), content_type='application/json')
    

The error is `'NoneType' object is not callable` and if I change it to:

    
    
    f.QUERY_TABLE="IT_SUCS"
    f.ROWCOUNT=50
    f.OPTIONS=[{'BUKRS': "TVN"}]
    f.invoke()
    

Then the error desapears BUT `f` is always null.

I need to get some tables from an RFC from SAP, any idea to solve this? Is
there another way to do it? maybe another library?

**UPDATE** After testing and debbuging I think that the `fd` variable is not
been initialized correctly, because when I try to see `fd's` attributes,
python stops and and error is shown (`TypeError: 'NoneType' object is not
callable`). This is just a theory, I am not sure about it.


Answer: A bit late...

    
    
    def get_table():
        QUERY_TABLE = 'MY_TABLE'
        Fields = ['MY_FIELD']
        FIELDS=[{'FIELDNAME':x} for x in Fields]
        get_data = conn.call("RFC_READ_TABLE", DELIMITER='|', FIELDS=FIELDS, QUERY_TABLE=QUERY_TABLE, )
        get_data = get_data['something in get_data']
        # here format your data, for x in ...
    

