on 03-06-2015 8:25 PM
I would like to fetch Material and Date from GuiTree using VBScript.
Below is my code that fetches ConRecNo (Ex:0000006669, 0000045082 etc.,)
session.findById("wnd[0]/tbar[1]/btn[18]").press
strSearchNodeText = "0000045082"
Set aw = session.activeWindow()
Set ObjSAPGuiTree = aw.FindById("wnd[1]/usr/cntlTREE1/shellcont/shell/shellcont[1]/shell[1]")
'Get the node keys , a key is a number/position in the
'A key value starts from 1.
Set ObjKeyValues = ObjSAPGuiTree.GetAllNodeKeys
'get the total count
''This count indicates the number of items/nodes in the Tree
intNodeCount = ObjKeyValues.Count
msgbox intNodeCount
blnFlag=False
'Iterate through the nodes of the tree
For i = 0 to intNodeCount-1
'Get the node text
strNodeText=ObjSAPGuiTree.GetNodeTextByKey(ObjKeyValues(i))
' strNodeText=ObjSAPGuiTree.getCellValue(i,"Material")
msgbox strNodeText
'Check if the match was found for the key that you are looking for
'if yes then activate the item
If Instr(strNodeText,strSearchNodeText)>0 Then
'Select the node and double click on it
'This is equivalent to ActivateItem
ObjSAPGuiTree.SelectNode ObjKeyValues(i)
ObjSAPGuiTree.DoubleClickNode ObjKeyValues(i)
blnFlag=True 'set a flag to indicate the macth was found
Exit For
End If
Next
'Release the objects
msgbox intNodeCount
Set ObjKeyValues=Nothing
Set ObjSAPGuiTree=Nothing
' myText = session.findById("wnd[1]/usr/cntlTREE1/shellcont/shell/shellcont[1]/shell[1]").getNodeTextByPath("1\1\4")
' msgbox myText
session.findById("wnd[1]/tbar[0]/btn[0]").press
Hi sap krazy,
before a long time, I had a similar problem. I solved it like follows:
. . .
For i = 0 to intNodeCount-1
'Get the node text
strNodeText=ObjSAPGuiTree.GetNodeTextByKey(ObjKeyValues(i))
' strNodeText=ObjSAPGuiTree.getCellValue(i,"Material")
msgbox strNodeText
strNodeText_Material = ObjSAPGuiTree.getItemText(CStr(ObjKeyValues(i)),"C 3")
'Check if the match was found for the key that you are looking for
'if yes then activate the item
If Instr(strNodeText,strSearchNodeText)>0 Then
'Select the node and double click on it
'This is equivalent to ActivateItem
ObjSAPGuiTree.SelectNode ObjKeyValues(i)
ObjSAPGuiTree.DoubleClickNode ObjKeyValues(i)
blnFlag=True 'set a flag to indicate the macth was found
Exit For
End If
Next
. . .
The parameter ItemName = "C 3" I took from the recorded script:
. . .
session.findById("wnd[0]/usr/cntlCNTL_CONTAINER/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell[1]").selectItem " 11","C 3"
session.findById("wnd[0]/usr/cntlCNTL_CONTAINER/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell[1]").ensureVisibleHorizontalItem " 11","C 3"
session.findById("wnd[0]/usr/cntlCNTL_CONTAINER/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell[1]").itemContextMenu " 11","C 3"
session.findById("wnd[0]/usr/cntlCNTL_CONTAINER/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell[1]").selectContextMenuItem "&FIND"
session.findById("wnd[1]/tbar[0]/btn[12]").press
It places the cursor on the cell with the material and press the right mouse button. Then select from the context menu the Find command and then pressing Cancel. Here, the upper script originated. Then you would only have to figure out in your script how is your column name for material. The date would have to work on the same principle.
Regards,
ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello.
May I miss your question. What is your issue right now?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Holger,
Thanks for taking time to read my query. I need your help in coding VBScript.
I would like to fetch Material and Date information from GuiTree. Using method GuiTree type method I figured its a 2 (Column tree). Please refer to picture attached. I'm can fetch condition record number (example: 0000004574, 0000045082 etc.,) but not corresponding material and date information.
Your help is much appreciated!!
Unfortunately I can´t discover this object in my System as we do not have any Setup/masterdata for this Transaction QC03.
As you can see on my Picture we have this GUITREE similar as ALV. First column can be read as nodekey. Subsequent data will appear as child_gui after doubleclick and all columns can be read.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.