Handling a Table Control 

A table control is a control that contains an R/3 table data. It has columns and rows of data.

A table control has the following parts:

The frame box defines the visible portion of the table data on the screen.

Each cell of the table control is considered a control. The information on these controls is in the control structure. The whole table is also a control. Special information on the table control is in the It_TableInfo structure.

Using Table Controls in SAPGUI

The following operations are allowed on a table control in SAPGUI:

A column may be defined as fixed, and then the end user cannot scroll over this column.

Using Table Controls in the GUI Library

The GUI Library provides all the above operations on a table control.

Displaying a Table Control

You display a table control as you would any other control on the screen.

Working with a Table Control

The following steps describe a typical procedure for working with the table control:

  1. Use ItEv_GetControlInfo, with the table control as a parameter, to get the extended information on the table control, such as the number of rows and column in it, or the number of fixed columns it contains. This fills the It_TableInfo structure with the extended table control information.
  2. Change the information in the It_TableInfo structure, if needed. For example, the TabVerScrollbarStartRow determines the first row that is displayed on the screen. To scroll to a particular row, for example, change the value of this parameter to be the number of the row to be displayed as the first row after scrolling.
  3. Use ItEv_SetControlInfo to apply the changes to the It_TableInfo structure.
  4. Send the event to the server with It_SendEvent.
  5. This will send the changes in the It_TableInfo structure to the application server.

  6. Use It_GetEvent if you wish to refresh the screen with new table data.

Example: Scrolling

The following example scrolls in a table control to display row number 5 as the first row. It assumes that control number 16 on the screen is a table.

pEvt->eventtype |= MES_VSCROLL ;

IT_TABLEINFO tbinfo;
int len = ItEv_GetControlInfo(pEvt, ITCTRL_IDX(16),&tbinfo, sizeof(tbinfo));
tbinfo.TabVerScrollbarStartRow = 5;
len = ItEv_SetControlInfo(pEvt, ITCTRL_IDX(16),&tbinfo, sizeof(tbinfo));
if (It_SendEvent(hMr, &pEvt) == FALSE) {
printf("error in sendevent\n");
}

if (It_GetEvent(hMr, &pEvt) == FALSE) {

printf("error in getevent\n");

}

Switching Between Columns

Use the ItEv_SetTableColumnPermutation function to switch between two columns in the table control.

The ItEv_SetTableColumnPermutation function uses an array that stores the order of the columns in the table control. Changing the values in the array changes the order of the columns in the table control.

The following example prompts the user to enter the columns to switch, and then switches between them. It assumes that control number 16 on the screen is a table.

printf("Swap: ");
int a, b, pCols[10];
for (i = 0; i < 10; i++)
pCols[i] = i;
scanf("%d %d", &a, &b);
pCols[a] = b;
pCols[b] = a;
ItEv_SetTableColumnPermutation(pEvt, ITCTRL_IDX(16), pCols, 10);
It_SendEvent(hMr, &pEvt);
It_GetEvent(hMr, &pEvt);

Changing the Width of a Column

Use the ItEv_SetWidth function to change the width of a table control column.