Saturday, March 15, 2008

SCREEN ELEMENTS ANDTABLE CONTROLS:

A table control is an area on the screen in which the system displays data in tabular form. It is processed using a loop. The top line of a table control is the header line, which is distinguished by a gray separator.

Within a table control, you can use table elements, key words, templates, checkboxes, radio buttons, radio button groups, and pushbuttons. A line may have up to 255 columns; each column may have a title.

You can display or enter single structured lines of data using a table control.

Features:
Resizeable table for displaying and editing data.
The user or program can change the column width and position, save the changes, and reload them later.

Check column for marking lines. Marked lines are highlighted in a different color.
Line selection: Single lines, multiple lines, all lines, and deselection
Column headings double as pushbuttons for marking columns.
Scrollbars for horizontal and vertical scrolling.
You can fix any number of key (leading) columns.
Cell attributes are variable at runtime.

Users can save display variants for table controls. These variants can be saved by each user, along with the basic setting, as the current display setting or as the default display setting.

The table control contains a series of attributes that are controlled entirely at the presentation server:
These are:

Horizontal scrolling using the scrollbar in the table control
Swapping columns
Changing column widths
Marking columns
Marking lines

The PAI processing block is triggered when you scroll vertically in the table control or save the user configuration.

As well as the normal "Object name", "Start position on screen" and "Static size" attributes, table controls also have special table control attributes.

The "Special table control attributes" determine the table type and display options for a table control, as well as whether it can be configured by the user. The fields stepl and loopc of structure syst contain information about the loop processing used with table controls (see following pages).

For further information about the static attributes, refer to the online documentation.

When you create a table control, you must create:

A table control area.
Table control fields.

To create a table control area, choose the table control object from the object list in the Screen Painter and place it in the screen work area. Fix the top-left hand corner of the table control area, and then drag the object to the required size.

In the "Object name" attribute, assign a name to your table control. In the ABAP program, declare a structure with the same name, containing the dynamically changeable attributes of the table control.

The CONTROLS statement declares a complex data object with the type TABLEVIEW
(corresponding to the type CXTAB_CONTROL, declared in type group CXTAB in the ABAP
Dictionary). At runtime, the data object (my_control) contains the static attributes of the table control.

You maintain the initial values (static attributes) in the Screen Painter. The USING SCREEN addition in the CONTROLS statement determines the screen whose initial values are to be used for the table control.

You can reset a table control to its initial attributes at any time using the statement REFRESH CONTROL FROM SCREEN . does not have to be the same as the initial screen of the table control.

You create fields in a table control using the Dict./Program fields function. This involves the following steps:
Enter the name of the structure whose fields you want to use in the table control and press ENTER.

In the field list, choose the fields that you want to use and choose OK.
Position the cursor in the table control area and click the left mouse button.
The system places all of the selected fields in the table control. If the fields have data element texts, the system uses these as column headings.

Alternatively, you can position individual input/output fields in the table control area, each of which generates a single column.

When you create a table control, the system automatically proposes one with a selection column.

The selection column behaves like a checkbox. It must therefore be a field with length 1 and data type CHAR. You must enter the field name in the attributes of the table control.

The selection column is a field of the structure used for transport between the screen and the ABAP program.

The runtime attributes of a table control, which are stored in the structure declared using the CONTROLS statement, can be divided into general attributes and column attributes.

The general attributes contain information about the attributes of the table control as a whole, such as, for example, the number of fixed columns.

The column attributes are stored in an internal table (one entry per column of the internal table).

For each column, it maintains the attributes stored in the structure SCREEN, plus the special table control column attributes column position, a selection and a visibility flag, and a field for the displayed width.

For information about the names of the attributes and their precise meanings, refer to the keyword documentation in the ABAP Editor for the CONTROLS statement (then choose Tableview -> CXTAB_CONTROL).

You can change a table control dynamically by modifying the contents of the fields in the table control structure declared in your program.

The fields of the table control structure also provide information about user interaction with the table control. For example, you can use the selected field to determine whether the user has selected a particular column.

For performance reasons, you read the data for the table control once from the database and store it in an internal table using an array fetch.

The system fills the table control lines from this internal table.

Before you can display data from an internal table in a table control, you must first fill the table. Make sure that you do not fill the internal table in every PBO event, but only when the key fields change (in the above example, airline and flight number).

For the table control processing, you need to know how far the user can scroll vertically (the size of the internal table). You should therefore use the DESCRIBE TABLE statement to find out the number of entries in the internal table, and save this in the LINES field of the table control.

There is only one work area for processing lines in the table control. For this reason, you need a LOOP … ENDLOOP. structure in both the PBO and PAI events for each table control.

In the PBO processing block, you must fill one line of the table control with the corresponding line from the internal table in each loop pass.

Similarly, in the PAI processing block, you must pass the changes made in the table control back to the correct line of the internal table.

When you process functions, you must distinguish between those that should only apply to individual lines of a table control, and those that should apply to the entire screen.

There are three steps involved in displaying buffered data from the internal table in the table control:

The system loops through the lines of the table control. The lines of the screen table are processed one by one. For each line, the system carries out the following steps:

The current line of the internal table is placed in the work area of the internal table. (Note that it is possible to scroll in the table on the screen.)
The data from the work area of the internal table is copied into the relevant line of the table control.

When you use table controls on a screen, the field transport sequence changes.

In the PBO processing block, data is transferred from the ABAP program to the screen after each loop pass in the flow logic. The rest of the screen fields are filled, as normal, at the end of the PBO.

The loop statement in the flow logic LOOP AT INTO WITH CONTROL starts a loop through the screen table, and reads the line of the internal table corresponding to the current line of the screen table, placing it in .
is the name of the internal table containing the data, is the name of the work area for the internal table, and is the name of the table control on the screen.

If the fields in your table control have the same structure and name as those in the work area , the system can transport data between the ABAP program and the screen automatically (step 3).

If you are not using the same structure for the table control fields and the work area of the internal table, you must call a module between LOOP and ENDLOOP that moves the data from the work area into the screen fields (MOVE-CORRESPONDING TO …) .

The system calculates the value of -TOP_LINE when you scroll, but not when you scroll a page at a time outside the table control.

Transferring changed values from the table control back to the internal table involves the following three steps:

The system loops through the lines of the table control. The lines of the screen table are processed one by one. For each line, the system carries out the following steps:

The data from the current line of the table control is copied into the header line of the internal table.

The data in the work area must then be placed in the line of the internal table corresponding to the line of the table control that is being processed. (Note that it is possible to scroll in the table on the screen.)

In the PAI processing block, all screen fields that do not belong to a table control and that are not listed in a FIELD statement are transported back to the work fields in the ABAP program first.

The contents of the table control are transported line-by-line to the corresponding work area in the ABAP program in the appropriate loop.

Lastly, the fields that occur in FIELD statements are transported directly before the corresponding statement.

The LOOP AT . ... ENDLOOP block processes a loop through the lines of the table on the screen.

If the fields on your screen have the same names as the fields in the internal table, you must return the data from the header line of the internal table to the body of the table itself. You do this using the field -current_line.

If the fields on your screen do not have the same names as the fields in the internal table, you must first copy the data into the header line of the internal table. You can then copy the data back into the internal table itself. You can also use the field -current_line to do this.

You can modify the attributes of a table control by overwriting the field contents of the structure created in the CONTROLS statement.

To change the attributes of individual cells temporarily (!), change the table SCREEN in a PBO module that you processes between LOOP and ENDLOOP in the flow logic (LOOP AT SCREEN, MODIFY SCREEN).

In the LOOP, the runtime system initializes the attributes set statically for the table control in the Screen Painter. You can only change these in a module called from a loop through the table control.

You can change a table control dynamically by modifying the contents of the fields of its structure.

The fields of the table control structure also provide information about user interaction with the table control. For example, you can use the selected field to determine whether the user has selected a particular column.

It is possible to change the attributes of table control fields temporarily. These changes are only effective while the current screen is being processed.

To do this, you call a module from within the table control loop in the flow logic, in which you change the attributes of the current line.

To change the attributes of the fields of a line in the table control, use a LOOP AT SCREEN. ... ENDLOOP. block to loop through the fields of the current line. Within this loop, you can change the attributes of the fields of the current line of the table control.

You can easily sort the table control display by a particular column using the table control attribute -selected and -screen-name

You can scroll a page at a time in a table control using the table control attribute
-top_line.

In the PAI processing block, you need to know the current number of lines in the corresponding table control.

The system field sy-loopc contains the number of table control lines in the PBO processing block. However, in the PAI, it contains the number of filled lines.

Sy-loopc is only filled between LOOP and ENDLOOP, since it always refers to the current loop.

The LINE parameter in the GET or SET statement refers to the system field sy-stepl, the special loop index in the flow logic.

You calculate the internal table line that corresponds to the selected table control line as follows:

Line = -TOP_LINE + cursor position - 1.

The GET CURSOR statement sets the return code as follows: sy-subrc = 0. The cursor was on a field. sy-subrc = 4: The cursor was not positioned on a field.

If you use a step loop on your screen, you can place the cursor on a particular element within the step loop block. To do this, use the LINE parameter and enter the line on which the cursor should be positioned: SET CURSOR FIELD LINE .

You can also use the OFFSET and LINE parameters together.

No comments:

Blog Archive