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

can we do load testing , by using QTP......?

1 Answers  


I m new to QTP? Is it necessary to know VB for learning QTP for Automation? Can I understand QTP excellently Without practical automation?

3 Answers  


How to handle Dynamically changing Objects in QTP?

4 Answers  


What is the main differece between QTP 9.0 and 9.2

1 Answers   VeriSign,


I am just a beginner in QTP. Could any one explain me in detail how to automate adding two numbers and getting the result in QTP. Also I would like to parameterize the inputs. I have tried but getting an error like 'Can't use sub.....'(can't recollect the exact error)

2 Answers  






PLS SEND REAL TIMERS, WHAT IS SOA TESTING..IM TRYING 3+ YR.. I HAVE GOOD KNOWLEDGE ON MANUAL TESTING... NOW IM NEW TO LEARN "ETL TESTING" IS BEST OR NOT? BEFORE LEARNING ETL TESTING ANY SKILLS ARE REQUIRED..... AND NOW WHAT IS THE MARKET FOR ETL TESTING... AND IT IS BASED ON PROGRAMMING OR NOT?PLS HELP ME REAL TIMERS IM REQESTING U..... CONTACT ME gan9000@gmail.com

1 Answers  


In key word driven framework,we will rename the logical names of objects,why?

3 Answers   Liquid Hub,


PLS REAL TIMERS WRITE THE ANS FOR THIS? WHICH SCRIPT IS USED IN REAL TIME NOW A DAYS 1)SHARED REPOSITORY BASED SCRIPT 2)DESCRIPTIVE PROGRAMMING BASED SCRIPT?

1 Answers  


1.explain end to end process of qc,2.how many tabs are in qc9.0,qc10.0 3.what is review, how many reviews are following in aproject 4.how will you get the requirements 5.why do we choose testing 6.how to export tc's and requirements to qc through add-ins

0 Answers  


what is Synchronization point in QTP?Can anybody give a perfect example on it Thanks in advance

5 Answers  


Hi, My problem is as follows. I recorded a script that created Object repository of each action i recorded. But later I added one more step (which was to enter data in a textfield) into the script through expert view. But as no repository for this newly added step exists in the test, my script fails. So please help me to sort this problem that how can I create object repository of a new step in an existing test. Thanks everyone

1 Answers  


While recording a login window QTP is identifying only parent window,then how can u identify the child objects.

2 Answers   Symphony,


Categories