by Anonymous » 10 Feb 2025, 17:57
Hier ist mein Python -Skript, das versucht, Daten aus einer SAP -Tabelle in AWS -Kleber zu ziehen. < /p>
Code: Select all
from pyrfc import Connection
import pandas as pd
## Variables
sap_table = 'TABLENAME' # SAP Table Name
fields = ["FIELD1", "FIELD2"] # List of fields
options = [""] # the WHERE clause of the query is called "options"
max_rows = 10 # MaxRows
from_row = 0 # Row of data origination
try:
# Establish SAP RFC connection
conn = Connection(ashost='mysapserver.com', sysnr='00', client='000', user='username', passwd='password')
print(f"SAP Connection successful – connection object: {conn}")
if conn:
# Read SAP Table information
tables = conn.call("RFC_READ_TABLE", QUERY_TABLE=sap_table, DELIMITER='|', FIELDS=fields, OPTIONS=options, ROWCOUNT=max_rows, ROWSKIPS=from_row)
# Access specific row & column information from the SAP Data
data = tables["DATA"] # pull the data part of the result set
columns = tables["FIELDS"] # pull the field name part of the result set
df = pd.DataFrame(data, columns = columns)
if df:
print(f"Successfully extracted data from SAP using custom RFC - Printing the top 5 rows: {df.head(5)}")
else:
print("No data returned from the request. Please check database/schema details")
else:
print("Unable to connect with SAP. Please check connection details")
except Exception as e:
print(f"An exception occurred while connecting with SAP system: {e.args}")
Dies führt zum folgenden Fehler:
Eine Ausnahme trat bei der Verbindung mit dem SAP -System auf: ("Nicht weicher Typ: 'dict'",) < Br /> Es verbindet sich erfolgreich, sodass ich denke, dass es die Syntax um die Tabelle ist, Feldnamen. < /p>
Hier ist mein Python -Skript, das versucht, Daten aus einer SAP -Tabelle in AWS -Kleber zu ziehen. < /p>
[code]from pyrfc import Connection
import pandas as pd
## Variables
sap_table = 'TABLENAME' # SAP Table Name
fields = ["FIELD1", "FIELD2"] # List of fields
options = [""] # the WHERE clause of the query is called "options"
max_rows = 10 # MaxRows
from_row = 0 # Row of data origination
try:
# Establish SAP RFC connection
conn = Connection(ashost='mysapserver.com', sysnr='00', client='000', user='username', passwd='password')
print(f"SAP Connection successful – connection object: {conn}")
if conn:
# Read SAP Table information
tables = conn.call("RFC_READ_TABLE", QUERY_TABLE=sap_table, DELIMITER='|', FIELDS=fields, OPTIONS=options, ROWCOUNT=max_rows, ROWSKIPS=from_row)
# Access specific row & column information from the SAP Data
data = tables["DATA"] # pull the data part of the result set
columns = tables["FIELDS"] # pull the field name part of the result set
df = pd.DataFrame(data, columns = columns)
if df:
print(f"Successfully extracted data from SAP using custom RFC - Printing the top 5 rows: {df.head(5)}")
else:
print("No data returned from the request. Please check database/schema details")
else:
print("Unable to connect with SAP. Please check connection details")
except Exception as e:
print(f"An exception occurred while connecting with SAP system: {e.args}")
[/code]
Dies führt zum folgenden Fehler: [b] Eine Ausnahme trat bei der Verbindung mit dem SAP -System auf: ("Nicht weicher Typ: 'dict'",) [/b] < Br /> Es verbindet sich erfolgreich, sodass ich denke, dass es die Syntax um die Tabelle ist, Feldnamen. < /p>