Micro Focus QTP (UFT) Forums
Function return value is not passed during the 3rd iteration - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Function return value is not passed during the 3rd iteration (/Thread-Function-return-value-is-not-passed-during-the-3rd-iteration)



Function return value is not passed during the 3rd iteration - premanand1979 - 10-16-2014

Hello guys,

I have a function to get data table values for my test, based on the function return value (True or False), I am doing subsequent actions. The function return value is getting passed successfully for the first two runs and it returns a empty value during the 3rd run. The return value of the function is maintained until it comes out of the function.

Please see below the example function call and code. The first two function calls Apple and Orange are working fine. Test is failing for the third functional call Banana.

Call Sample_Function(1,"Apple")

Call Sample_Function(2,"Orange")

Call Sample_Function(3,"Banana")

Code:
Function Sample_Function(RowId,SearchCriteria)
Dim DataStatus
DataStatus = Retrieve_Excel_Data(RowId)
If DataStatus = True Then 'It returns a empty value during 3rd run
  Msgbox "Sucess"
Else
  Msgbox "Failed"
End If
End Function

Function Retrieve_Excel_Data(RowId)
Dim XlsStatus, Source, Target, RowCount
XlsStatus = False
DataTable.AddSheet(Target)    
DataTable.ImportSheet "C:\a.xls", Source, Target
RowCount = DataTable.GetSheet(PO_Target_SheetName).GetRowCount
If RowCount < 1 then
XlsStatus = True
Retrieve_Excel_Data = XlsStatus
Else
Retrieve_Excel_Data = XlsStatus
End If
End Function