I have a question regarding a table in t-code FEBA, which is used for electronic bank statements. I'm trying to detect whether an item is selected or not. In the screenshot, you can see that the selected item is displayed in blue font, while the unselected items are in the normal font color:
I have the following code to loop through each line, but I couldn't find a way to check if an item is selected. Could you help me improve this?
Here is the line that I'm trying to modify to perform this check:
session.findById("wnd[0]/usr/tabsTS/tabpREST/ssubPAGE:SAPDF05X:6106/tblSAPDF05XTC_6106/txtDF05B-PSBET[11," & adjustedIndex & "]")
Apart from that, there's another way to detect selection: in the screenshot, if an item is selected, we can press on this line, but if it is not selected, we can't press it.
session.findById("wnd[0]/usr/tabsTS/tabpREST/ssubPAGE:SAPDF05X:6106/tblSAPDF05XTC_6106/txtDF05B-PSDIF[12," & adjustedIndex & "]")
Full code:
Function LoopDataOriginal(session As Object)
Dim rowCount As Integer
Dim visibleRows As Integer
Dim scrollPos As Integer
Dim i As Integer
Dim adjustedIndex As Integer
Dim batchSize As Integer
Dim endRow As Integer
rowCount = session.findById("wnd[0]/usr/tabsTS/tabpREST/ssubPAGE:SAPDF05X:6106/tblSAPDF05XTC_6106").rowCount
visibleRows = session.findById("wnd[0]/usr/tabsTS/tabpREST/ssubPAGE:SAPDF05X:6106/tblSAPDF05XTC_6106").VisibleRowCount
batchSize = visibleRows
For scrollPos = 0 To rowCount - 1 Step batchSize
session.findById("wnd[0]/usr/tabsTS/tabpREST/ssubPAGE:SAPDF05X:6106/tblSAPDF05XTC_6106").verticalScrollbar.position = scrollPos
endRow = scrollPos + batchSize - 1
If endRow >= rowCount Then endRow = rowCount - 1
For i = scrollPos To endRow
adjustedIndex = i Mod visibleRows
Debug.Print session.findById("wnd[0]/usr/tabsTS/tabpREST/ssubPAGE:SAPDF05X:6106/tblSAPDF05XTC_6106/txtDF05B-PSDIF[12," & adjustedIndex & "]").Text
Debug.Print session.findById("wnd[0]/usr/tabsTS/tabpREST/ssubPAGE:SAPDF05X:6106/tblSAPDF05XTC_6106/txtDF05B-PSBET[11," & adjustedIndex & "]").Text
'to add to check for selected
Next i
Next scrollPos
End Function
So, you are talking about a GuiTableControl Object. All possible methods are listed in the documentation.
You need to get the cell object, which is a GuiVComponent Object, via the field ID with its column/row coordinates (or via the method GetCell
of the Table Control object if you prefer):
Set tableControl = session.findById("wnd[0]/usr/tabsTS/tabpREST/ssubPAGE:SAPDF05X:6106/tblSAPDF05XTC_6106")
Set cell = tableControl.findById("txtDF05B-PSBET[11," & relativeRowIndex & "]")
' OR
Set cell = tableControl.getCell(11,relativeRowIndex)
You then get the property highlighted
, whose value is 1 if the cell text is highlighted (blue as you describe it), or 0 otherwise:
msgbox cell.Highlighted