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

与世无争的帅哥 提交于 2020-12-12 07:53:27

问题


I need to read a specific column value of the last row of the below Variant table in SAP. 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?


回答1:


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


来源:https://stackoverflow.com/questions/59820810/how-to-read-row-details-of-a-guitree-control-using-gui-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!