on 07-31-2014 4:51 PM
Hello,
I've been struggling to have a correct row count in my orders. Sometimes I can have from 1 to 50 items in it. I was only get row counts that includes all rows and only visible row count that can be seen on screen.
Is there any way to identify a number of rows that has data in them? Below are the references
TotalRow = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").rowCount
VisibleRow = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").visiblerowCount
BR,
Gedis
Expanding my answer above:
The quickest way to get the total rows with data inside a SAPGUI table control object is to use .VerticalScrollbar.Maximum + 1.
That +1 because the index of the SAPGUI table control row starts with 0, if you're looping from an array variable, that +1 is not necessary.
VisibleRowcount returns the total rows visible on screen, even if there is no data on the table. Say the table has data in 5 rows only, but the total visible rows is 11, you'll get 11.
RowCount returns the total visible and hidden rows of the table, regardless if it has data or not. The value is always total rows with data + total visible rows -1. If SAPGUI table object has 11 visible rows, 5 rows with data, you'll get 15.
So, to put all these properties together:
VerticalScrollbar.Maximum = Rowcount - VisibleRowcount
Another one is Rows.Count that will return similar value as VisibleRowcout.
Hope this info will be useful to someone out there, even if it is 6 years too late.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've been trying to juggle around with the code with what i have. i found work around where i loop scroll if last visible item is not empty and then proceed loop scrolling by 1 line until empty field while keeping count. It's sort of a bit slowish, but it does the job. I wonder if there is any easier way without looping through items.
Here's the code i used (is there formating to quote code?):
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUISERVER")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
On error resume next
dim itemInput
itemInput = 24
Dim TotScrol, TotScrolInt, RowScroll, Iterations, TotalRow, VisibleRow, runCount
TotalRow = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").rowCount
VisibleRow = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").visiblerowCount
'TotScrol = Totalrow/VisibleRow (OLD scroll count. Problem totarow shows full row, and visible row full visible rows, including empty. No way to count only items)
TotScrol = (ItemInput(i)/VisibleRow)+0.0001
TotScrolInt = Int(TotScrol) 'Make the number of scrolls an integer (no decimals)
RowScroll = VisibleRow
Iterations = VisibleRow
Dim leftOver ' - how many item lines are after last scroll
leftOver = itemInput-(TotScrolInt)*VisibleRow
'MsgBox(leftOver)
'MsgBox(TotalRow)
'MsgBox(VisibleRow)
'MsgBox(TotScrol)
'MsgBox(TotScrolint)
dim Counter, posNo, textCheck
Counter = 0
posNo = 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").verticalScrollbar.position = posNo
visiblerow_check = visiblerow - 1
textCheck = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/txtVBAP-POSNR[0," & visiblerow_check & "]").text
msgbox(textcheck)
msgbox(visiblerow)
If textCheck <> "" Then
Do
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").verticalScrollbar.position = visiblerow
textCheck = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/txtVBAP-POSNR[0," & visiblerow_check & "]").text
Counter = Counter + 1
msgbox(textCheck)
visibleRow = visibleRow + visibleRow
msgbox(visiblerow)
msgbox(Counter)
Loop until textCheck = ""
End If
VisibleRow = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").visiblerowCount
posNo = Counter * VisibleRow
msgbox(Counter)
msgbox(visiblerow)
msgBox(posNo)
Do
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").verticalScrollbar.position = posNo
textCheck = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/txtVBAP-POSNR[0,0]").text
'Counter = Counter + 1
posNo = posNo + 1
Loop until textCheck = ""
posNo = posNo - 1
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").verticalScrollbar.position = 0
msgbox(posNo)
msgbox(textCheck)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Script Man,
In SAP fields are quite fixed, so I can't really sort it or atleast I do not know how ( I am very new to coding). Also what is difference between determining empty row cout or non empty ones. As far as I know SAP still has to go through each row to see if it is empty or not. The process of checking row by row is what makes it really slow. Too bad there is no command as visiblerowcount or rowcount that just apply for rows with data
BR,
Gedis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.