SAP / PyRFC

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

How to establish a client connection to application server utilizing sapnwrfc.ini? #24

Closed Tset-Noitamotua closed 8 years ago

Tset-Noitamotua commented 8 years ago

Just can't figure it out from documentation how to do it. The docs say pyrfc by default looks for sapnwrfc.ini in current folder. Let's asume I have this content in my sapnwrfc.ini

DEST=???
R3NAME=DE999
ASHOST=ABC123
SYSNR=01
CLIENT=123
USER=username
PASSWD=password
LANG=DE
TRACE=3

1) What is DEST? 2) How to call Connection()?

> from pyrfc import Connection
> my_sap = Connection()
> Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "pyrfc\_pyrfc.pyx", line 150, in pyrfc._pyrfc.Connection.__init__ (pyrfc\_pyrfc.c:2281)
    File "pyrfc\_pyrfc.pyx", line 188, in pyrfc._pyrfc.Connection._open (pyrfc\_pyrfc.c:2927)
    File "pyrfc\_pyrfc.pyx", line 218, in pyrfc._pyrfc.Connection._error (pyrfc\_pyrfc.c:3153)
    pyrfc._exception.ExternalRuntimeError: RFC_INVALID_PARAMETER (rc=20): key=RFC_INVALID_PARAMETER, message=Invalid parameter 'unsigned paramCount' was passed to the API call [MSG: class=, type=, number=, v1-4:=;;;]
bsrdjan commented 8 years ago

PyRFC is just a wrapper of the standard SAP NetWeaver RFC Library and the detailed documentation of SAP NW RFC Lib is fully applicable and available on SAP Service Marketplace.

Following the link at the bottom of PyRFC README, http://service.sap.com/rfc-library, in the Download and Documentation section you will find the SAP NetWeaver RFC SDK Guide, with detail description of all Connection parameters.

How to use sapnwrfc.ini is described in pyrfc documentation

Hope this helps.

Tset-Noitamotua commented 8 years ago

Thanks for the hint.

As Page 15 of SAP NetWeaver RFC SDK Guide states:

Using the sapnwrfc.ini file

" ... . The destination parameter of this function must point to an entry in the sapnwrfc.ini file."

# Example of a sapnwrfc.ini file
# SAP System using a specific application server
DEST=BIN_HS0011
ASHOST=hs0011
SYSNR=53
RFC_TRACE=0

To answer my own questions:

1) DEST stands for destination and refers to possible DEST= definition(s) in sapnwrfc.ini (e.g. DEST=BIN_HS0011 in example above) 2) To open a connection (again refering above example) call my_sap = Connection(DEST='BIN_HS0011')

NOTE: pass value of DEST as string - thus in quotes.

NOTE: you can define multiple destination ins sapnwrfc.ini e.g.

# destination 1
DEST=SYSTEM_001
ASHOST=hostname_of_sys001
SYSNR=001
USER=user_001
PASSW= ...

# destination 2
DEST=SYSTEM_002
ASHOST=hostname_of_sys002
SYSNR=002
USER=user_002
PASSW= ...

# destination n
...

I hope I have summed up correctly and close this issue.