We are going to learn how to put values that we will use in our tests on a spreadsheet and then import that spreadsheet as the Global DataTable so that QTP can read in those values instead of using hardcoded values in the test script itself.
Open up an excel spreadsheet.
First write the header for the column User and then put in the value
Ex. Here you see a "USER" column with a value "jeanette"
Now do the same for Password.
Ex. Here you see a "USER" column with a value "jeanette" and a "PASSWORD" column with a value "mercury"
Save your spreadsheet so you can access it from your test script. (Note. If you are using QTP version 11 or before then you need to save it as an .xls file. If you are using UFT then you can save it with a newer format like .xlsx)
In your QTP test script, add the following line of code so that your test will import the spreadsheet as the global datatable. This means if you have several actions in your test then they all can access the global datatable.
At the end of your script add the following line to export the global datatable. I name it something different so it does not override the original.