Automating SAP tables with not unique names
I'm automating an SAP environment for my company in Düsseldorf using HP QuickTest Professional 9.5.
At the moment I have a problem using several tables (SAPGuiTable) in our environment: Some of the tables contain columns with not unique column names (for example 2 times a column "Name"). Is there any possibility to differentiate between them?
To solve this problem I tried the following approches:
Iterate through the columns and read the column names using the following methods:
intCount = SAPGuiSession("Sessionname").SAPGuiWindow("Windown ame").SAPGuiTable("Tablename").ColumnCount()
to read the column count. This method works fine. Afterwards, I tried to iterate through the columns and get the header name. But I could not find any method or property to get the header name.
Use of the
SAPGuiSession("Sessionname").SAPGuiWindow("Windown ame").SAPGuiTable("Tablename").getRowByCellContent ([...])
method using values of both columns (with the same header). Unfortunatly the method did not return an approprite result using a value of the right column.
Read all column headers using the "Columns" property of the table.
The return value is a two dimensional array (as visible in the watch-view). Afterwards, I tried to use this array like this:
For i = 0 To UBound(Columns,2)
If 0 = StrComp(Columns(0,i), "/WantedString/") Then
SAPGuiSession().SAPGuiWindow().SAPGuiTable().Selec tCell 1, "#"&i
But this did not lead to the wanted result, too. The access to the second dimension of the Columns array did raise a type mismatch.
By now, I do not know how to access all columns of a SAPGuiTable if they have not unique names.
Are you able to help me solving this issue?
Thank you in advance.
Re: Automating SAP tables with not unique names
The following solution:
<font class="small">Code:</font><hr /><pre>
intColCount = SAPGuiSession().SAPGuiWindow().SAPGuiTable().Colum nCount
ReDim arrColumns(intColCount - 1)
Set selColumns = SAPGuiSession().SAPGuiWindow().SAPGuiTable().objec t.Columns
For i = 0 to intColCount - 1
arrColumns(i) = selColumns(i).title
Now, you are able to provide an array with all column headers and to match the column title with the column index.