Skip to main content

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:

  1. Checks for existant SAP GUI instances.
  2. Connects to that instance.
  3. 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

sap_functions-1.1.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sap_functions-1.1-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file sap_functions-1.1.tar.gz.

File metadata

  • Download URL: sap_functions-1.1.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for sap_functions-1.1.tar.gz
Algorithm Hash digest
SHA256 b0097b156d96c62bc545ce7ace03e269e83031281134ed5719b6f83324e3a2a5
MD5 7f3791e3ffd1bed1ddc5cf033fb0455b
BLAKE2b-256 260f30f31dae1a95ea8b102a94ffc4b366f6efe1757c63fb5d27cc55a9d6b317

See more details on using hashes here.

File details

Details for the file sap_functions-1.1-py3-none-any.whl.

File metadata

  • Download URL: sap_functions-1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for sap_functions-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d2b279562762db23607dccf2d550029022043d7bd20033adb2e88f59f9bdbb58
MD5 334c25189c6a5f0f44a99fac1754bc24
BLAKE2b-256 604cd34e9b185d2cea52bb689de3f71674afc4af8544c01eca6549f0e7bdf10c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page