So I am developing a data extractor in order to extract SAP data using SAP Gui Scripting + VBA (Excel).
The script will run a transaction and extract the data to excel. The following is the code to extract the data from gridview:
'Save gridview
Set GridView = Session.findById("/app/con[0]/ses[0]/wnd[0]/usr/cntlG_CONTAINER/shellcont/shell/shellcont[1]/shell")
' Extract data to excel
For i = 0 To GridView.RowCount - 1
For j = 0 To GridView.ColumnCount - 1
shtInput.Cells(z + i, j + 1) = GridView.GetCellValue(i, GridView.ColumnOrder(j))
Next j
shtInput.Cells(z + i, Area) = "Undefined"
Next i
Exit Sub
It copies most of the data correctly, however the last rows in SAP isn't copied correctly.