Skip to Content

How to get Column Name from GUITREE Control


We are using SAP Screen Personas 3.0 / SP07 with WEBGUI. In one of the scripts, we need to get values from couple of columns of the selected row, I have been able to do that using absolute column position (..elementAt(3), ..elementAt(5) etc). However, the script fails when the layout changes as the columns have different positions now. I need some help in understanding what possibilities exist for handling this situation. Is there a way to know column position in current layout based on column name? Appreciate all the help!


Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Feb 26, 2019 at 04:23 PM

    Hi Sudhir,

    It can be a bit complex, but this code should help. This is a guide and you will have to adapt for your specific requirements.

    You will have to use an if statement to look for the column name you need (i.e. J_STMAIN-ANWS). This should get you going:

    var table = session.findById("wnd[0]/usr/tabsTABSTRIP_0300/tabpANWS/ssubSUBSCREEN:SAPLBSVA:0302/tblSAPLBSVATC_E");
    //Read Table Contents
    function getTableContents(zStatusTable)
     session.utils.log('==================================== Read Table Contents Function ===============================');
     session.utils.log('zStatusTable.firstVisibleRow =>' + zStatusTable.firstVisibleRow);
     session.utils.log('zStatusTable.visibleRowCount =>' + zStatusTable.visibleRowCount);
     session.utils.log('zStatusTable.rowCount =>' + zStatusTable.rowCount);
     var zcolumns = zStatusTable.columns;
     var colCount = zcolumns.length;
     for(var x=0; x < colCount; x++)
     	session.utils.log('column(' + x + ').name => ' + zcolumns.elementAt(x).name);
     for(var zRow=0; zRow < 3; zRow++)
     	for(x=0; x < colCount; x++)
      		session.utils.log ('data at row(' + zRow + '), column(' + x + ') =>' + zStatusTable.getCellValue(zRow, zcolumns.elementAt(x).name));

    If you have more rows then is displayed on the screen you will need additional code to scroll the rows. If you need this code, let me know and I can provide that too.



    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Brian,

      Thank you for your response. I am dealing with GuiTree control and the columnName collection seems to be different from the columns collection for GuiTableControl ( zcolumns ).

      However, building upon what you provided, was able to find the column names as C1 C2 etc... ( I was looking for column titles earlier) and they appear to remain consistent irrespective of the position.

      Your help is much appreciated!!


      Sudhir Baxi

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.