' Begin ----------------------------------------------------------------
Sub ReadTableInArray(TableName, ByRef ArrayName)
'Reset the session
session.findById("wnd[0]/tbar[0]/okcd").text = "/n"
session.findById("wnd[0]/tbar[0]/btn[0]").press
'Open TAC SE16
session.findById("wnd[0]/tbar[0]/okcd").text = "/nSE16"
session.findById("wnd[0]/tbar[0]/btn[0]").press
'View table
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = _
TableName
session.findById("wnd[0]/tbar[1]/btn[7]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
'Open user specific parameters dialog
'Attention: Here is a language sprecific code
Set Menu = session.findById("wnd[0]/mbar")
Set Einstellungen = Menu.FindByName("Einstellungen", "GuiMenu")
Set BenutzerPar = Einstellungen.FindByName("Benutzerparameter...", _
"GuiMenu")
BenutzerPar.Select()
'Set the display
Set ALVGridView = session.findById("wnd[1]/usr/tabsG_TABSTRIP/" & _
"tabp0400/ssubTOOLAREA:SAPLWB_CUSTOMIZING:0400/" & _
"radRSEUMOD-TBALV_GRID")
If ALVGridView.Selected = vbFalse Then
ALVGridView.select()
End If
session.findById("wnd[1]/tbar[0]/btn[0]").press
Set BenutzerPar = Nothing
Set Einstellungen = Nothing
Set Menu = Nothing
'Read data from table into array
Set table = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell")
Rows = table.RowCount() - 1
Cols = table.ColumnCount() - 1
ReDim ArrayName(Rows + 1, Cols)
'Get the title of all columns in the first array line
Set Columns = table.ColumnOrder()
For j = 0 To Cols
ArrayName(0, j) = CStr(Columns(j))
Next
For i = 0 To Rows
For j = 0 To Cols
ArrayName(i + 1, j) = table.GetCellValue(i, CStr(Columns(j)))
'Each 32 lines actualize the grid
If i Mod 32 = 0 Then
table.SetCurrentCell i, CStr(Columns(0))
End If
Next
Next
Set ALVGridView = Nothing
Set Columns = Nothing
Set table = Nothing
End Sub
'Main
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
Set connection = application.Children(0)
Set session = connection.Children(0)
'Read the table SFLIGHT in an array
Dim SFlight()
ReadTableInArray "SFLIGHT", SFlight
'Get a part from the array
For i = 0 To Ubound(SFlight, 1)
MsgBox SFlight(i, 1) & "; " & SFlight(i, 2) & "; " & SFlight(i, 3)
Next
' End ------------------------------------------------------------------