Purpose
Select a tree node

Solution
Use the predefined VB function
   guinet.TreeControl.SelectNodeByPath

specifying the hierarchical node path.

If you know the technical node key, you may use
   guinet.TreeControl.SelectNodeByKey
  
Examples:
 
CallVBAsync guinet.TreeControl.SelectNodeByPath "Shipping Instruction\EN"

or
 CallVBAsync guinet.TreeControl.SelectNodeByKey "TXT03EN"


Both functions allow us to specify a list of node identifiers (by path or by key) which are searched one after the other. The functions return the number 1,2,... of the matching identifier, or 0 if no matching node can be found.

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


Please note:
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 SelectNodeByKey will fail if the node is not yet loaded into the tree control. But the selection by path with SelectNodeByPath will work for such "lazy loading" trees, since GuiXT automatically expands all subtrees of the given hierarchical path during its search.


Example

In transaction VA03 (customer order display) there is a tab "Shipping". We want to display the "shipping instruction text"  on the "shipping" tab
:

 

 

In our InputScript that reads the text we need to select the right node in the text selection tree  in VA03:

To identify the node, we can either use the hierarchical path "Shipping instruction\EN" or the internal SAP node key "TXT03EN".  Here TXT03 is the configured text id and EN is the language code. In other trees, the internal node keys may be meaningless numbers.

Tip: The command

CallVBAsync guinet.TreeControl.GetSelectedItem

reads both the current node path and the node key into GuiXT variables which you can display in the GuiXT Debug window:

 

GuiXT script

// new transaction or new order number?
// then clear all transaction specific GuiXT variables
if not V[tc.transactionid=&V[_transactionid]] _
      or not
V[tc.vbeln=&F[VBAK-VBELN]]
 
Clear V[tc.*]
 
Clear text[tc.*]
  Set V[tc.transactionid] "&V[_transactionid]"
  Set V[tc.vbeln] "&F[VBAK-VBELN]"

endif

if Q[Transaction=VA03]

 
if Q[Page=Shipping]
   
// shipping note already read?
   
if not V[tc.shipping_instruction_read]
     
Set V[tc.shipping_instruction_read] "X"
     
// read shipping note
     
Enter "=KTEX_SUB" process="read_shipping_instruction.txt"

      // no further script processing at the moment
     
Stop Script
    endif

    // display shipping note
   
Box (7,88) (11,156) "Shipping instruction"
   
TextBox (7.5,88.8) (11,156.5) name="tc.shipping_instruction" -readOnly

  endif
endif

InputScript "read_shipping_instruction.txt"

 // ----------------------------------------
// VA03, read shipping instruction text
// ----------------------------------------

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

// read text and return
Screen SAPMV45A.4002
  
if V[shipping_instruction_exists=1]
   
CallVBAsync guinet.TextControl.GetText textName:="tc.shipping_instruction"
 
endif

 Enter "/3" // Back

Please observe: In your InputScript you need a separate Screen...Enter block for the tree node selection.

 

Components
InputAssistant + Controls