From 2f3d6617bc02af6cb66cbb5c3a1b005e7ff2d341 Mon Sep 17 00:00:00 2001 From: Kamil Democko Date: Fri, 22 Mar 2024 14:14:45 +0100 Subject: [PATCH] New version of docs --- docs/index.html | 94 ++++++++++++++++++++++++++++++------------- docs/pysapscript.html | 31 +++++++++++++- 2 files changed, 97 insertions(+), 28 deletions(-) diff --git a/docs/index.html b/docs/index.html index badfc00..25f6533 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ pysapscript API documentation - + @@ -22,20 +22,23 @@

Package pysapscript

-

Description

-

SAP scripting for Python automatization

-

Documentation

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/pysapscript.html

Installation

pip install pysapscript
 

Usage

Create pysapscript object

-
pss = pysapscript.Sapscript()
+
import pysapscript
+
+sapscript = pysapscript.Sapscript()
 

parameter default_window_title: = "SAP Easy Access"

Launch Sap

-
pss.launch_sap(
+
sapscript.launch_sap(
     sid="SQ4",
     client="012",
     user="robot_t",
@@ -43,42 +46,79 @@ 

Launch Sap

)

additional parameters:

-
root_sap_dir = Path(r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui")
-maximise = True
-quit_auto = True
-
-

Attach to window:

-
window = pss.attach_window(0, 0)
+

root_sap_dir = Path(r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui")
+maximise = True
+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:

    -
  • will automatically quit if not specified differently
  • -
  • manual quitting: pss.quit()
  • +
  • pysapscript will automatically quit if not manually specified in launch_sap parameter
  • +
  • manual quitting method: sapscript.quit()

Performing action:

-

use SAP path starting with wnd[0] for element argumetns

-
window.write(element, value)
+

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)
 window.read(element)
-window.read_shell_table(element)
-window.press_shell_button(element, button_name)
-window.change_shell_checkbox(element, checkbox_name, boolean)
-window.select_shell_rows(element, [0, 1, 2])
+window.set_checkbox(value)
+window.visualize(element[, seconds=1])
+
+table: ShellTable = window.read_shell_table(element)
 html_content = window.read_html_viewer(element)
 
-

Another available actions…

-
    -
  • close window, open new window, start transaction, navigate, maximize
  • -
+

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)
+
Expand source code
"""
 .. include:: ../README.md
-"""
+""" + +from .pysapscript import Sapscript +from .window import Window +from .shell_table import ShellTable +from .types_.types import NavigateAction +from .types_ import exceptions
@@ -117,15 +157,15 @@

Sub-modules

Index

diff --git a/docs/pysapscript.html b/docs/pysapscript.html index 13bac71..f10b881 100644 --- a/docs/pysapscript.html +++ b/docs/pysapscript.html @@ -40,6 +40,16 @@

Module pysapscript.pysapscript

class Sapscript: def __init__(self, default_window_title: str = "SAP Easy Access") -> None: + """ + Args: + default_window_title (str): default SAP window title + + Example: + sapscript = Sapscript() + main_window = sapscript.attach_window(0, 0) + main_window.write("wnd[0]/tbar[0]/okcd", "ZLOGON") + main_window.press("wnd[0]/tbar[0]/btn[0]") + """ self._sap_gui_auto = None self._application = None self.default_window_title = default_window_title @@ -227,13 +237,32 @@

Classes

(default_window_title: str = 'SAP Easy Access')
-
+

Args

+
+
default_window_title : str
+
default SAP window title
+
+

Example

+

sapscript = Sapscript() +main_window = sapscript.attach_window(0, 0) +main_window.write("wnd[0]/tbar[0]/okcd", "ZLOGON") +main_window.press("wnd[0]/tbar[0]/btn[0]")

Expand source code
class Sapscript:
     def __init__(self, default_window_title: str = "SAP Easy Access") -> None:
+        """
+        Args:
+            default_window_title (str): default SAP window title
+
+        Example:
+            sapscript = Sapscript()
+            main_window = sapscript.attach_window(0, 0)
+            main_window.write("wnd[0]/tbar[0]/okcd", "ZLOGON")
+            main_window.press("wnd[0]/tbar[0]/btn[0]")
+        """
         self._sap_gui_auto = None
         self._application = None
         self.default_window_title = default_window_title