Reputation: 3050
I know that the newest library to connect python and SAP is 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 instead, so I downloaded the source and compile it with MinGW, it installed pretty well and I can now establish 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 disappears 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 debugging I think that the fd
variable is not initialized correctly, because when I try to see fd
attributes, python stops and error is shown:
TypeError: 'NoneType' object is not callable
Upvotes: 2
Views: 1015
Reputation: 1
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 ...
Upvotes: 0
Reputation: 69
Try to remove the line:
f.OPTIONS=[{'BUKRS': "TVN"}]
these parameter is line a line to append on SELECT execution. so it's like:
f.OPTIONS=[{ "BUKRS = 'TVN'" }]
Att.
Upvotes: -1