SapRfcError: DATA_BUFFER_EXCEEDED

When using the pysaprfc library you may encounter this error when performing a RFC_READ_TABLE. The reason for this is primarily because the table has too many fields to draw back into the itable python structure of the pysaprfc library. To overcome this you will need to limit the number of fields being returned in the read_table method as shown in this code below. By the way this particular code snippet is also useful for drawing back iDoc status codes for a list of iDoc numbers. Especially useful if you are having trouble getting read only access directly to the database as we were 🙂

import pysap

# Variables
WhereSQL = "DOCNUM IN (2016, 2017, 2018)"
SQLTable = "EDIDS"
Fields = ["DOCNUM","LOGDAT","LOGTIM","CREDAT","CRETIM","STATUS",
"STACOD","STATXT","STAMQU","STAMID"]
MaxRows = "50"
CONN_FILE = "C:/Python26/pysaprfc/examples/sapconn.ini"
CONN_NAME = "SAPSANDBOX"

# Change next line to be able to connect to your SAP system
sap_conn=pysap.Rfc_connection(conn_file=CONN_FILE,conn_name=CONN_NAME)
sap_conn.open()

# Read entries from SQLTable
itab=sap_conn.read_table(SQLTable,options=[WhereSQL],max_rows=MaxRows)
# Print some fields from itab to show it worked
for p in itab:
print '%(DOCNUM)s %(LOGDAT)s %(LOGTIM)s %(CREDAT)s %(CRETIM)s %(STATUS)s %(STACOD)s %(STATXT)s %(STAMQU)s %(STAMID)s ' % p
sap_conn.close()