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.0.tar.gz (13.8 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.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sap_functions-1.0.tar.gz
  • Upload date:
  • Size: 13.8 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.0.tar.gz
Algorithm Hash digest
SHA256 385fa12a66df1b46c38e231a9e40683895fb6a416510d2cb12138dd186082b16
MD5 921ac1c4204456000d621dacccd716de
BLAKE2b-256 1c3e8a2e0ef5e5b9793c72182de256ebbfe3308a114691a0ddbdd186efa3d2f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sap_functions-1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8616098dc2cb4bfc10b7f6dbbfb9574ac4dad21401177940cfdfc2a8ceb2bf03
MD5 45f5efde56e6aa169b7c4852401cedb9
BLAKE2b-256 63186e6b7225619cb1384dab43ea30b1f6a9dc9c8654e723ddd50c601e6e4626

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