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

unique properties of button,edit box, radio button,check box?

1 Answers   IBM,


How you used DDT in QTP?

1 Answers  


Can anybody give the code for ALL DATATABLE METHODS)(ex: datatable.getrowcount, datatable.getsheet etc....) and ALL DATABASE COMMANDS (like .getcelldata, which are used to retrieve data from a database and from a webtable)with examples.

1 Answers   Accenture,


Why do you create a text checkpoint on a Web application? What is the purpose of the Close method?

0 Answers  


Can someone tel additonal features which has been included under QTP 9.0 which is not there in 8.2 version?

1 Answers  






What are default add-ins in qtp?

14 Answers   Semantic Space,


How do we edit the script in QTP. Anybody can explain in detail..Thanks in advacne...

3 Answers   IBM,


Explain quicktest professional (qtp) testing process?

0 Answers  


I know the Basic QTP. But I wanted to learn descriptive programming in QTP. Without Object Repository how we can develop a script? I wanted to do one real time project using QTP. If you know this type of training is available in pune then let me know the address.

0 Answers  


wt is frame work wt r d different types of frame works used in ur company

1 Answers   Infotech,


What is Parameterizing Tests?

1 Answers   Crea,


what difference between runtime object and text object and what property they have. whether they have same properties or different properties.

0 Answers   Intel, Satyam,


Categories