Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

DataTable Question

This is a discussion on DataTable Question within the QTP forums, part of the Software Testing category; Hey, I'm new to using QTP. I'm working on testing SAP transactions.My question is in regards to DataTables. I'm importing an xls into the Global Sheet and I want the ...

Go Back   Geeks Talk > Software Testing > QTP
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 06-11-2009
Junior Member
 
Join Date: Jun 2009
Location: Michigan, USA
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Davis2sa is on a distinguished road
Thumbs down DataTable Question

Hey,

I'm new to using QTP. I'm working on testing SAP transactions.My question is in regards to DataTables.

I'm importing an xls into the Global Sheet and I want the test to loop through each row of data. The problem is that when the test runs the last row of data imported to the global sheet, it goes back up to the first row (or iteration) and cycles through the data again....This repeats forever. My script looks like this:

DataTable.Import("C:\Documents and Settings\XXXXXXX\Data\My Documents\MaterialNumber.xls")

Do Until DataTable("MaterialNumber") = ""
.....
.......
.........SetCellData 1,"Material", DataTable("MaterialNumber", dtGlobalSheet)
............
..............
.................
....................
DataTable.SetNextRow
Loop

The "MaterialNumber" is not labeled, or parameterized in the global sheet, it doesn't exist until the xls is imported. Everything works fine except that the loop never ends. Perhaps my loop logic is the wrong way to go. I just want to be able to upload a list of data, have the test run through each row, then stop when it has tested all the rows.

Any help is greatly appreciated. Thanks in advance!!!!

Regards,

Shawn
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-11-2009
Expert Member
 
Join Date: Apr 2008
Location: Tamilnadu
Posts: 1,465
Thanks: 15
Thanked 150 Times in 141 Posts
deepasree has a spectacular aura aboutdeepasree has a spectacular aura about
Re: DataTable Question

Hai friend,

select File->Settings-> Run->Run one iteration only

Click on Apply

Click on Ok

Then run the test and let me know

Thanks
Deepa
Reply With Quote
The Following User Says Thank You to deepasree For This Useful Post:
  #3 (permalink)  
Old 06-11-2009
Junior Member
 
Join Date: Jun 2009
Location: Michigan, USA
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Davis2sa is on a distinguished road
Re: DataTable Question

I think it just doesn't ever recognize the "" as a blank row, because it only pulls in the rows that have data in the xls and none of those are blank. I'm going to try to add an "end" as the last row in my xls sheet. Then run the loop until the value = "end"

I think what you suggested will have helped though, because it doesn't re-import the xls every time now.
Reply With Quote
  #4 (permalink)  
Old 06-11-2009
Junior Member
 
Join Date: Jun 2009
Location: Michigan, USA
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Davis2sa is on a distinguished road
Re: DataTable Question

That did it. Thank you very much! Before I changed the "run one iteration" setting I guess it would go back the beginning of the test and re-import the data from the excel sheet and start the process over....

Do you know if there is way to get it to end the loop without having to input "end" at the end of the xls data and test for that? I'm not sure we'll want to have to add "end" at the bottom of every column of data that we test.

Thanks again!
Reply With Quote
  #5 (permalink)  
Old 06-12-2009
Expert Member
 
Join Date: Apr 2008
Location: Tamilnadu
Posts: 1,465
Thanks: 15
Thanked 150 Times in 141 Posts
deepasree has a spectacular aura aboutdeepasree has a spectacular aura about
Re: DataTable Question

hai friend,

Adding end at the end of the column is not at all an apt approach

Use the below code what I have suggested

It will return the number of rows present in the datatable. Your run settings should be select File->Settings-> Run->Run one iteration only. It the datatable row is empty the loop will be automatically get terminated.

Datatable.ImportSheet "C:\Documents and Settings\Deepa\Desktop\ABC.xls"

For i=1 to Datatable.GetRowCount
'Msgbox Datatable.GetRowCount ' Returns number of rows present in the datatable

'your steps here

Datatable.SetNextRow
Next

By using the above code without using "end" your loop will automatically end.

Thanks
Deepa

Last edited by deepasree; 06-12-2009 at 02:17 AM.
Reply With Quote
The Following User Says Thank You to deepasree For This Useful Post:
  #6 (permalink)  
Old 06-15-2009
Junior Member
 
Join Date: Jun 2009
Location: Michigan, USA
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Davis2sa is on a distinguished road
Re: DataTable Question

Thanks so much deepasree!!!! It works great now.
Reply With Quote
Reply

  Geeks Talk > Software Testing > QTP

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
datatable.import rajaputra QTP 3 06-27-2009 05:02 AM
values in datatable thegoro QTP 4 06-01-2009 04:37 AM
How to set cursor on different datatable separately? mkansakar QTP 1 04-27-2009 06:48 AM
Datatable and parameterization newqtp QTP 1 04-11-2008 10:43 PM
Create datatable in memory Geek_Guest C# 2 12-13-2007 01:08 AM


All times are GMT -4. The time now is 02:16 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved