How do you script a nested loop in QTP?

I am showing a snipet of my code. Any suggestions to help
me get this to work would be great appreciated!

STEP A
- Customer Number: No loop
- ISBN: Loop

STEP B
- Customer Number: Loop
- ISBN: Nested Loop


Here is the code I am using now. I am using i for the loop
and j for the nested loop in STEP B of my script.

===========================================

'CREATE AN ADDITIONAL CUSTOMER

Dim myNum, RowNum, RowCnt2, val2, total, i
DataTable.ImportSheet "C:\QOE Data -
UAT1.xls" ,"Data" ,"Global"
RowCnt2 = DataTable.GetRowCount

i = 1
DataTable.SetCurrentRow(i) ' Set row to one

Do while Not i > RowCnt2

i=i+1

DataTable.SetNextRow

MsgBox Datatable.Value("Customer_Num")
Msgbox i
Msgbox RowCnt2

If Not i > RowCnt2 then
val2=datatable.Value("Customer_Num","Global")

OracleFormWindow("Sales Order").SelectMenu "File->New"

OracleFormWindow("Sales Order").OracleTabbedRegion("Order
Information").OracleTextField("Customer Number").SetFocus

OracleFormWindow("Sales Order").OracleTabbedRegion("Order
Information").OracleTextField("Customer Number").Enter val2

End If

'CREATE SECOND ISBN LIST

DataTable.ImportSheet "C:\QOE Data -
UAT1.xls" ,"Data" ,"Global"

Dim j, RowCnt3, val3

RowCnt3 = DataTable.GetRowCount
For j = 1 To RowCnt3

DataTable.SetCurrentRow(i)
' datatable.getSheet("DataTable").setNextRow

If Trim(DataTable("ISBN",dtGlobalSheet)) = "" Then
j = j - 1
Exit For
End If
Next

'Define ISBN rows
If RowCnt3 <> j Then
RowCnt3 = j
End If

'Loop through ISBN rows

For j = 1 To RowCnt3
DataTable.SetCurrentRow(i)

val3 = Datatable.Value("ISBN","Global")

msgbox j
If j = 1 Then

OracleFormWindow("Sales Order").OracleTabbedRegion("Line
Items").OracleTextField("Ordered Item").SetFocus

OracleFormWindow("Sales Order").OracleTabbedRegion("Line
Items").OracleTextField("Ordered Item").Enter val3

else If j < 16 Then
OracleFormWindow("Sales Order").OracleTabbedRegion("Line
Items").OracleTextField("Ordered Item_"&i).SetFocus

OracleFormWindow("Sales Order").OracleTabbedRegion("Line
Items").OracleTextField("Ordered Item_"&i).Enter val3

else If RowCnt1 => 16 Then
OracleFormWindow("Sales Order").OracleTabbedRegion("Line
Items").OracleTextField("Ordered Item_15").SetFocus

OracleFormWindow("Sales Order").OracleTabbedRegion("Line
Items").OracleTextField("Ordered
Item_15").InvokeSoftkey "DOWN"

OracleFormWindow("Sales Order").OracleTabbedRegion("Line
Items").OracleTextField("Ordered Item_15").SetFocus

OracleFormWindow("Sales Order").OracleTabbedRegion("Line
Items").OracleTextField("Ordered Item_15").Enter val3

end if
end if
End If
Next

'EXIT APP

msgbox i
loop

Browser("Browser").Page("Oracle Applications 11i").Sync
Browser("Browser").Close

==========================================

It isn't working correctly in my nested loop in STEP B (for
ISBN).

Any ideas??

Thanks!
SBsteve


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More QTP Interview Questions

What all challenges you have faced during automation and how you have resolved it?

2 Answers   Genpact,


when u script reveiwing in which area u more concentrates?

0 Answers   IBM,


how to write vbscript on web applications in qtp. explian with one example?

4 Answers   Wipro,


Write a Script With descriptive programming(Without Repository) to update an Update an order in Flight App and verify whether it is done successfully.(Use ChildObjects method)

2 Answers  


how to associate object repository during runtime in qtp

1 Answers   Deloitte,






what is the difference between Reusable action and external action?

2 Answers   HCL,


i want to handle all the unwanted pop up through QTP i done that with recovery scenario but it need some title of pop up but i want that it should handle all the pop up even i don't give the title of that pop up in recovery scenario is there any general way to handle all the pop up please help

3 Answers  


I want two test two agents login for the flight website. Here is the scenario: I want to go through 1-3 rows for one user login and other user login I want to go though 3-5 rows. How would you set this up in qtp. Thank You

0 Answers   IBM,


What are the different types of Database checkpoints in QTP? when they are used?

2 Answers  


What is data driver in qtp?

0 Answers  


To count the no of links present in the yahoo home page i have written the script like this Set fileSysObject=createobject("Scripting.FileSystemObject") Set linksFileName=fileSysObject.opentextfile ("D:\samplelinkfile.txt",2,true) Set linkDescObj=description.Create linkDescObj("micclass").value="Link" Set noOfLinks=browser("yahoo").Page("Yahoo! India").ChildObjects(linkDescObj) For i=0 to noOfLinks.count-1 linkName=noOfLinks(i).getROProperty("name") linksFileName.writeline(linkName) Next linksFileName.close Set fileSysObject=nothing While running the script it showing error that object "yahoo"isnot found in the object repository. Is there any setting before running the script? if yes what is the steps for it.Im using QTP9.0

2 Answers  


wht type of User defined functions or Java Releated functions Do we write in VB scripting

0 Answers  


Categories