Micro Focus QTP (UFT) Forums
How to append values to the existing datatable in qtp during runtime - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: How to append values to the existing datatable in qtp during runtime (/Thread-How-to-append-values-to-the-existing-datatable-in-qtp-during-runtime)



How to append values to the existing datatable in qtp during runtime - Prashanth - 04-30-2013

Hi,

I have a problem,
I create a datasheet during runtime and add a web table value which contain header and data during runtime,

now i want to add the next set of values/data(header not needed) to the same datatable retaining the previous header/column names and data along with the new data..

Code am using

Code:
With Browser(---).page(---)
            clcnt=.WebTable("class:=dataGrid").ColumnCount(1)                        
    datatable.AddSheet("TempStatusHold")
    For i=1 to clcnt                    
    columnHeader=.WebTable("class:=dataGrid").GetCellData(1,i)                        
    columnVal=.WebTable("class:=dataGrid").GetCellData(3,i)                        
    datatable.GetSheet("TempStatusHold").AddParameter columnHeader,columnVal                        
    Next
    
      datatable.GetSheet("TempStatusHold").SetNextRow
     (or) datatable.GetSheet("TempStatusHold").SetCurrentRow(3)

     For i=1 to clcnt                                    
     columnVal=.WebTable("class:=dataGrid").GetCellData(3,i)                        
     datatable.GetSheet("TempStatusHold").AddParameter " ",columnVal                        
       Next

End With
====================================================
With the above code,,, the new set of data is replacing the the old value

Please suggest ......


RE: How to append values to the existing datatable in qtp during runtime - ravi.gajul - 05-01-2013

Hi,
Please refer to the sample code to add data to a sheet and modify your code accordingly.
Clue: Please see the usage of AddParameter and GetParameter methods
Code:
DataTable.AddSheet("TempStatusHold")
DataTable.GetSheet("TempStatusHold").AddParameter "A","A"
DataTable.GetSheet("TempStatusHold").AddParameter"B","B"
DataTable.GetSheet("TempStatusHold").AddParameter "C","C"
DataTable.GetSheet("TempStatusHold").AddParameter"D","D"
For i=0 to 16
    DataTable.SetCurrentRow(i)
    DataTable.GetSheet("TempStatusHold").GetParameter("A").Value=i
    DataTable.GetSheet("TempStatusHold").GetParameter("B").Value=i
    DataTable.GetSheet("TempStatusHold").GetParameter("C").Value=i
    DataTable.GetSheet("TempStatusHold").GetParameter("D").Value=i
Next

Regards,
Ravi