cancel
Showing results for 
Search instead for 
Did you mean: 

How Fetch Highlighted Rows from a SAP Table

_Ikuta01
Discoverer
160

Hi,

Just wanted to ask how to fetch data rows from SAP table (type of GuiTableControl).

I want to fetch the values for the highlighted/selected rows only and save it to a DataTable.

Example of the reference SAP Table where I only want to grab the data for row 2 & 3 (the selected rows).

_Ikuta01_1-1729060094735.png


But I don't know what property to achieve the "IsHighlighted" logic below.

using System;
using System.Data;
using SAPFEWSELib;

class Program
{
    static void Main()
    {
        GuiTableControl SapTable = (GuiTableControl)session.FindById("your_tablecontrol_id");

        DataTable selectedRowsTable = new DataTable();
        selectedRowsTable.Columns.Add("Column1", typeof(string));
        selectedRowsTable.Columns.Add("Column2", typeof(string));

        for (int rowIndex = 0; rowIndex < SapTable.RowCount; rowIndex++)
        {
            if (IsHighlighted(rowIndex))  // Todo: How to detect if highlighted
            {
                DataRow newRow = selectedRowsTable.NewRow();
                newRow["Column1"] = SapTable.GetCellValue(rowIndex, "Column1");
                newRow["Column2"] = SapTable.GetCellValue(rowIndex, "Column2");
                selectedRowsTable.Rows.Add(newRow); // Add only highlighted rows
            }
        }

        foreach (DataRow row in selectedRowsTable.Rows)
        {
            Console.WriteLine($"{row["Column1"]}, {row["Column2"]}");
        }
    }

    
}

 

Accepted Solutions (0)

Answers (1)

Answers (1)

FrankKrauseGUI
Product and Topic Expert
Product and Topic Expert

Hi,

GuiTableControl organizes the rows in a collection of objects of type GuiTableRow.
See also:
https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/ce1d9e64355d49568e5de...

Each of the rows is an object in this collection and has properties like "Selected". See also: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/5341bac75c8d428eb8460...

Best regards,
Frank