Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Re: Iteration Code Logic Help needed
#1
Solved: 11 Years, 4 Months, 4 Weeks ago
Hi,

In this action first half, I am trying to insert values from global datatable and second half inserting values from local datatable. What I am trying to do is in first iteration, insert first row of global datatable and 1 to 3 rows from local datatable. In second iteration, second row of global and 4 to 6 rows of local datatable and so on.

Now with the below code, I am able to run the first iteration well. In the second iteration, it’s inserting second row of global datatable (like I wanted) but its inserting again the 1 to 3 rows of local datatable not 4 to 6 from local datatable. There is something real small to correct but have no idea what to add or what to change. Please suggest. No syntax error or something just the logical error. I kept the code you need to check in bold.



Code:
[b]str_currentIteration = Environment("ActionIteration")[/b]

Browser("Department").Page("Welcome").webedit("USER").Set "user"

Browser("Department").Page("Welcome").WebEdit("PASSWORD").SetSecure "Password"

Browser("Department").Page("Welcome").Image("Login").Click

Browser("Welcome").Page("County Home Page").Link("ADMINISTRATION").Click

Browser("Administration").Page("Search Contracts").webradiogroup("Add/Search Contract").Select "Add"

Browser("Administration").Page("Search Contracts").weblist("Contract").Select "Foster Family Contracts"

Browser("Administration").Page("Search Contracts").webbutton("Submit").Click

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").webedit("Residential Certificate Number").Set DataTable("RFCN",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Fiscal Year").Set DataTable("Contract_Period",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Contract Begin Date").Set DataTable("Contract_Effective",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Contract End Date").Set DataTable("Contract_End",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Facility Name").Set DataTable("Name_of_Facility",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Parent Organization Name").Set DataTable("Name_of_Parent_Organization",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Facility Location Address1").Set DataTable("Facility_Loc_Add1",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Facility Location Address2").Set DataTable("Facility_Loc_Add2",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Facility Location City").Set DataTable("Facility_Loc_City",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").weblist("Facility Location State").Select DataTable("Facility_Loc_State",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Facility Location Zip Main").Set DataTable("Facility_Loc_Zip_Main",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebEdit("Facility Location Zip Extn").Set DataTable("Facility_Loc_Zip_Extn",dtGlobalSheet)

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebCheckBox("Copy Facility Loc to Parent Organization Loc").Click

Browser("Foster Family/Institutional Contract Header").Page("Add Foster Family/Institutional Contract Header").WebButton("Save").Click



[b]str_currentIteration = Environment("ActionIteration") [/b]
(Note: during the first iteration str_currentiteration is 1 but its not incrementing for 2nd iteration)

[b]str_startIteration =(3*str_currentIteration) -2

str_endIteration = 3*str_currentIteration

For i = str_startIteration To str_endIteration

  DataTable.GetSheet("Action1").SetCurrentRow(i)[/b]
  Browser("Add Foster Family Contract").Page("Add Foster Family Classes").WebCheckBox("Performance Based").Set DataTable("PB", dtLocalSheet)

  Browser("Add Foster Family Contract").Page("Add Foster Family Classes").WebEdit("Class").Set DataTable("Class",dtLocalSheet)

  Browser("Add Foster Family Contract").Page("Add Foster Family Classes").WebEdit("Total PerDiem Foster Family Class").Set DataTable("TPD_Foster_Family_Class",dtLocalSheet)

  Browser("Add Foster Family Contract").Page("Add Foster Family Classes").WebEdit("Administrative cost Total PerDiem").Set DataTable("TPD_Admin_Cost",dtLocalSheet)

  Browser("Add Foster Family Contract").Page("Add Foster Family Classes").WebEdit("Title IV-E Allowable Maintenance").Set DataTable("Title_IV_E_Maintenance",dtLocalSheet)

  Browser("Add Foster Family Contract").Page("Add Foster Family Classes").WebEdit("Title IV-E Allowable Admin Costs").Set DataTable("Title_IV_E_Administrative",dtLocalSheet)

  Browser("Add Foster Family Contract").Page("Add Foster Family Classes").WebButton("Insert").Click

[b]Next[/b]

Please help...Thanks in advance
Reply
#2
Solved: 11 Years, 4 Months, 4 Weeks ago
Hi,
Please find the below implemenation logic

Code:
rg=datatable.GetRowCount
ra=datatable.GetSheet(2).GetRowCount
temp=1
For i=1 to rg step 1
    msgbox "temp value"  &temp
    datatable.SetCurrentRow(i)
             gvalue=datatable.Value(1,1)
                  msgbox gvalue
                      For j=temp to temp+2 step 1
                           datatable.SetCurrentRow(j)
                              avalue=datatable.Value(1,2)
                                  msgbox avalue
                      Next
                temp=temp+3    
Next

Thanks,
Venkat.Batchu
Reply
#3
Solved: 11 Years, 4 Months, 4 Weeks ago
Thank you Venkat Batchu. That worked really well.

I have another question for you if you don't mind.
Can we control the no. of rows to be inserted from the local table for the above scenario?
What I mean is, in first iteration, insert first row of global datatable and 1 to 3 rows
from local datatable. In second iteration, second row of global and 4th row of local datatable and in
the third iteration, insert third row of global datatable and 5,6 rows of local datatable and so on. Please let me know.

Thank you for your time and help.
Reply
#4
Solved: 11 Years, 4 Months, 4 Weeks ago
Hi Sratna,
We could do script based on ur requirment ,
but logic will be changed any way i already gave the some part of the logic in the previous post itself so first try to reach ur script with new requirement, if not we can help out...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Object not found during the 2nd iteration of an Action call in a For loop BGunay 0 990 04-23-2020, 07:08 PM
Last Post: BGunay
  UFT Tool runs more than one iteration always cthossain 2 3,826 02-12-2017, 01:25 PM
Last Post: cthossain
  Need a logic in array - QTP surestud 4 3,244 08-20-2015, 02:47 PM
Last Post: cuongtv
  Function return value is not passed during the 3rd iteration premanand1979 0 2,271 10-16-2014, 09:40 PM
Last Post: premanand1979
  VB Script logic Suma Parimal 3 2,805 03-24-2014, 12:56 AM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 1 Guest(s)