Purpose Use the built-in functions of the native
control interface for the Tree Control
For most tasks it is not advisable to
program your own VB functions that communicate with the special SAP
UI controls such as grid control or tree control. The SAP UI
controls are more complex than one might think, since they
handle user actions, read and write the SAP GUI datastream and
communicate with SAP application. So your VB function is player
number three or four in this system.
The following functions, built in into the GuiXT Controls
interface "guinet.dll", cover most of what is normally needed.Please observe:
All functions have obligatory
and optional parameters. We
suggest you use the "by name" calling for all optional
parameters.
All functions can either be called from your GuiXT script, in most cases with
CallVBAsync, or from your own VB.NET function. If you need to
evaluate the return code of the built-functions it is often more
practical to call up your own VB.NET function with
CallVBAsync and then call the built-in function from there.
TreeControl.GetSelectedItem
Returns the selected
tree node, or "" if no node is selected
In an InputScript this function can be used synchronously via CallVB.
It is useful at the beginning of an InputScript if you need the selected
tree node for further processing. See also the returned system
variables (below) that contain further information about the selected
node.
GuiXT
CallVB guinet.TreeControl.GetSelectedItem
Parameters 1
treeNo Default: 1
Number of the tree on screen; you need it if there are several trees.
2 treeView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
Returns The internal node key, or "" if no
node is selected
Sets system variables V[_treeNode.fullpath]
Full path of the selected tree node V[_treeNode.key]
Internal key of the seleced node V[_treeNode.label]
Label of the seleced node V[_treeNode.type]
Type of the sected node
SAP uses the following node types: trvNodeTypeFolder = 0 trvNodeTypeLeaf = 1 trvNodeTypeHidden = 2
trvNodeTypeDisabled = 4 trvNodeTypeGrayed = 8
trvNodeTypeDisabledGrayed = 12
In relatively large trees, for example the SAP Easy Access
tree or the SAP Reference IMG (transaction SPRO), the tree control does
not load all nodes immediately but waits until the user requests a
particular subtree. A selection by key with
TreeControl.SelectNodeByKey will fail if the node is not yet
loaded into the tree control. But the selection by path with
TreeControl.SelectNodeByPath (see below) will work for such "lazy
loading" trees, since GuiXT automatically expands all subtrees of the
given hierarchical path during its search.
In your InputScript, put
TreeControl.SelectNodeByPath into a separate Sceen ... Enter block
(see the example below). GuiXT then automatically expands all subtrees
of the given hierarchical path during its search.
Enter "/nspro"
// Customizing: Execute Project
Screen SAPLS_IMG_TOOL_5.0100
Enter "/5" // SAP Reference IMG
Screen SAPLSHI01.0200
Set V[p1] "SAP Customizing Implementation Guide"
Set V[p2] "Sales and Distribution"
Set V[p3] "Sales"
Set V[p4] "Sales Documents"
Set V[p5] "Contracts"
Set V[p6] "Value Contract"
Set V[mypath] "&V[p1]\&V[p2]\&V[p3]\&V[p4]\&V[p5]\&V[p6]"
CallVBAsync guinet.treecontrol.SelectNodeByPath "&V[mypath]"
Enter
In your InputScript, put
TreeControl.DoubleclickNodeByPath into a separate Sceeen...Enter block
(see the example below). GuiXT then automatically expands all subtrees
of the given hierarchical path during its search.
Parameters 1 path The internal node path
to select, or a comma-separated list of paths which are searched one
after the other
2 delimiter Default: ","
Delimiting character or string in the node key list
3 treeNo Default: 1
Number of the tree on screen; you need it if there are several trees.
4 treeView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
Returns 0 if node path is not found 1 if
first node path is found, 2 if second and so on
TreeControl.CopyText
Copies the whole tree (or a selected subtree) into a
GuiXT text variable, one line for each tree node. Each line contains:
Node key
Node level
Technical node number (internal use only)
One or more node labels
See the example below.
In your InputScript, put
TreeControl.CopyText
into a separate Sceeen...Enter block (see the example below). GuiXT then
automatically expands all subtrees of the given hierarchical path during
its search.
GuiXT
CallVBAsync guinet.TreeControl.CopyText
Parameters 1
textName Default: ""
Name of the text variable 2 delimiter Default: ","
Delimiter (string is possible) to be used between the returned
node values
3 path Default:
" " // not yet supported in GuiXT 2019 Q1 2 If specified, only the subtree for the given
path is copied into the text variable
4 treeNo Default: 1
Number of the tree on screen
5
treeView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
6
colNames Default: "" If "X", the first line returned contains the internal column names
7
colTitles Default: "" If "X", the first line returned contains the column titles
Returns The same text that is put into the text variable.
Example:
GuiXT
// SAP header text display
Screen sapmv45a.4002
// read whole text tree into a GuiXT text variable
CallVBAsync guinet.treecontrol.copytext _
textName:="tc.headertexts" _
delimiter:=";"
Enter
Screen sapmv45a.4002
Message "&text[tc.headertexts]"
Enter