Google Search - Blog...........

SAP ABAP - Table Control - Introduction, Syntax & Example.

A table can be created in transaction. These tables when designed on the screen are called as SCREEN TABLES. These screen tables are of two types viz.
• Table controls
• Step loops
Though these are tables when code is written to handle them, the tables are treated as loops.

Features of Table Controls

• Data is displayed in the form of table when many records match the criteria.
• Table control gives user the feeling of an actual table.
• You can scroll through the table vertically and horizontally.
• You can select rows and columns
• Resize the width of a column
• You can have separator lines in between rows and columns
• Automatic resizing of the table when the user resizes the window.

In general table control includes all the features of an actual table and user gets the feeling that he is actually working with table. You can update information in table control and it can be updated in the database table by writing code for it.

Steps associated for creating complete screen table are as follows:

• Declaration of table control in module pool program.
• Designing of table control on the screen.
• Passing data to table in flow logic.

Declaring of Table Control in the Module Pool Program


Controls TCI type Tableview using screen

When you use table control in a screen you must declare the structure in module pool program. Important fields of tableview are as follows:

• Lines – number of displayable rows in a table.
• Top_line – the row of table where the screen displays start.
• Current_line – The row currently being processed inside a loop.

When you process the table control in flow logic depending upon where you want to start display of rows, you need to use these variables.

Designing Table Control on Screen
• To design table control on the screen, you need to click on Table in control bar and place it on the screen. You can adjust the length and width of table control.
• Name the table control. (Here you need to use same name which you have used for declaration of table control in module pool program)
• From dictionary object, select table fields and place them in the table control.

Passing data to Table Control

As already mentioned, table controls are tables but are treated like loops. Usually transfer of data from program to screen is automatic. But in case of table control, transfer of data is not automatic. You need to explicitly transfer the data to table control. ABAP/4 provides loop statement, which is associated with flow logic to transfer the data. Because table control is treated like a loop, data from where it is transferred should be a loop. You cannot transfer the data by only select statement; you need to put the data into internal table. ABAP/4 provides the LOOP statement, which is associated with the flow logic and allows you to loop through the table control and internal tables. In between LOOP-ENDLOOP, you can use most of the flow logic keywords like field values. Module etc.

You need to code a LOOP statement in both PBO and PAI event of the screen. With LOOP statement, you can transfer the data from program to table control and vice versa. That is, if user updates the value in the table control, you can update database table with its value. And this can be done in PAI event. So even if you are not updating database table through the table control, you need to put the LOOP statement in the PAI event also.


LOOP AT with control cursor

Loop at itab.

Proper usage of Table Control is as follows:

In flow logic.



Considering, we have following fields in table control and the screen looks like this:

In module pool program

CONTROL TC1 Type tableview using screen 200.

Module assign.
Sflight – carrid = itab – carrid.
Sflight - connid= itab - connid.
Sflight - fldate= itab – fldate.

The transfer of the data from program to table control takes place in steps and these steps are as follows:
• With LOOP AT statement the first row is picked up and placed in the header of the internal table.
• Whatever statements you have in between LOOP-ENDLOOP are executed. In this case, you have Module statement. In Module statement, value of internal table is assigned to table control field.
• The row in internal table is transferred to the first line of the table control as stated in the LOOP AT statement.
• The system encounters the ENDLOOP statement and Control is passed to the next line of the internal table.
• In the same way, all the records of the internal table are passed to the table control.

No comments:

Post a Comment