Automate the double work of logging maintenance tasks twice: once in the Excel Schichtbuch and once in SAP PM.
This VBScript scans the shift logbook Excel, identifies entries not yet processed in SAP, and confirms, completes, or cancels the corresponding SAP work orders (IW41 / IW32), either fully automatically or with user confirmations.
🧑🏭 Typical users: Maintenance & Reliability (M&R) planners, supervisors, managers
⚙️ Runs on: Windows, SAP GUI for Windows (with scripting), Microsoft Excel
- Features
- How it works
- Prerequisites
- Installation
- Excel layout & data mapping
- Command-line usage
- Parameter defaults
- Run examples
- Logging
- Safety checks & guardrails
- Known limitations
- Troubleshooting
- 🔍 Reads the Schichtbuch Excel in bulk (fast, minimal COM calls)
- 👷 Maps employee names → SAP personnel numbers using sheet 2 (lenient name matching)
- 🕒 Converts Excel time fractions into proper timestamps and correctly handles overnight work
- 🌍 Converts all timestamps to UTC using Windows ActiveTimeBias
- 🗃️ Confirms work orders in IW41 including short texts, work duration, start/end, and final confirmation settings
- ❌ Cancels orders in IW32 when the Excel log marks them as cancelled
- 🧹 Optionally completes (TECO) confirmed work orders
- 📄 Writes back results to the Excel (column 16) only if no existing message is present
- 🔁 Optional helper: copies upcoming PMs from IW38 into the Excel (layout-dependent)
- 🛡️ Robust SAP wrappers (
SafeFindById,SafeSetText,SafeSendVKey, etc.) - 🪵 Detailed log files in
./logs/
- Script initializes logging, reads runtime arguments, loads timezone offset.
- Determines which Excel file to open based on:
filePathargument- OR
useCurrentExcel=yes(builds SharePoint path) - OR file-open dialog (default)
- Excel is opened; sheet 1 & sheet 2 are bulk-read for performance.
- Each row in sheet 1 is validated and processed:
- Checks WO, employee, status, times
- Cancels orders in IW32 when needed
- Determines SAP status and skip-conditions
- Confirms WOs via IW41 for one or multiple employees
- Performs TECO if needed
- Writes result messages to column 16
- Logs everything and exits cleanly
- Windows with Windows Script Host (WSH)
- SAP GUI 7.x+ with scripting enabled (client + server)
- Microsoft Excel installed
- SAP access to IW32, IW33, IW38, IW41
- IW38 helper requires ALV layout with technical field names
- Place these files in the same directory:
- Ensure folder is writable (script creates
./logs/) - Ensure SAP GUI scripting is enabled
| Column | Description |
|---|---|
| 1 | Date (Tag) |
| 3 | WO_Nr (must be 9 digits starting with 4) |
| 5 | Employee(s) separated by / |
| 7 | Bemerkung |
| 8 | Fehlerbeschreibung |
| 9 | Massnahme (max 40 chars) |
| 10 | Startzeit (Excel fraction) |
| 11 | Endzeit (Excel fraction) |
| 12 | DauerInH (fraction or time) |
| 15 | Status (matches sheet 2) |
| 16 | Script output message |
- Column A: Employee name
- Column B: Personnel number
- Cell E4: "done" text
- Cell E5: "cancelled" text
cscript //nologo "Schichtbuch script.vbs" [filePath=<path_or_url>] [autoConfirm=yes|no] [useCurrentExcel=yes|no]
Default: not provided
Behavior:
- If
useCurrentExcel=yes→ script builds current-month SharePoint path - Otherwise → shows Excel file-open dialog
Default: not provided
Behavior: script asks user:
- Yes → automatic confirmations
- No → ask before each confirmation
Default: no
Behavior:
yes→ build SharePoint path for current month's Schichtbuchno→ normal file selection process
cscript //nologo "Schichtbuch script.vbs"
cscript //nologo "Schichtbuch script.vbs" filePath="C:\Data\Schichtbuch.xlsx" autoConfirm=yes
cscript //nologo "Schichtbuch script.vbs" useCurrentExcel=yes autoConfirm=yes
Stored in ./logs/<script>_<user>_<timestamp>.log.
- Hard skip conditions: missing WO, wrong WO format, message already present, status missing
- Soft skips: missing employee, missing times, invalid conversions
- SAP skip conditions: purchases found, multiple operations
- SAP wrappers abort cleanly on layout or scripting errors
- SAP GUI layout differences require adjustments
- IW38 helper depends on technical ID layout
- Massnahme truncated to 40 chars
- Buffered writes disabled for reliability
Check SAP GUI scripting and correct transaction screen.
Add employee + personnel number to sheet 2.
Ensure Excel uses real time values or fractions.