Automate SAP with python!
Project description
Github - https://github.com/kamildemocko/PySapScript
SAP scripting for use in Python.
Can perform different actions in SAP GUI client on Windows.
Documentation
https://kamildemocko.github.io/PySapScript/
pdoc --html --output-dir docs .\src\pysapscript\
Installation
uv sync
uv pip install -e .
Usage
Create pysapscript object
import pysapscript
sapscript = pysapscript.Sapscript()
parameter default_window_title: = "SAP Easy Access"
Launch Sap
sapscript.launch_sap(
sid="SQ4",
client="012",
user="robot_t",
password=os.getenv("secret_password")
)
additional parameters:
root_sap_dir = Path(r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui")
maximise = True
language = "de"
quit_auto = True
Attach to an already opened window:
from pysapscript.window import Window
window: Window = sapscript.attach_window(0, 0)
positional parameters (0, 0) -> (connection, session)
Quitting SAP:
- pysapscript will automatically quit if not manually specified in
launch_sapparameter - manual quitting method:
sapscript.quit()
Performing action:
element: use SAP path starting with wnd[0] for element arguments, for example wnd[0]/usr/txtMAX_SEL
- element paths can be found by recording a sapscript with SAP GUI or by applications like SAP Script Tracker
window = sapscript.attach.window(0, 0)
window.maximize()
window.restore()
window.close()
window.start_transaction(value)
window.navigate(NavigateAction.enter)
window.navigate(NavigateAction.back)
window.write(element, value)
window.press(element)
window.send_v_key(value[, focus_element=True, value=0])
window.select(element)
selected = window.is_selected(element)
window.read(element)
window.set_checkbox(value)
window.visualize(element[, seconds=1])
window.exists(element)
table: ShellTable = window.read_shell_table(element)
html_content = window.read_html_viewer(element)
Table actions
ShellTable uses polars, but can also be return pandas or dictionary
from pysapscript.shell_table import ShellTable
table: ShellTable = window.read_shell_table()
table.rows
table.columns
table.to_dict()
table.to_dicts()
table.to_polars_dataframe()
table.to_pandas_dataframe()
table.cell(row_value, col_value_or_name)
table.get_column_names()
table.load()
table.press_button(value)
table.select_rows([0, 1, 2])
table.change_checkbox(element, value)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysapscript-3.2.2.tar.gz.
File metadata
- Download URL: pysapscript-3.2.2.tar.gz
- Upload date:
- Size: 60.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efcdb07ae0a95b871e182f07f9ce4ac5cf215fe657acdf4976123430932f2fd5
|
|
| MD5 |
ef24533e9c7bc05ba0396e4e4ad84f72
|
|
| BLAKE2b-256 |
e9ceebf1fa280c405cc333083ac4a0e3e71d8cbbf57d3ec096a9b115caf79564
|
File details
Details for the file pysapscript-3.2.2-py3-none-any.whl.
File metadata
- Download URL: pysapscript-3.2.2-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af1394302b0c2ce46aa20c08bae1722517037a3102f8c80c66ff4ec16f0bdbaa
|
|
| MD5 |
941729d3b8494132bd7eef670c7414dd
|
|
| BLAKE2b-256 |
a9f8dd17a1f1ec5a51fa28e83bb91433be37cec5955d71ef26db0637847d09b7
|