Automate SAP data extraction, SharePoint upload, and Excel macro execution
Project description
SAP Automation
What is this?
We regularly need to pull data from SAP, format it as Excel, and upload it to SharePoint. Doing this manually is slow and repetitive. These scripts automate the entire process so you can run a single Python file and have the data extracted, saved, and uploaded automatically.
Who is this for?
Anyone who needs to extract SAP reports on a recurring basis. You do not need to be a programmer. The templates are designed so you only need to:
- Record your SAP steps (SAP has a built-in script recorder)
- Paste the recording into the template
- Fill in a few settings (transaction code, file paths)
- Run the script
How it works
The scripts follow this workflow:
- Open SAP and connect to PR1
- Run your recorded SAP transaction (fill in fields, execute report, click export)
- Save the exported file locally
- Read the file into memory
- Copy a checked-in Excel template from SharePoint, write the data into it, and save it back to SharePoint
- Clean up temporary files
The "checked-in file" is an .xlsx template that lives in a SharePoint folder. You specify the path to this template in your script. The scripts copy it, fill it with your data, and save the result as a new file in your destination folder. This ensures every upload has consistent formatting.
Folder Structure
SAP_Automation/
├── functions/ Core modules that do the actual work (you don't edit these)
├── templates/ Starter scripts you copy and customize for each SAP transaction
└── tools/ Utilities like the transaction checker
Templates
SAP Pipeline (template_sap_pipeline.py)
The main template. Handles the full workflow: connect to SAP, run your transaction, export data, upload to SharePoint.
df = run_extract(sap_script,
transaction="ZSUPVENG",
export_format="xlsx",
template_folder=r"Z:\path\to\template_folder",
sharepoint_folder=r"Z:\path\to\your_sharepoint_folder",
)
How to use:
- Copy this template and rename it (e.g.
ZSUPVENG.py) - Paste your SAP recording into the
sap_script()function - Set
transactionto your transaction code - Set
template_folderto the SharePoint folder containing your checked-in.xlsxtemplate - Set
sharepoint_folderto where you want the output file saved - Run the script
SharePoint Upload (template_sharepoint_upload.py)
Uploads any data to SharePoint as a formatted Excel file. No SAP needed. Useful when you already have data in a file or DataFrame and just want to push it to SharePoint.
result = save_excel_to_sharepoint(df,
template_folder=r"Z:\path\to\template_folder",
sharepoint_folder=r"Z:\path\to\your_sharepoint_folder",
output_filename_prefix="MyReport_2026-01-01",
)
Excel Macros (template_excel_macro.py)
Opens an Excel workbook and runs VBA macros by name.
run_excel_macro(
file_path=r"Z:\path\to\your_workbook.xlsm",
macro_name="MyMacro",
module_name="Module1"
)
Core Modules (functions/)
These are the building blocks. You don't need to edit these files.
| File | What it does |
|---|---|
sap_extract.py |
The main engine. Connects to SAP, runs your recording, handles the save dialog, reads the file, uploads to SharePoint |
sap_connection.py |
Opens SAP GUI, connects to PR1, handles popups like "Multiple Logon" |
sharepoint_upload.py |
Copies the checked-in template, writes your data into it, saves it to SharePoint |
excel_macro.py |
Opens an Excel file and runs a VBA macro |
Export Formats
Your SAP recording should include the export menu clicks (right-click, select format, etc.). The export_format setting just tells the engine what file type to expect so it can handle the save dialog correctly.
| Format | What the engine does |
|---|---|
"txt" |
Fills in the save dialog, reads the tab-delimited text file |
"xlsx" |
Fills in the save dialog, waits for the file, closes the Excel window SAP opens |
"clipboard" |
No save dialog needed, reads directly from clipboard |
Tools
Transaction Checker (tools/check_transactions.py): Scans all your scripts for SAP transaction codes, then connects to SAP and verifies each one opens successfully. Run it with check_transactions.bat.
Project details
Release history Release notifications | RSS feed
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 process_automation-1.0.1.tar.gz.
File metadata
- Download URL: process_automation-1.0.1.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7de84c1f6fdb1748edfa4029330c2ff2587812fff7741edcfd56adee792f882d
|
|
| MD5 |
824c3f97058c8b33a6297aef3cbf3f12
|
|
| BLAKE2b-256 |
2bd69b2daa5876d8e6284937799d2eb248d866a5dc7ac5f7ee25f4fb7f24cd14
|
Provenance
The following attestation bundles were made for process_automation-1.0.1.tar.gz:
Publisher:
publish.yml on Mircea-Sava/process-automation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
process_automation-1.0.1.tar.gz -
Subject digest:
7de84c1f6fdb1748edfa4029330c2ff2587812fff7741edcfd56adee792f882d - Sigstore transparency entry: 1061542750
- Sigstore integration time:
-
Permalink:
Mircea-Sava/process-automation@9935d00f0da39f0662c4fa4766a306c98b03eb48 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Mircea-Sava
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9935d00f0da39f0662c4fa4766a306c98b03eb48 -
Trigger Event:
release
-
Statement type:
File details
Details for the file process_automation-1.0.1-py3-none-any.whl.
File metadata
- Download URL: process_automation-1.0.1-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2328d5ff34e8a3d500238d88495881543ef4a4d7c68dfeef1791df67f25be186
|
|
| MD5 |
5242b067ce51b42110aa8a7498b088b5
|
|
| BLAKE2b-256 |
e736cea4af099c22b329f8a746d97a594e59c612c3753a0c45a63061a25f2fb9
|
Provenance
The following attestation bundles were made for process_automation-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on Mircea-Sava/process-automation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
process_automation-1.0.1-py3-none-any.whl -
Subject digest:
2328d5ff34e8a3d500238d88495881543ef4a4d7c68dfeef1791df67f25be186 - Sigstore transparency entry: 1061542751
- Sigstore integration time:
-
Permalink:
Mircea-Sava/process-automation@9935d00f0da39f0662c4fa4766a306c98b03eb48 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Mircea-Sava
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9935d00f0da39f0662c4fa4766a306c98b03eb48 -
Trigger Event:
release
-
Statement type: