udani
udani

Reputation: 1307

How to read row details of a GuiTree control using GUI Script

I need to read a specific column value of the last row of the below Variant table in SAP GUI. When I record the script to navigate through the rows of the table, I get below lines. I need to extract specific cell value. Manually, I can copy and paste the content of the row to note pad. But, I am unable to figure out how to read the content of the specific column or entire row.

I have been trying different ways:

session.findById("wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB06/" _
    & "ssubSUBSC:SAPLATAB:0201/subAREA1:SAPLAIA1:0304/subSUB:SAPLAIA1:0308/" _
    & "subTREE:SAPLAIA1:0306/cntlVARI_CANVAS/shell").selectedNode = "0001"

session.findById("wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB06/" _
    & "ssubSUBSC:SAPLATAB:0201/subAREA1:SAPLAIA1:0304/subSUB:SAPLAIA1:0308/" _
    & "subTREE:SAPLAIA1:0306/cntlVARI_CANVAS/shell").selectedNode = "0002"

These are the lines generated when I move down the row using down arrow key. But how can I get the content of the row?

enter image description here

Upvotes: 3

Views: 5135

Answers (1)

Sandra Rossi
Sandra Rossi

Reputation: 13676

This is a GuiTree object, and more specifically one of type "Column Tree".

In your case, that will be:

set tree = session.findById("wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB06/" _
& "ssubSUBSC:SAPLATAB:0201/subAREA1:SAPLAIA1:0304/subSUB:SAPLAIA1:0308/" _
& "subTREE:SAPLAIA1:0306/cntlVARI_CANVAS/shell")

The property SelectedNode gives a String which is the key of the node currently selected ("node" is for a line of the tree):

nodeKey = tree.SelectedNode

From there, you may access the node text with the method GetNodeText:

nodeText = tree.GetNodeText( nodekey )

The text of a cell is obtained with the method GetItemText ("item" being a cell at the intersection of a row and a column of the tree, excluding the left column containing the hierarchy):

itemText = tree.GetItemText( nodeKey, columnName )`

The column names are obtained with the method GetColumnNames:

set columnNames = tree.GetColumnNames()`

The column names being a GuiComponentCollection object, you loop at its elements as follows:

for i = 0 to columnNames.Length - 1
  colunmName = columnNames.ElementAt(i)
next

Upvotes: 4

Related Questions