QTP blog reader Abhijeet has asked here for a way to get total no of rows irrespective of whether the rows are visible or not. I have also faced this problem once while working on a Siebel Application and have written a small piece of code for it.
I would like to reproduce the same code here for the  benefit of QTP community. Please make necessary changes according to the needs of your application.

  1. ' Name: gf_CountTotalRows
  2. ' Description:This function counts the total no of rows irrespective of whether the rows are visible or not
  3. ' Created By:Ankur Jain
  4. ' Variables:sRecordCounter,arrRecordCounter,str,plus,sTotal_Rows
  5. ' Environment Variable:Row_Count
  6. ' Parameters:uiname
  7. '****************************************************
  8. Public Function gf_CountTotalRows(uiname)
  9. 'Variable will contain the (statement) firstset of current no of records
  10. sRecordCounter=SiebApplication("micclass:=SiebApplication").SiebScreen("micclass:=SiebScreen").SiebView("micclass:=SiebView").SiebApplet("micclass:=SiebApplet","uiname:="&uiname).RecordCounter
  11. 'Splitting the variable to get the "+ "sign
  12. arrRecordCounter = Split(sRecordCounter)
  13. 'Storing the 4 member of array(ie the member which contains the + sign)
  14. str=arrRecordCounter(4)
  15. 'Capturing the "+" sign
  16. plus=Right(str,1)
  17. 'Loop to navigate till the last rowset
  18. Do while plus ="+"
  19. SiebApplication("micclass:=SiebApplication").SiebScreen("micclass:=SiebScreen").SiebView("micclass:=SiebView").SiebApplet("micclass:=SiebApplet","uiname:="&uiname).SiebList("micclass:=SiebList").NextRowSet
  20. sRecordCounter=SiebApplication("micclass:=SiebApplication").SiebScreen("micclass:=SiebScreen").SiebView("micclass:=SiebView").SiebApplet("micclass:=SiebApplet","uiname:="&uiname).RecordCounter
  21. arrRecordCounter = Split(sRecordCounter)
  22. str=arrRecordCounter(4)
  23. plus=Right(str,1)
  24. Loop
  25. 'sRecordCounter will contain the last set of current visible no of records
  26. sRecordCounter=SiebApplication("micclass:=SiebApplication").SiebScreen("micclass:=SiebScreen").SiebView("micclass:=SiebView").SiebApplet("micclass:=SiebApplet","uiname:="&uiname).RecordCounter
  27. arrRecordCounter = Split(sRecordCounter)
  28. ' sTotal_Rows will contain the Total No of records in string format
  29. sTotal_Rows=arrRecordCounter(4)
  30. Environment.Value ("Row_Count") = sTotal_Rows
  31. 'Finally to navigate back to the first row set
  32. 'On error resume next 'The next statement works only when the no of rows are greater than visible no of rows
  33. if (Row_Count > 5) then
  34. SiebApplication("micclass:=SiebApplication").SiebScreen("micclass:=SiebScreen").SiebView("micclass:=SiebView").SiebApplet("micclass:=SiebApplet","uiname:="&uiname).SiebList("micclass:=SiebList").FirstRowSet
  35. End if
  36. End function

Related: Tips with QTP
               Tips with Siebel Add-in
               Tips with Oracle/Java Add-in

If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS Feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.

Please use QTP forum for posting QTP questions.