cancel
Showing results for 
Search instead for 
Did you mean: 

Python sapnwrfc FUNCTION CALL ERROR

Former Member
0 Kudos

Hi everyone,

I am trying an external rfc connection with sapnwrfc-0.05 for Python. I have the latest nwrfcsdk from SAP. It took me a while to figure out the new python module methods, but I am now able to connect successfuly.

I have a function module that I need to call and feed external data to it. This function is writing to a Z table of mine. I have done this successfuly with previous versions of python sapnwrfc module.

Here is my test code:


import sapnwrfc
conn = sapnwrfc.base.rfc_connect({'ashost':'HOSTNAME', 'sysnr':'00', 'client':'900', 'user':'RFCUSER', 'passwd':'PASSWORD' })
if conn :
    print "I am connected"
#    VBELN = CHAR
#    LNUMB = NUMC
#    WERKS = CHAR
#    GJAHR = NUMC
#    HEAT =  NUMC
#    ZIERA = CHAR
#    ZLENG = CHAR
#    ZWEIG = CHAR
#    ZINDX = CHAR
#    ZPDA = CHAR
#    ZTIME = CHAR
    data = [VBELN+LNUMB+WERKS+GJAHR+HEAT+ZIERA+ZLENG+ZWEIG+ZINDX+ZPDA+ZTIME]

    iface = conn.discover("MY_Z_FUNCTION_MODULE")   
    f = iface.create_function_call()
# MY_Z_FUNCTION_MODULE has a TABLE structure DATA
    f.DATA(data)
    f.invoke()
    print "Done"
    conn.close()

When I run this code I get the following ERROR:


File "/usr/lib/python2.4/site-packages/sapnwrfc/__init__.py", line 165, in invoke
    return self.handle.invoke()
sapnwrfc.RFCCommunicationError: RFC FUNCTION CALL ERROR: set_table_line invalid Input value type

The same function module was working before, when called with DATA as a single string item in a list.

Any help?

Thank you all.

Menelaos

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

As I discovered, you need to supply the DATA table structure with a dictionary of its field values:


data = [{'VBELN':VBELN,
            'LNUMB':LNUMB,
            'WERKS':WERKS,
            'GJAHR':GJAHR,
            'HEAT':HEAT,
            'ZIERA':ZIERA,
            'ZLENG':ZLENG,
            'ZWEIG':ZWEIG,
            'ZINDX':ZINDX,
            'ZPDA':ZPDA,
            'ZTIME':ZTIME}]

Just make sure that each field has the correct size. The data types in the dictionary should all be strings, but the string contents should match the field types of the DATA table structure....

This is really an improvement over the old method (single string) but some documentation would be helpfull Piers!

Can I help?

Menelaos Maglis

Edited by: Menelaos Maglis on Jul 25, 2008 10:49 AM

A correction on the data field types.

Former Member
0 Kudos

Yes - you are right the documentation is a bit thin inside the module, but the things you are talking about are specific to RFC_READ_TABLE, a specific SAP function module.

Did you look at the examples in http://www.piersharding.com/download/python/sapnwrfc/sapnwrfc-0.05.tar.gz ? These should usually be enough to get started with, but probably don't answer the more complex questions.

there are also the articles https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/u/8630. [original link is broken] [original link is broken]

You are welcome to blog about it too

Cheers,

Piers Harding.