Skip to content

Instantly share code, notes, and snippets.

@hugo-dc
Created March 13, 2013 03:07
Show Gist options
  • Save hugo-dc/5149085 to your computer and use it in GitHub Desktop.
Save hugo-dc/5149085 to your computer and use it in GitHub Desktop.
Pysap Code Example
# This examples show how to perform remote function calls
import pysap
# Set configuration file (contains server, mandant, user, password, etc)
sap_conn = pysap.Rfc_connection(conn_file='sapconn.ini')
# Open connection
sap_conn.open()
# Get RFC definition
func = sap_conn.get_interface('RFC_GET_TABLE_ENTRIES')
# Print its description
print func.desc
# Fill the needed arguments
func['TABLE_NAME'] = 'KNA1'
func['MAX_ENTRIES'] = 10
# Perform function calls
try:
rc = func('TABLE_NAME', 'MAX_ENTRIES', 'ENTRIES') # Only the arguments specified here will be passed to the RFC,
# for example, if you omit MAX_ENTRIES, the RFC will return ALL the entries
# Also you have to define the returning fields, in this case the table ENTRIES
except pysap.SapRfcError, desc:
print 'Error invoking: %s' % desc
itab = sap_conn.get_table('KNA1')
itab.append_from_table(func['ENTRIES'])
print '_'*79
for row in itab:
print '%(KUNNR)5s %(NAME1)-30s' % row
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment