Skip to content

Commit

Permalink
New version of docs
Browse files Browse the repository at this point in the history
  • Loading branch information
demockokamilvseholding committed Mar 22, 2024
1 parent 5431c21 commit 2f3d661
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 28 deletions.
94 changes: 67 additions & 27 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.10.0" />
<title>pysapscript API documentation</title>
<meta name="description" content="Description" />
<meta name="description" content="[Github - https://github.com/kamildemocko/PySapScript](https://github.com/kamildemocko/PySapScript)" />
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
Expand All @@ -22,63 +22,103 @@
<h1 class="title">Package <code>pysapscript</code></h1>
</header>
<section id="section-intro">
<h1 id="description">Description</h1>
<p>SAP scripting for Python automatization</p>
<h1 id="documentation">Documentation</h1>
<p><a href="https://github.com/kamildemocko/PySapScript">Github - https://github.com/kamildemocko/PySapScript</a></p>
<p>SAP scripting for use in Python.<br>
Can perform different actions in SAP GUI client on Windows.</p>
<h1 id="documentation">Documentation</h1>
<p><a href="https://kamildemocko.github.io/PySapScript/pysapscript.html">https://kamildemocko.github.io/PySapScript/pysapscript.html</a></p>
<h1 id="installation">Installation</h1>
<pre><code class="language-pip">pip install pysapscript
</code></pre>
<h1 id="usage">Usage</h1>
<h2 id="create-pysapscript-object">Create pysapscript object</h2>
<pre><code class="language-python">pss = pysapscript.Sapscript()
<pre><code class="language-python">import pysapscript

sapscript = pysapscript.Sapscript()
</code></pre>
<p>parameter <code>default_window_title: = "SAP Easy Access"</code></p>
<h2 id="launch-sap">Launch Sap</h2>
<pre><code class="language-python">pss.launch_sap(
<pre><code class="language-python">sapscript.launch_sap(
sid=&quot;SQ4&quot;,
client=&quot;012&quot;,
user=&quot;robot_t&quot;,
password=os.getenv(&quot;secret_password&quot;)
)
</code></pre>
<p>additional parameters:</p>
<pre><code class="language-python">root_sap_dir = Path(r&quot;C:\Program Files (x86)\SAP\FrontEnd\SAPgui&quot;)
maximise = True
quit_auto = True
</code></pre>
<h2 id="attach-to-window">Attach to window:</h2>
<pre><code class="language-python">window = pss.attach_window(0, 0)
<p><code>root_sap_dir = Path(r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui")</code><br>
<code>maximise = True</code><br>
<code>quit_auto = True</code></p>
<h2 id="attach-to-an-already-opened-window">Attach to an already opened window:</h2>
<pre><code class="language-python">from pysapscript.window import Window

window: Window = sapscript.attach_window(0, 0)
</code></pre>
<p>positional parameters (0, 0) -&gt; (connection, session)</p>
<h2 id="quitting-sap">Quitting SAP:</h2>
<ul>
<li>will automatically quit if not specified differently</li>
<li>manual quitting: <code>pss.quit()</code></li>
<li>pysapscript will automatically quit if not manually specified in <code>launch_sap</code> parameter</li>
<li>manual quitting method: <code>sapscript.quit()</code></li>
</ul>
<h2 id="performing-action">Performing action:</h2>
<p>use SAP path starting with <code>wnd[0]</code> for element argumetns</p>
<pre><code>window.write(element, value)
<p><strong>element</strong>: use SAP path starting with <code>wnd[0]</code> for element arguments, for example <code>wnd[0]/usr/txtMAX_SEL</code><br>
- element paths can be found by recording a sapscript with SAP GUI or by applications like <a href="https://tracker.stschnell.de/">SAP Script Tracker</a></p>
<pre><code class="language-python">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)
</code></pre>
<p>Another available actions&hellip;</p>
<ul>
<li>close window, open new window, start transaction, navigate, maximize</li>
</ul>
<h2 id="table-actions">Table actions</h2>
<p>ShellTable uses polars, but can also be return pandas or dictionary</p>
<pre><code class="language-python">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)
</code></pre>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;
.. include:: ../README.md
&#34;&#34;&#34;</code></pre>
&#34;&#34;&#34;

from .pysapscript import Sapscript
from .window import Window
from .shell_table import ShellTable
from .types_.types import NavigateAction
from .types_ import exceptions</code></pre>
</details>
</section>
<section>
Expand Down Expand Up @@ -117,15 +157,15 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
<h1>Index</h1>
<div class="toc">
<ul>
<li><a href="#description">Description</a></li>
<li><a href="#documentation">Documentation</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#usage">Usage</a><ul>
<li><a href="#create-pysapscript-object">Create pysapscript object</a></li>
<li><a href="#launch-sap">Launch Sap</a></li>
<li><a href="#attach-to-window">Attach to window:</a></li>
<li><a href="#attach-to-an-already-opened-window">Attach to an already opened window:</a></li>
<li><a href="#quitting-sap">Quitting SAP:</a></li>
<li><a href="#performing-action">Performing action:</a></li>
<li><a href="#table-actions">Table actions</a></li>
</ul>
</li>
</ul>
Expand Down
31 changes: 30 additions & 1 deletion docs/pysapscript.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ <h1 class="title">Module <code>pysapscript.pysapscript</code></h1>

class Sapscript:
def __init__(self, default_window_title: str = &#34;SAP Easy Access&#34;) -&gt; None:
&#34;&#34;&#34;
Args:
default_window_title (str): default SAP window title

Example:
sapscript = Sapscript()
main_window = sapscript.attach_window(0, 0)
main_window.write(&#34;wnd[0]/tbar[0]/okcd&#34;, &#34;ZLOGON&#34;)
main_window.press(&#34;wnd[0]/tbar[0]/btn[0]&#34;)
&#34;&#34;&#34;
self._sap_gui_auto = None
self._application = None
self.default_window_title = default_window_title
Expand Down Expand Up @@ -227,13 +237,32 @@ <h2 class="section-title" id="header-classes">Classes</h2>
<span>(</span><span>default_window_title: str = 'SAP Easy Access')</span>
</code></dt>
<dd>
<div class="desc"></div>
<div class="desc"><h2 id="args">Args</h2>
<dl>
<dt><strong><code>default_window_title</code></strong> :&ensp;<code>str</code></dt>
<dd>default SAP window title</dd>
</dl>
<h2 id="example">Example</h2>
<p>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]")</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class Sapscript:
def __init__(self, default_window_title: str = &#34;SAP Easy Access&#34;) -&gt; None:
&#34;&#34;&#34;
Args:
default_window_title (str): default SAP window title

Example:
sapscript = Sapscript()
main_window = sapscript.attach_window(0, 0)
main_window.write(&#34;wnd[0]/tbar[0]/okcd&#34;, &#34;ZLOGON&#34;)
main_window.press(&#34;wnd[0]/tbar[0]/btn[0]&#34;)
&#34;&#34;&#34;
self._sap_gui_auto = None
self._application = None
self.default_window_title = default_window_title
Expand Down

0 comments on commit 2f3d661

Please sign in to comment.