cancel
Showing results for 
Search instead for 
Did you mean: 

How can I scroll to the bottom of a page with VBS script recording?

Former Member
0 Kudos

I am writing a program that utilizes VBScript in order to grab data from SAP. When I load the large table of data, select it, and then copy it, I am getting a message saying that not all data is copied to the clipboard. If I scroll down before selecting the data the rows that were not copied become populated. So in my script I want the page to scroll down before selecting all the data and copying it.

I have looked into using the "sendkey" methods for the page down key but my research has led me to believe that this type of command does not actually work for SAP. The macro recorder also does not pick up my action of scrolling down manually.

Is there another way of doing this? Or am I am I mistaken about my previously attempted methods being wrong.

Accepted Solutions (1)

Accepted Solutions (1)

stefan_schnell
Active Contributor

Hello Alexander,

you can find a solution for your problem here. We discuss the same problem in the context to load any table as CSV file from a grid. In this case we actualize all 32 lines the grid until we get the bottom of the table.

Let us know your result.

Cheers
Stefan

Former Member
0 Kudos

I have read through this a few times and understand the purpose. It is a very well written post; However, I believe that it is too complicated of a solution for what I need to do. Could you please explain why I would need to do that over using other simpler approaches? I currently have been trying a few other things.

1. Using the firstVisibleRow property I can have the scrollbar move but I cannot figure out how to set the firstVisibleRow to be the last row in the table. Is there not an easy way to do this?

2. Going into the ScrollBar object and setting its position. This has not worked for some reason. I try to set the position to the property "Maximum" that I found in the Scripting help documentation but this does not do anything.

Is there a reason that these methods cannot work? Thank you so much for your valuable time!

stefan_schnell
Active Contributor

Hello Alexander,

as far as I know the SAP data provider loads only the visible rows, to minimize data traffic between back end and front end, that is the reason to load the rows successive. If you jump to the end of the table, it also doesn't loads the whole table.

Here I jump to the end of a table and go up a step, you can see the data provider reloads the data.

1. Try this to jump to the end of an ALV Grid

Rows = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").RowCount
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").firstVisibleRow = Rows - 1

2. It seems that the scroll bar isn't supported by the GridView control. If you record you activities and change the position of the scroll bar, the recorder delivers settings of firstVisibleRow.

Cheers
Stefan

Former Member

This solution has worked for me I cannot thank you enough! I can finally move on with my project!

stefan_schnell
Active Contributor
0 Kudos

Hello Alexander,

great to hear this.

Cheers
Stefan

Answers (1)

Answers (1)

lord_strahd
Member
0 Kudos

Hi All,

I had the same issue for about the last 3 years.

"When I load the large table of data, select it, and then copy it, I am getting a message saying that not all data is copied to the clipboard. If I scroll down before selecting the data the rows that were not copied become populated. So in my script I want the page to scroll down before selecting all the data and copying it."

I am self-taught, so my solutions are crude but effective.

My data always had a random amount of rows, between 2 and 120, but you should be able to continue this pattern to include as may possible rows as needed. This code effectively cause SAP to scroll down ~30 rows at a time, filling in the data so when I copied the column I got all the info. the "On Error Resume Next" keeps it from breaking down if my current cell row is > the actual last row.

In my VBA, I added the lines:

On Error Resume Next

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").currentCellRow = 2
On Error Resume Next
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").currentCellRow = 30
On Error Resume Next
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").currentCellRow = 60
On Error Resume Next
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").currentCellRow = 90
On Error Resume Next

Hope this helps!