Tuesday, April 06, 2004

Python and SAP (take II)

The pysaprfc module by Klavdij Voncina is quite a clever way to connect python and SAP systems. The module is pure python using ctypes. No need to build and link librfc!

A quick example from the prompt:


>>> import pysap
>>> sap_conn=pysap.Rfc_connection(conn_file='c:/tmp/sapconn.ini')
>>> sap_conn.open()
>>> f=sap_conn.get_interface('RFC_GET_TABLE_ENTRIES')
>>> f['TABLE_NAME']='T005T'
>>> itab.append_from_table(f['ENTRIES'])
>>> f['MAX_ENTRIES']=20
>>> rc=f('TABLE_NAME','MAX_ENTRIES','ENTRIES')
>>> itab=sap_conn.get_table('T005T')
>>> itab.append_from_table(f['ENTRIES'])
>>> for row in itab: print '%(landx)s' % row
...
Andorra
Ver.Arab.Emir.
Afghanistan
Antigua/Barbuda
Anguilla
Albanien
Armenien

Labels: ,

0 Comments:

Post a Comment

<< Home