Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write to DataTable
#1
Solved: 11 Years, 5 Months ago
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.
Reply
#2
Solved: 11 Years, 5 Months ago
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
Reply
#3
Solved: 11 Years, 5 Months ago
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
Reply
#4
Solved: 11 Years, 5 Months ago
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
Reply
#5
Solved: 11 Years, 5 Months ago
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
Reply
#6
Solved: 11 Years, 5 Months ago
Hi,

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

Regards,
Sankalp
Reply
#7
Solved: 11 Years, 5 Months ago
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
Reply
#8
Solved: 11 Years, 5 Months ago
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
Reply
#9
Solved: 11 Years, 5 Months ago
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.
Reply
#10
Solved: 11 Years, 5 Months ago
Hi,

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

Regards,
Sankalp
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Datatable add and datatable import sheet wheelercha 4 33,710 06-14-2012, 04:53 PM
Last Post: Arul

Forum Jump:


Users browsing this thread: 1 Guest(s)