PyRFC and RFC_READ_TABLE #259
-
Hi everyone, I am currently trying to extract the data shown in the system status view. Thank you so much in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
RFC_READ_TABLE returns a dictionary that contains the table schema, table data, and your query options. The table data is returned as long strings for each row of the table though, so you need to do some string parsing to get the value for each field. Here's an example: > import pyrfc
>
> table = "my_table"
> delimiter = "|" # how SAP should separate field values in response data. Be sure this character isn't in the field data!
> with pyrfc.Connection(...) as conn:
> result = conn.call("RFC_READ_TABLE", QUERY_TABLE=table, DELIMITER=delimiter, ...)
> print(result)
{
"DATA": [
{"WA": "long_string_of_row_1_of_data"},
{"WA": "long_string_of_row_2_of_data"},
...
],
"FIELDS": [
{"FIELDNAME": ...},
...
], # the schema of the table
"OPTIONS": ..., # echos that options you used when calling RFC_READ_TABLE
}
> data = [
> line["WA"].strip().split(delimiter)
> for line in result["DATA"]
> ]
> print(data)
[
["row", "1", "data", "split", "by", "field"],
["row", "2", "data", "split", "by", "field"],
...
] |
Beta Was this translation helpful? Give feedback.
RFC_READ_TABLE returns a dictionary that contains the table schema, table data, and your query options. The table data is returned as long strings for each row of the table though, so you need to do some string parsing to get the value for each field. Here's an example: