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

How to perform action on objects, If two objects have the almost the same name ? example : Object 1 : "Entry of Items" Object 2 : "Items" Whenever I ask QTP to perform an action on Object 2 it performs action on Object 1. Note: The two objects are present in an Oracle Application tree.

2 Answers   Wipro,


New to QTP: In a qtp flight booking application, I tried to parameterize the to and from drop down lists using data table, depending on ur drop down selection it will pop up a list of flights. Here I am not finding a way to select flight randomly from given list... Thanks in advance guys.

1 Answers  


What is text check point and text area check point?

0 Answers  


What is keyword view in qtp?

0 Answers  


How should I click on the right click menu objects When I trying to add the object properties to the OR.It is showing only Window(Window).Not all the objects of the window. Also while recording I found No script. How to solve this>.

1 Answers  






1 Folders in VSS 2 In navigation script there are 100 script i want to run first 50 and 37th script also not needed to run how to do this 3 What is navigation script,Driver script, business script what we are loaded in this script 4 use of resource tab 5 Difference between verification and validation give real scenario example 6 file scripting object when to use it 7 what are the problems you are faced while testing web application 8 difference between expert view and keyword view 9 difference between QTP 8.2 and QTP 9.2 navigation frame work please answer these questions from real time working people as early as possible

0 Answers  


Explain actions in qtp ?

0 Answers  


what is Defect density, defect leakage, defect age,latentbed,yasid testing, interface

4 Answers   Syntel,


Plze let me know how you can validate in the QTP that printed documents is correctly printed or not ie how we can do the validation that all the records or text are printed successfully in the printed document as per the application format requuired.

4 Answers   MBT,


How to call a test from another test?

0 Answers  


How to add a runtime parameter to a data sheet?

6 Answers  


If 3 browsers are opened in our system, how to enter the facebook url into second browser by using descriptive programing

3 Answers   Mind Tree,


Categories