Micro Focus QTP (UFT) Forums
Passing Values between Datasheets - 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: Passing Values between Datasheets (/Thread-Passing-Values-between-Datasheets)



Passing Values between Datasheets - D2010 - 03-30-2011

Say I have a QTP script which contains several reusable actions. The Global Datasheet contains a few parameters that are used by the other actions. So I want to pass these parameters between the actions’ datasheets. So logically I followed basic Excel functionality and did a point and click from one of the local datasheets to the global datasheets cell that I require. This works giving the following formula =Global!A1

A1 being the cell that I wanted to get the value of (i.e. Column A, Row 1).

However I will be reading in the Global Datasheet and the column headings may or may not reflect the “A” title. Therefore is it possible to re-write this formula (=Global!A1) so that it takes the column title that I have created in QTP? Eg. pUsername.

I logically tried to just do the following, but QTP did not like these:
=Global!”pUsername”1
=Global!pUsername1

I am looking for a solution to the above rather than alternative solutions, as I do have reasons for wanting to do it this way and I am aware that I could just take the parameter values from within the action.
Any help would be greatly appreciated.


RE: Passing Values between Datasheets - tdevick - 03-30-2011

If I understand correctly, you have a data sheet cell with the name "pUsername" and it contains the formula "Global!A1". You want to read this value and change it to "Global!pUsername". Is that correct?
Code:
DataTable.GetSheet("Global").GetParameter(i).Name

where "i" is a cell index. So if you want to get the name of cell 1 of the current row in a datasheet, you would do this:

Code:
cellName=DataTable.GetSheet("Global").GetParameter(1).Name

assuming the title of cell #1 in row x in the global sheet of your data table has title "pUsername", if I understand you correctly, you would do this:

Code:
formula=DataTable(1, dtGlobalSheet) ' returns the string "Global!A1"
tempTable=split(formula, "!")
newFormula=tempTable(0) & "!" & cellName ' returns "Global!pUsername"

Is this what you were looking for, or am I misunderstanding your goal?


RE: Passing Values between Datasheets - D2010 - 03-31-2011

Thanks tdevick, but thats not quite what I am looking for. This is what I have done:

1. In the Global Datasheet I have renamed column 'A' to 'pUsername'.
2. In the Local Datasheet of my action I have selected cell A1 (column 1, Row 1).
3. I then enter '=' into that cell, then go to the global datasheet and select cell one of the column 'pUsername' and the press enter.
4. A formula is generated automatically by QTP which is '=Global!A1'.

So my localsheet is now reflecting the contents of the globalsheet, which is what I desire...

But I don't want the formula to be A1, I want it to be pUsername1. As the "A" aspect may not always be true as I may have other global parameters so it could be B1, C1 etc.

So I am looking to see if their is a way to reword the formula within the datasheets cell to have 'pUsername' instead of using 'A'.

Hope this helps make my goal more clear.


RE: Passing Values between Datasheets - Suba - 03-31-2011

This is an interestinging Question.

Experts, please correct me if I am wrong, I believe "pUsename" is a LABEL used within a particular Datasheet and is always located on the First Row of the datasheet / Worksheet in Excel. QTP logically interprets it as a Column Name instead of using Excel Column Name.

If you try to open the Excel Doc externally, you will be able to view my explanation. Hence '=Global!A1' is correct the value is being worksheet "Global" Cell "A1". I believe Excel will not recognize as Column "A" unless you rename the Column naming convention within Excel.

Experts, please pitch in your comments if I am wrong. I would also like to understand the internal to this.

Thanks,
Subha


RE: Passing Values between Datasheets - basanth27 - 03-31-2011

Suba -
Yes. That is correct. However, i still have hunch that it could be a possibility and i have been looking through excel forums to see if we can make it happen. One of the shortcomings of datasheet trying to clone excel.


RE: Passing Values between Datasheets - Suba - 04-01-2011

Thanks Basanth.

There was typo in my previous reponse. Correction as below.

If you try to open the Excel Doc externally, you will be able to view my explanation. Hence '=Global!A1' is correct the value is being worksheet "Global" Cell "A1". I believe Excel will not recognize as Column "A" unless you rename the Column naming convention within Excel.


CORRECTION:
If you try to open the Excel Doc externally, you will be able to view my explanation. Hence '=Global!A1' is correct the value is being worksheet "Global" Cell "A1". I believe Excel will not recognize as Column "pUsename" unless you rename the Column naming convention within Excel.

Thanks,
Suba