I need to find and open the corresponding process order for each delivery. I've found a list of the process orders in the DRB (see screenshot below). Now I want to open each PO separately but I'm a bit stuck.
I thought to loop through each line and check if the text states 'Process Order'. Is there a technical name as well for the specific line? This would be ideal if I use different languages, otherwise I would need to specify each translation in my if-function. I thought to do it like this but it's not working sadly:
Set tree = session.findById("wnd[0]/usr/cntlBROWSER/shellcont/shell/shellcont[1]/shell[1]")
Set ListNodeKeys = tree.GetAllNodeKeys
For Each nodeKey In ListNodeKeys
nodeText = tree.GetNodeTextByKey(nodeKey)
If nodeText = "Process Order" Then
tree.doubleClickNode
End If
Next nodeKey
Does anyone have a better solution for this?
EDIT: I've got it to work with the following:
tree.selectNode (nodeKey)
tree.doubleClickNode (nodeKey)
But I've now seen that I need to firstly open up the 'Sales Order' tree and then find the 'Process Order'. What is the best way to do this? Because I want to check a specific field in each process order, but I cannot make the loop work to firstly open the 'sales order' and the doubleclick on the 'Process order'. Then check a field and go back to the following process order.
So my current code is as follows:
Set tree = session.findById("wnd[0]/usr/cntlBROWSER/shellcont/shell/shellcont[1]/shell[1]")
Set ListNodeKeys = tree.getallnodekeys
For Each nodeKey In ListNodeKeys
nodeText = tree.GetNodeTextByKey(nodeKey)
If nodeText = "Sales Order" Then
tree.expandNode (nodeKey)
End If
Next nodeKey
For Each nodeKey In ListNodeKeys
nodeText = tree.GetNodeTextByKey(nodeKey)
If nodeText = "Process Order" Then
tree.selectNode (nodeKey)
tree.doubleClickNode (nodeKey)
testExtract = session.findById("wnd[0]/usr/tabsTABSTRIP_5115/tabpKOZE/ssubSUBSCR_5115:SAPLCOKO:5120/ctxtAFPOD-KDPOS").Text
MsgBox testExtract
End If
Next nodeKey
So firstly I expand the 'Sales Order' (you can see it on my screenshot above) and then I try to open all process orders. I'm now stuck at opening the first process order. If I run the code separately, when sales order is already 'open', I can double click on the process order without any problem. Only when I combine the code as shown here above, I cannot get into the process order (so expand sales order + double click on process order).
Anyone an idea of a good solution for the edit here above?
The problem was that the first node was selected automatically and messed up the code that followed. I bypassed it by deselecting it each time:
If nodeText = "Process Order" Then
tree.selectNode (nodeKey)
tree.doubleClickNode (nodeKey)
tree.unselectNode (nodeKey)
testExtract = session.findById("wnd[0]/usr/tabsTABSTRIP_5115/tabpKOZE/ssubSUBSCR_5115:SAPLCOKO:5120/ctxtAFPOD-KDPOS").Text
MsgBox testExtract
End If