A utility package for sap automations
Project description
sap_functions
Library with utility classes and functions to facilitate the development of SAP automations in python.
This module is built on top of SAP Scripting and aims to making the development of automated workflows easier and quicker.
Implementation example
from sap_functions import SAP
sap = SAP()
sap.select_transaction("COOIS")
This scripts:
- Checks for existant SAP GUI instances.
- Connects to that instance.
- Write "COOIS" in the transaction field.
Classes overview
SAP
Handle general functions for SAP interactions.
Attributes:
shell_obj: Object with SAP native functions.
session: the SAP user session.
window: the SAP user session specific window.
side_index: Saves temporary data of private functions.
desired_operator: Saves temporary data of private functions.
desired_text: Saves temporary data of private functions.
field_name: Saves temporary data of private functions.
target_index: Saves temporary data of private functions.
Methods:
__get_sap_connection(connection_str: str) -> win32com.client.CDispatch: Get sap session or throw error.
__count_and_create_sap_screens(connection: win32com.client.CDispatch, window: int) -> None: Create SAP windows until its the number passed.
__active_window() -> int: Get active window number.
__scroll_through_tabs(area: win32com.client.CDispatch, extension: str, selected_tab: int) -> win32com.client.CDispatch: Recursively searches for items in an area.
__scroll_through_shell(shell: win32com.client.CDispatch, extension: str) -> win32com.client.CDispatch: Recursively searches for items in an shell based on extension.
__scroll_through_table(table: win32com.client.CDispatch, extension: str) -> win32com.client.CDispatch: Recursively searches for items in an table based on extension.
__scroll_through_fields(area: win32com.client.CDispatch) -> win32com.client.CDispatch: Recursively searched for items in a field area.
__scroll_through_fields(area: win32com.client.CDispatch) -> None: Conditionals for different function calling.
select_transaction(transaction_code: str) -> None: Select a transaction.
select_main_screen() -> None: Get to main screen.
clean_all_fields() -> None: Clean all fields in current screen.
run_actual_transaction() -> None: Run actual transaction.
insert_variant(variant_name: str) -> None: Insert variant in transaction.
change_active_tab(tab_index: int) -> None: Change tab if there are more than one (popups).
write_text_field(field_id: str, text: str) -> None: Write text to a specific field.
write_text_field_until(field_id: str, text: str, until: str) -> None: Write text to a specific field "until" section.
choose_text_combo(field_id: str, option: str) -> None: Interacts with choose text combo of a given field.
flag_field(field_id: str, flag: bool) -> None: Flag checkbox fields.
flag_field_at_side(field_id: str, flag: bool) -> None: Flag checkbox fields on the side.
option_field(field_id: str, option_index: int) -> None: Chooses a radio button within a field.
press_button(button_id: str) -> None: Interacts with a button by pressing it.
multiple_selection_field(field_id: str, values: list[str]) -> None: Interacts with multiple selection of a given field.
find_text_field(field_id: str) -> str | None: Get the value of a field or None if not found.
get_text_at_side(field_id: str) -> str | None: Get the value at the side of a field.
multiple_selection_paste_data(field_id: str, data: str) -> None: Paste a string into the multiple selection field.
navigate_into_menu_header(menu_path: list[str]) -> None: Choose a path to go in the menu_header.
save_file(file_path: str, file_format: str) -> None: Save a file in specific format and path.
get_table(table_id: str) -> win32com.client.CDispatch: Get Table instance.
get_shell(shell_id: str) -> win32com.client.CDispatch: Get Shell instance.
get_footer_message() -> str | None: Get footer message.
Shell
Represents a SAP shell
Attributes:
shell_obj: Object with SAP native functions.
session: the SAP user session.
Methods:
select_layout(layout: str) -> None: Select layout within a shell.
count_rows() -> int: Get number of rows.
get_cell_value(index: int, column_id: str) -> str: Get value of given cell.
get_shell_content() -> list[list[str]]: Get the shell content in an object.
select_all_content() -> None: Select all the shell content.
click_cell(index: int, column_id: str) -> None: Click on specific cell.
press_button(field_name: str, skip_error: bool = False) -> None: Press button in shell toolbar.
press_nested_button(*nested_fields: str, skip_error: bool = False) -> None: Press nested button in shell toolbar.
select_column(column_id: int) -> None: Select a column in the shell.
Table
Represents a SAP table
Attributes:
table_obj: Object with SAP native functions.
Methods:
get_cell_value(row: int, column: str) -> str: Get value of given cell.
Contributing
The sap_functions module is open for contributing, feel free to create an issue or submit your pr.
Maintainers
Gabriel Volles Marinho - gabrielvmarinho1711@gmail.com
Robert Aron Zimmermann - robert.raz@gmail.com
Project details
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 sap_functions-0.1.1.tar.gz.
File metadata
- Download URL: sap_functions-0.1.1.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0rc3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a66ecd1669c558a6443c9025dc2d20b1fb3c9ea630fd1928c423ea8bd6d0317
|
|
| MD5 |
d49fe3d35a838301ae5293c8d7f8558a
|
|
| BLAKE2b-256 |
c053a985970a33bb059dddd7dde571ce7451b8ba816afc1da4e9638c1c69671f
|
File details
Details for the file sap_functions-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sap_functions-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0rc3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64d13a9bbdc30be37b9c7eb15c160fa5583c7cce70d354dfd2f52269c12a6ede
|
|
| MD5 |
76ce449f5256ba8b35f3ad16e0889890
|
|
| BLAKE2b-256 |
576ddbb3be649657b203518f3c405cdac527add2cd595905624211fadfee90de
|