Skip to Content

Going through a table in SAP returns errors

Hi,

I have been struggling with understanding how to loop through a table in SAP. Just to give some context, here is what I basically need to do:

1. Go to a page in SAP with a table

2. Double click on a line, which brings me to a window with values that I need to copy and insert it in a spreadsheet.

3. Loop through an entire table in the same fashion and repeat a procedure.

The object I am going through has the following code:

Session.FindById("wnd[0]/usr/cntlUSAGE_TREE_CONTAINER/shellcont/shell/shellcont[1]/shell").selectedNode = " 5" Session.FindById("wnd[0]/usr/cntlUSAGE_TREE_CONTAINER/shellcont/shell/shellcont[1]/shell").doubleClickNode " 5"

I am new to SAP and googled many instances already. I still have not figured out how to write the code in my case. Any recommendations will be appreciated.

My code returns error "The object does not support this property or method" (RowCount)

Dim Table As Object
Dim rows As Long
Dim i As Long

Set Table = Session.FindById("wnd[0]/usr/cntlUSAGE_TREE_CONTAINER/shellcont/shell/shellcont[1]/shell[1]")
rows = Table.RowCount - 1

For i = 0 To rows
Session.FindById("wnd[0]/usr/cntlUSAGE_TREE_CONTAINER/shellcont/shell/shellcont[1]/shell").selectedNode = "          i"
Session.FindById("wnd[0]/usr/cntlUSAGE_TREE_CONTAINER/shellcont/shell/shellcont[1]/shell").doubleClickNode "          i"

Next i

Add comment
10|10000 characters needed characters exceeded

  • Hello Olesia,

    welcome in the SAP Community.

    Are you sure that you are using a table...

    ...or an ALV-Grid?

    An ALV-Grid is a GuiShell with the SubType GridView, like in your example. The table is GuiTableControl and, in a normal case, without a shell. That would explain why the RowCount property is not available.

    Let us know your results.

    Cheers
    Stefan

    table001.jpg (19.1 kB)
    table002.jpg (32.3 kB)
  • Hello Stefan,

    I figured that. Indeed, my object was a tree. However, I have also grids and tables. I am wondering if there is a difference in declaring grids and tables. I am currently trying to find column names for a grid.

    My grid goes under the line: session.findById("wnd[0]/usr/lbl[6,5]") I am trying to figure how to find the column identifiers for this grid. Just a click on the column heading returns the same line with [6,5] at the end.

    Thank you for your help!



  • Follow
  • Get RSS Feed

0 Answers