Micro Focus QTP (UFT) Forums
Write to DataTable - 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 Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Write to DataTable (/Thread-Write-to-DataTable)

Pages: 1 2


Write to DataTable - bgold01 - 04-21-2012

I am fairly new to coding in QTP. I am using a 3270 Terminal Emulator. I would like to copy a defined value on my screen to a datatable that I've imported to run iterations. What code can I put into my Expert View that will allow me to copy a field from the screen to the table?
Thanks.


RE: Write to DataTable - sshukla12 - 04-23-2012

Hi,

get the value fromapplication in any variable using getroproperty, say variable is vb_text. Use the below code to write to data table
Code:
DataTable.Value(ColumnName,datasheetname)=vb_text

Regards,
Sankalp


RE: Write to DataTable - bgold01 - 04-24-2012

Thanks Sankalp. I got a getroproperty statement in my code and the datatable.value statement. the process runs fine and I know the write to the table works when I put the vb_text in quotes, it writes vb_text. However, I can't make the code work to capture the value in the vb_text field. here is the line of code I'm using for getroproperty. if you can please help me assign it to the vb_text value, I'd really appreciate it:

Code:
TeWindow("Window").TeScreen("screen2").GetROProperty("Special Code")
Thanks


RE: Write to DataTable - sshukla12 - 04-24-2012

Hi9,

GetROProperty captures the property of the object at run time, make sure that "Special code" is a property of the object u r trying to find out and use
Code:
vb_text=TeWindow("Window").TeScreen("screen2").GetROProperty("Special Code")

Regards,
Sankalp


RE: Write to DataTable - hamzaz - 04-24-2012

Hi,

I have quite a similar question.
I am using the following code

Code:
numb="123 456 545"
words=split(numb, " ")
For i=lbound(words) to ubound(words)
msgbox(words(i))
  Datatable.Value("Data", dtGlobalSheet)=words(i)
next

Problem is value is saved one by one in A1 cell, so when i run the program the values changes one by one in cell A1 and at the end I just get the last value.

I want to save all the values like
cell A1 123
cell A2 456
etc.

Looking for responses Smile


RE: Write to DataTable - sshukla12 - 04-24-2012

Hi,

Use Datatable .setCurrent row(i) inside the loop.

Regards,
Sankalp


RE: Write to DataTable - hamzaz - 04-24-2012

Hi Thanks for your response,

I am using the following code

Code:
words=split(numb, " ")
For i=lbound(words) to ubound(words)
msgbox(words(i))
Datatable.SetCurrentRow(i)
  Datatable.Value("Data", dtGlobalSheet)=words(i)
  next

Its now setting the values in datatable as long as test is running but when i stop the test it removes all the values at the end of the test


RE: Write to DataTable - sshukla12 - 04-24-2012

Hi,

It will remove the values from data table as test run stops because these values are stored for the run time, if u want tostore these values then save them in seperate .xls file using Excel object and if u want to only view thw output generated then refer to the results _Run time data table.

Regards,
Sankalp


RE: Write to DataTable - hamzaz - 04-24-2012

I can understand now, but I have seen that it is not storing the 1st value, it skips the 1st one and print from the 2nd to last.


RE: Write to DataTable - sshukla12 - 04-24-2012

Hi,

Problem might be related to for loop, debug your code , u can find it out easily.

Regards,
Sankalp