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.

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

Example:
CallVB selnode = guinet.TreeControl.GetSelectedItem

 

 

TreeControl.SelectNodeByKey
Selects a tree node by its internal key.

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.

CallVBAsync guinet.TreeControl.SelectNodeByKey  key

Parameters
1
key
The internal node key to select, or a comma-separated list of keys 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 the node key is not found
1 if the first node key is found, 2 if the second one is found, and so on

Example:
CallVBAsync textno = guinet.TreeControl.SelectNodeByKey "TXT03DE,TXT03EN,TXT03FR"

 

 

TreeControl.SelectNodeByPath
Selects a tree node by its path.

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.

CallVBAsync guinet.TreeControl.SelectNodeByPath  path

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 pathis not found
1 if first node path is found, 2 if second and so on

Example 1:
Screen SAPMV45A.4002
   CallVBAsync shipping_instruction_exists = guinet.TreeControl.SelectNodeByPath _
 
           
 
"Shipping Instruction\EN"
 
Enter

Example 2:

Enter
"/nspro"

// Customizing: Execute Project
Screen SAPLS_IMG_TOOL_5.0100
 
Enter "/5" // SAP Reference IMG

Screen SAPLSHI01.0200
 
Set V[mypath] "SAP Customizing Implementation Guide\Sales and Distribution\Sales\Sales Documents\Contracts\Value Contract"
  CallVBAsync guinet.treecontrol.SelectNodeByPath "&V[mypath]"

Enter

 

TreeControl.SetFocus
Sets the focus on the tree control.

CallVBAsync guinet.TreeControl.SetFocus

Parameters
1 treeNo   Default: 1
Number of the tree on screen; you need it if there are several trees.

Returns
"" if tree controls is not found
"X" if tree control is found

 

 

TreeControl.DoubleclickNodeByKey
Selects a tree node by its internal key and presses F2 on the selected node to simulate the double click.

CallVBAsync guinet.TreeControl.DoubleclickNodeByKey  key

Parameters
1
key
The internal node key to select, or a comma-separated list of keys 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 key is not found
1 if first node key is found, 2 if second and so on


TreeControl.DoubleclickNodeByPath

Selects a tree node by its path and presses F2 on the selected node to simulate the double click.

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.

CallVBAsync guinet.TreeControl.DoubleclickNodeByPath  path

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.

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:
// 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

 


Components
InputAssistant + Controls