Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add multiple local datatables to one action?
#1
Solved: 11 Years, 4 Months ago
Hi,
Is it possible to add more than one local datatable for one action.I know if we split that action into two we can create two local datatables. Is there any other way without splitting the action? If yes, please tell me how.

I see by default only global and action1 datatables.
I tried :
DataTable.ImportSheet"C:\Documents and Settings\user\Desktop\12.xls",1,2
DataTable.ImportSheet"C:\Documents and Settings\user\Desktop\11.xls",1,3

only one of the above two statements worked and it inserted data from my excel.
Its not creating another local datatable. Please suggest.

Thanks
Reply
#2
Solved: 11 Years, 4 Months ago
Hi Ratna,

Basically in QTP there will be Design Time Datatable(in QTP window) & RunTime Datatable(in Test Results).
BY default there will be only two Datasheets i.e Global & Localsheets in Design Time Datatable.

Bt If you want to add newdata sheets , you can do that by using "Datatable.AddSheet" method which would be added in RunTime Datatable.

Refer QTP Help for Datatble Methods for more info.
Reply
#3
Solved: 11 Years, 4 Months ago
can i do this? for runtime datatable
Code:
DataTable.AddSheet("12.xls")
DataTable.ImportSheet"C:\Documents and Settings\c-vkanchu\Desktop\12.xls"
If i have to specify parameters, how am i gonna do that
Code:
Datatable. addsheet("12.xls").addparameter("column1", "its value")("column2","its value")
etc
how am i gonna do the above for 10 rows and 10 columns.

also in my script do i have to give like this
Code:
Browser("").Page("").webedit("").Set DataTable("RFCN",dtLocalSheet)
even for runtime datatable data if RFCN is a column in my runtime datatable?

how do i get the rowcount just like the global/local datatable?
Code:
GlobalRowCount=datatable.GetSheet("Global").GetRowCount
ActionRowCount=datatable.GetSheet("Action1").GetRowCount
what would i give in place of Global and Action1??? if its a runtime datatable?

I am new to QTP. so, Please be patient with me

Thanks in advance.
Reply
#4
Solved: 11 Years, 4 Months ago
Hi Ratna,

Yes, you can add datasheets to Runtime Datatable.

Syntax
DataTable.AddSheet(SheetName)

Example:
Code:
Datatable.AddSheet("xxxx")

Datatable.Importsheet Imports a sheet of a specified file to a specified sheet in the run-time Data Table. The data in the imported sheet replaces the data in the destination sheet
Syntax :
DataTable.ImportSheet(FileName, SheetSource, SheetDest)

Example:
Code:
Datatable.Importsheet "C:\doc & Settings\sample.xls","Sheet1","xxxx"


For Adding parameters you can use "AddParameter" method:
"AddParameter" method Adds the specified parameter (column) to the sheet in the run-time Data Table.
Syntax
DTSheet.AddParameter(ParameterName, Value)

Example :
Code:
DataTable.GetSheet("xxxx").AddParameter "Place","INDIA"

"also in my script do i have to give like this
Browser("").Page("").webedit("").Set DataTable("RFCN",dtLocalSheet) even for runtime datatable data if RFCN is a column in my runtime datatable?"
--> You can give as below
Code:
Browser("").Page("").webedit("").Set DataTable("colname","xxxx")

[color]"how do i get the rowcount just like the global/local datatable?
what would i give in place of Global and Action1??? if its a runtime datatable?"--> [/color]You can give as below:

Code:
NewsheetRowcount=datatable.GetSheet("xxxx").GetRowCount

Finally, for your [color]"how am i gonna do the above for 10 rows and 10 columns"[/color] question use the below code & execute, check the test results for RunTime Datatable.

Code:
Datatable.AddSheet"xxxx"
    For i=1 to 10
         Datatable.GetSheet("xxxx").AddParameter "Col"&i,""
    Next
  
    For j=1 to 10
      Datatable.GetSheet("xxxx").SetCurrentRow(j)
           For k=1 to datatable.GetSheet("xxxx").GetParameterCount
                 Datatable.Value("Col"&k,"xxxx")="Value of"&"Row"&j&"Col"&k
           Next
    Next
  
   msgbox Datatable.GetSheet("xxxx").Name&" : "&Datatable.GetSheet("xxxx").GetRowcount
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Local System Monitor kbhargava505 0 2,522 10-16-2015, 12:52 PM
Last Post: kbhargava505
  Case changes while reading values from inbuilt datatables krishnakittu03 3 2,964 04-28-2015, 11:34 AM
Last Post: kbhargava505
  How to Create and use local repository Sourabh146 2 2,542 01-28-2014, 10:56 PM
Last Post: jacosta
  how to access Local dataTables in another action within a same script RA185112 5 6,037 07-25-2012, 01:27 PM
Last Post: sshukla12
  Update from Local repository DeeptiNR 4 5,051 04-10-2012, 07:29 AM
Last Post: DeeptiNR

Forum Jump:


Users browsing this thread: 2 Guest(s)