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 is the registration process and examination fees?

0 Answers  


How to change the Default synchronization method time and where?

4 Answers  


How u will open the build automatically in QTP except using Systemutil.run command

6 Answers  


I have 5 no.of Action in my Test. Out off which i should make 3rd action as my start-up action. How should i make it?

9 Answers   IBM,


How we can merge the object repositories?say if we have 2 or 3 object repositories then how we can merge them?Is there any option in QTP to merge the object repositories?

2 Answers  






In this bellow script QTP is not able to getting no. of Links from my Browser. Set desc=description.create desc("micclass").value="Link" Set obj=Browser("creationtime:=0").page("title:=.*").childobjects(desc) msgbox obj.count I am getting "General Run Error".Why QTP is not supporting my Browser,but its running fine in other system.Please help me to overcome this problem.

1 Answers  


Hello, I am learning QTP. I have recorded test for Login page, i have also inserted checkpoint for Email field & when I run test it passed. But when i tried to run test by inserting 'Adding Parameter Values to a Data Table' for email & password field, it pass the first value in both the fields but after that when test run for second parameter values it displays 'Internet Explorer cannot open the Internet site, Operation aborted' & when i analyze test result it displays run time error 'Object disable'. I have also cleared all the history from IE but it is not working. Please help me. Thank you.

2 Answers  


what is the command (keyboard command) to swith from expert view to key word view

3 Answers  


How to handle the exceptions using recovery secnario manager in Qtp?

2 Answers  


hi testers,one script has three actions , at the of running three actions are running , how to set run only perticular action and what is the use of split the action? when it will be useful?

3 Answers   Syntel,


how can we handle errors other than using recovery scenerios in qtp

0 Answers  


Is there anyway to automatically update the Datasource name in Database Checkpoints object when we migrate tests to a new release?

0 Answers   ADP, CTS,


Categories