cancel
Showing results for 
Search instead for 
Did you mean: 

Run-time error while trying to select node 10 on a tree

Former Member
0 Kudos

Hello Team, i usually spend some time reading posts on this community and applying some solutions you gave to my own problems but, in this case, I'm stuck and can't find a solution. I hope you give me an advice on this.

I'm trying to go through a node tree, comparing its' elements with the ones I have stored on an array. When a get the correct one, then it perform a process involving the .selectnode and .doubleclicknode methods. The script run as it has to but, when i get to node 10, the macro will stop and thow a run-time error message.

This is my code:

    For k = 3 To 10000

        Set sapnode = session.findbyid("wnd[0]/shellcont/shell/shellcont[1]/shell[1]")

        sapnode.selectnode "          " + CStr(k)

        strNodeComp = sapnode.GetColumnCol(sapnode.GetColumnNames.Item(0)).Item(k - 1)

        If strNodeComp = strNodeArray(intIndex) Then

            sapnode.doubleClickNode "          " + CStr(k)

            session.findbyid("wnd[0]/usr/subSUB_HUDETAIL:/SCWM/SAPLUI_PACKING:0300/tabsTS_HU/tabpHUDETAIL2").Select

            Set TrackTab = session.findbyid("wnd_[0]/usr/subSUB_HUDETAIL:/SCWM/SAPLUI_PACKING:0300/tabsTS_HU/tabpHUDETAIL2/ssubSUB_DETAIL:/SCWM/SAPLUI_PACKING:0335/cntlCC_HUID/shellcont/shell")

            TrackTab.pressToolbarButton "NEW_LINE"

            TrackTab.setColumnWidth "HUIDENT", 25

            TrackTab.modifyCell 0, "IDART", "T"

            TrackTab.modifyCell 0, "HUIDENT", strRefDoc

            TrackTab.pressEnter

            session.findbyid("wnd[0]").sendVKey 0

            sapnode.collapseNode "          " + CStr(k)

            intIndex = intIndex + 1

            If intIndex = intnodelenght - 2 Then

                Exit For

            End If

        End If

    Next k

Thanks in advance for your valuable help.

MadHer

Accepted Solutions (1)

Accepted Solutions (1)

script_man
Active Contributor
0 Kudos

Hi Victor,

It may be that you could use the following notice.

sapnode.selectnode right("          " + CStr(k),11)

and

sapnode.doubleClickNode right("          " + CStr(k),11)

and

sapnode.collapseNode right("          " + CStr(k),11)

Regards,

ScriptMan

Former Member
0 Kudos

Hi ScriptMan, sorry for delay in my answer, this process was only performed under some circunstances, which not occuerred until yesterday. Your solution works perfect for me.

Please close this thread as is resolved.

By the way, i'm new on sapscripts but i want to learn more, can you please suggest me which would be a good work for learning this?

Thanks and Best Regards,

Answers (1)

Answers (1)

thomas_brutigam2
Active Participant
0 Kudos

Hi Victor.

just in case you have to run through all 30000 Nodes,

it would be easier if you do like this:

Get the Original Length of the first Entry:

a_len = Len("          ") !!!! Here Without the "first" Node !!!! only Spaces!

So if K gets to the next higher place (10,100,1000) you just have to Calculate its Length an "add" some Spaces:

for example

For k = 3 to 100000

b_len= len(CStr(k))

destnode = String(" ",a_len - b_len) &CStr(k)

sapnode.selectnode destnode

Next k

This has to be fitted at your needings an it will work

Greetings Thomas Br