Micro Focus QTP (UFT) Forums

Full Version: How to get the total no. of columns used for a particular row
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
my code says .
DataTable.SetCurrentRow (2)
now i need to retrive the total number of column used in 2 nd row ..
is there any syntax
what is the substitute of "ddt_get_parameters" used in Winrunner in QTP ..

please reply asap
Hi Swetha,

For retrieving the columns(Parameters) count in datatable, check the below code.

Code:
datatable.GetSheet("Sheetname").GetParameterCount

Try it n See .... u will get the columns count for any sheets in datatable easily...


Regards,
Sreekanth CR
sreekanth.chilam@gmail.com
Hi Sreekanth ,
This code retrives total column count of the sheet .
I want to retrieve column count of just 1 particular row ..
suppose i have 3 row .. 1 row has 6 colunm and 2 nd one has 3
third one has 4 .. so how to retrive the column count of 2nd row
please reply asap
Hi Sreekanth ,
This code retrives total column count of the sheet .
I want to retrieve column count of just 1 particular row ..
suppose i have 3 row .. 1 row has 6 colunm and 2 nd one has 3
third one has 4 .. so how to retrive the column count of 2nd row
please reply asap
Code:
Dim rc,cc
rc=datatable.GetRowCount
msgbox rc

For i=2 to 2
    cc=datatable.GetSheet("Global").getparametercount
    msgbox cc
Next
HI Swetha,

I wrote one user defined function which takes requires row number as an Input argument/Parameter.

1. Refer the below function defination :

Code:
Function Column_Count_Retrieve(Rownumber)
     Datatable.Getsheet("Global").SetCurrentrow(Rownumber)
     Temp=0  
            Col_Count=Datatable.GetSheet("Global").GetParametercount      
                 for j=1 to Col_Count
                         Val=Datatable.GetSheet("Global").GetParameter(j).Value
                               if Val<> "" then
                                     Temp=Temp+1
                               end if
                  Next
      msgbox   "Row  " &Rownumber&"   :   "&Temp&" rows"
End Function

2. Call the above function as given below :

Call Column_Count_Retrieve(3) ' Calling the function for finding the no. of columns used by 3rd Row
Call Column_Count_Retrieve(1) ' Calling the function for finding the no. of columns used by 1st Row
Call Column_Count_Retrieve(2) ' Calling the function for finding the no. of columns used by 2nd Row

I hope now your requirement has been solved.
Hello bfakruddin , i guess you need to change the code. Smile
Sorry,
I have check only 2nd column, not for all rows... Sreekanth given beautiful code...
You can use that...
Code:
datatable.columncount(rows)

webtable.columncount(rows)