on 08-31-2015 12:16 PM
Hi, I am working on a project in SAP BW. I want to use a script to search for a certain object in the tree of InfoProviders.When I use the recorder to search for a certain node (and then expand it) it generates this code for me:
REM start transaction
session.findById("wnd[0]/tbar[0]/okcd").text = "/nrsa1"
session.findById("wnd[0]").sendVKey 0
REM Search in the tree for object "ZCSG01"
session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = " 1"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = " 1"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[0]/shell").pressButton "%AWB_TREE_SEARCH"
session.findById("wnd[1]/usr/txtRSAWBN_S_DYNPRO_0500-SEARCH_TERM").text = "ZCSG01"
session.findById("wnd[1]/usr/txtRSAWBN_S_DYNPRO_0500-SEARCH_TERM").caretPosition = 6
session.findById("wnd[1]").sendVKey 0
REM "ZCSG01" is found as node 37
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").expandNode " 37"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = " 1"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").selectItem " 38","COL1"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").ensureVisibleHorizontalItem " 38","COL1"
The generated code finds the node, but then (in the rest of the script) uses the absolute position " 37". This means that my script stops working when I insert a new object between node 1 and node 37. I would like to know if I can search for the name of the node so that I can dynamically determine the line number of the node.
Also, I am not able to find any proper documentation about how to work with hierarchies and the commands that are available. If anyone could help me in that respect that would be great too.
I found the solution: See the changes that I marked in BOLD.
twan.jans-beken wrote:
Hi, I am working on a project in SAP BW. I want to use a script to search for a certain object in the tree of InfoProviders.When I use the recorder to search for a certain node (and then expand it) it generates this code for me:
REM start transaction
session.findById("wnd[0]/tbar[0]/okcd").text = "/nrsa1"
session.findById("wnd[0]").sendVKey 0
REM Search in the tree for object "ZCSG01"
session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = " 1"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = " 1"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[0]/shell").pressButton "%AWB_TREE_SEARCH"
session.findById("wnd[1]/usr/txtRSAWBN_S_DYNPRO_0500-SEARCH_TERM").text = "ZCSG01"
session.findById("wnd[1]/usr/txtRSAWBN_S_DYNPRO_0500-SEARCH_TERM").caretPosition = 6
session.findById("wnd[1]").sendVKey 0
Dim strKey
Dim strTxt1, strTxt2
strKey = session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").GetFocusedNodeKey
strTxt1 = Right(" " & Cstr(strKey), 11)
strTxt2 = Right(" " & Cstr(strKey + 1), 11)
REM "ZCSG01" is found as node 37
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").expandNode strTxt1
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = " 1"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").selectItem strTxt2,"COL1"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").ensureVisibleHorizontalItem strTxt2,"COL1"
The generated code finds the node, but then (in the rest of the script) uses the absolute position " 37". This means that my script stops working when I insert a new object between node 1 and node 37. I would like to know if I can search for the name of the node so that I can dynamically determine the line number of the node.
Also, I am not able to find any proper documentation about how to work with hierarchies and the commands that are available. If anyone could help me in that respect that would be great too.
So the short answer is: The command to use is
session.findById("wnd[0]/...").GetFocusedNodeKey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.