SAP ABAP Table Control with Examples
Table controls and step circles are objects for screen table presentation that you add to a screen in the Screen Painter.From a programming outlook, table controls and step circles are the very same. Table controls are basically further developed step circles that show information with the look and feel related with tables in work area applications.
Data declarations
DATA:
lt_data TYPE TABLE OF ty_data,
ls_data TYPE ty_data,
wa_tc TYPE scrfname.
Constants for table control
CONSTANTS:
c_col1 TYPE i VALUE 1,
c_col2 TYPE i VALUE 2,
c_col3 TYPE i VALUE 3,
c_col4 TYPE i VALUE 4.
Table control structure
DATA:
BEGIN OF it_field OCCURS 0,
field(10) TYPE c,
END OF it_field.
Screen elements
SELECTION-SCREEN
BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS:
p_exit AS CHECKBOX.
SELECTION-SCREEN
END OF BLOCK b1.
Module to populate data into internal table lt_data
MODULE
populate_data.
ls_data-field1 = 'Value1'.
ls_data-field2 = 'Value2'.
ls_data-field3 = 'Value3'.
ls_data-field4 = 'Value4'.
APPEND ls_data TO lt_data.
ENDMODULE.
PBO module for the screen
MODULE
user_interface OUTPUT.
CALL SCREEN 100.
ENDMODULE.
PAI module for the screen
MODULE
user_interface INPUT.
DATA: lv_row TYPE i,
lv_col TYPE i.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT'.
p_exit = abap_true.
WHEN 'ADD_ROW'.
CLEAR ls_data.
APPEND ls_data TO lt_data.
WHEN 'DEL_ROW'.
READ TABLE it_field INDEX tc_row-col1.
IF sy-subrc = 0.
DELETE it_field INDEX tc_row-col1.
ENDIF.
Take the next step |
WHEN OTHERS.
lv_row = tc_row.
lv_col = tc_col.
CASE lv_col.
WHEN c_col1.
READ TABLE lt_data INTO ls_data INDEX
lv_row.
IF sy-subrc = 0.
it_field-col1 = ls_data-field1.
ENDIF.
WHEN c_col2.
READ TABLE lt_data INTO ls_data INDEX
lv_row.
IF sy-subrc = 0.
it_field-col2 = ls_data-field2.
ENDIF.
WHEN c_col3.
READ TABLE lt_data INTO ls_data INDEX
lv_row.
IF sy-subrc = 0.
it_field-col3 = ls_data-field3.
ENDIF.
WHEN c_col4.
READ TABLE lt_data INTO ls_data INDEX
lv_row.
IF sy-subrc = 0.
it_field-col4 = ls_data-field4.
ENDIF.
ENDCASE.
ENDCASE.
ENDMODULE.
Experience the difference |
Screen 100 with table control
With table controls, the client can:
Look at the table upward and evenly
Re-size the width of a section
Look inside a field (when field contents are more extensive than the field)
Select table lines or segments
Re-request the arrangement of sections
Save the ongoing presentation settings for sometime later
Table controls additionally offer extraordinary designing elements (some programmed, some discretionary) that make tables simpler to check out and utilize. Table Control gives -
programmed table resizing (vertical and level) when the client resizes the window
separator lines among columns and between segments (vertical and level)
section header fields for all segments
One element of step circles is that their table columns can traverse more than one line on the screen. A column of a table control, then again, should constantly be contained in a solitary line (despite the fact that looking over is conceivable).As a general rule, a significant number of the highlights given by the table control are taken care of locally by your framework's SAPgui frontend, so you don't have to program them yourself. The main outstanding exemption for this is vertical looking over.where
Cursor Position for a table control can be set in following ways:
At PBO you can set the cursor on a particular field of a particular line of a table control.
Utilizing the discretionary expansion OFFSET, you can enter the offset of the cursor in the field as portrayed under Setting the Cursor Position.
At PAI you can peruse the ongoing cursor position.
Notwithstanding the data given under Finding Out the Cursor Position, field
The framework variable stepl - contains the ongoing table line record in a circle … endloop. Loopc - contains number of lines apparent in the table
To make a table control
1.Add a table control component to your screen
2.Give a name to the table control. In the ABAP program proclaim a design with something similar ( CONTROLS
3.To make fields go to the Dict./Program fields capability.
Enter the name of the design whose fields you need. (Assuming that you believe it should pick it from word reference of your program click the pertinent puhbutton).
In the field list pick the fields you need and pick alright.In the event that you need a choice segment , check the suitable really take a look at confine the characteristics and give it a name. Make the field in the ABAP program.
In the PBO you ought to have the assertion
It is inside the circles that information move occurs between the screen and the inside table.When you populate the interior table use DESCRIBE TABLE