-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-SapTableColumn.ps1
More file actions
74 lines (57 loc) · 1.83 KB
/
Copy pathSet-SapTableColumn.ps1
File metadata and controls
74 lines (57 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#Requires -Version 5.1
<#
.SYNOPSIS
Fills consecutive rows of a SAP GuiTableControl from a list of values.
.DESCRIPTION
PowerShell port of src/vbs/SapTableInput.vbs.
GuiTableControl.GetCell(row, column) is zero based and addresses the visible
window of the control, so the first visible row is index 0 after every scroll.
The control has to be resolved again after each scroll because SAP GUI
rebuilds its child elements when the viewport moves.
.PARAMETER Session
A GuiSession, e.g. the object returned by Connect-SapGui.ps1.
.PARAMETER TableId
findById path of the table control.
.PARAMETER Value
Values to write, one per row. Accepts pipeline input.
.PARAMETER ColumnIndex
Zero based column index inside the table control. Default 0.
.PARAMETER ConfirmPopup
Press the save button of the modal popup (wnd[1]) once every value is written.
.EXAMPLE
'1000','1010','1020' |
.\Set-SapTableColumn.ps1 -Session $session -TableId 'wnd[1]/usr/tblX' -ConfirmPopup
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
$Session,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$TableId,
[Parameter(Mandatory, ValueFromPipeline)]
[string[]]$Value,
[ValidateRange(0, 255)]
[int]$ColumnIndex = 0,
[switch]$ConfirmPopup
)
begin {
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$rowIndex = 0
}
process {
foreach ($item in $Value) {
$Session.FindById($TableId).VerticalScrollbar.Position = $rowIndex
$table = $Session.FindById($TableId)
$table.GetCell(0, $ColumnIndex).Text = $item.Trim()
Write-Verbose "row $rowIndex = $($item.Trim())"
$rowIndex++
}
}
end {
if ($ConfirmPopup) {
$Session.FindById('wnd[1]/tbar[0]/btn[8]').Press()
}
Write-Verbose "wrote $rowIndex row(s)"
}