Micro Focus QTP (UFT) Forums
How to create a Reusable code for Repetitive Reporter.ReportEvent Statements - 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 Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: How to create a Reusable code for Repetitive Reporter.ReportEvent Statements (/Thread-How-to-create-a-Reusable-code-for-Repetitive-Reporter-ReportEvent-Statements)



How to create a Reusable code for Repetitive Reporter.ReportEvent Statements - notknownspammer - 10-02-2014

Hi Everyone,

I need to create a reusable function to update QC step results using QTP.
I am using reporter.ReportEvent then specifying the arguements after each step in QTP script.
After doing this about 7 times I decided that I should create a reusable function to limit the efforts, though a bit concerned because there are so many variables which values differ throughout.

I am having trouble with this code:
Code:
Public Function  fn_StepResult(variable, Vvalue, vmictypeA, vmictypeB, vstepnum, vmessageA, vmessageB)
If variable = Vvalue Then
Reporter.ReportEvent vmictypeA, vstepnum, vmessageA
Else
Reporter.ReportEvent vmictypeB, vstepnum, vmessageB
End If
End Function

The error is:
Type mismatch: 'Reporter.ReportEvent'
Function file: C:\....\....\Desktop\web_methods.qfl
Line (675): "Reporter.ReportEvent vmictypeA, vstepnum, vmessageA".


I am calling this function as:
Code:
Call fn_StepResult(Environment("LVCA"), "3rd Party ID search", "micPass", "micfail", "Step 1", "search preselected / Select 3rd Party ID in search by weblist, and valdiate the list selection is true",  "search preselected / Select 3rd Party ID in search by weblist, and valdiate the list selection is true")

Please help I am facing a deadline and thank you in advance.

Hi Everyone,

I have resolved the issue.

The error was in the Call to the function specifically the values of the variables vmictypeA and vmictypB.

I realized that the micPass and micFail also have boolean values.

micPass = 0
micFail = 1

Therefore I replaced the micPass and micFail values with 0 and 1.
The script worked like a charm.

Though this approach might be unique, I am curios to what others thought of my approach.

I am ope to any suggestions or advice.

Thank you All and Please use this forum only! For QTP related purposes