Micro Focus QTP (UFT) Forums
Calling a function using the variable name read from XL - 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: Calling a function using the variable name read from XL (/Thread-Calling-a-function-using-the-variable-name-read-from-XL)



Calling a function using the variable name read from XL - User_Pilot - 11-09-2010

I'm a novice in QTP. Actually, our team is developing a framework for our web application. We just need to confirm something regarding the function call in QTP.

Scenario:

We have myltiple tasks list (which is stored in a xl) which needs to be completed for completing a workflow in our application. We are plaaning to store these tasks as rows in an xl. We need to read this taks to a variable and have to call the function corresponding to that task from the library. The function name will be same as the task name.
i.e let task 1=aabbcc , here we have to call a function names AABBCC() in the script. We are reading the task from XL to a variable Var=AABBCC then we have to call the function AABBCC() Coolwithout using select case(because we have 200+tasks in our system!!Sad )

Can anyone help me out in this?

Thanks in Advance!!


RE: Calling a function using the variable name read from XL - PrabhatN - 11-09-2010

Hi,

At first, import all the data from the excel sheet to the QTP data table. Create a Driver Script action where you will be calling all the actions related to specific task. In the Driver Script action write the following code:

Code:
getTaskCount = DataTable.LocalSheet.GetRowCount
For counter=1 To getTaskCount
    DataTable.SetCurrentRow(counter)
    RunAction DataTable("Tasks",dtLocalSheet), oneIteration
Next

It really doesn't matter how many tasks you have in the data table, it will go on calling the actions as many time as you want Smile

Hope this will help you. Plese write if want further clarifications


RE: Calling a function using the variable name read from XL - User_Pilot - 11-09-2010

Thanks Prabhat. We are just in the planning phase. Once I try this out I'll get back to you. Smile