✒️ABAP El chequeo, la prueba y la utilización del Table Painter en los Smartforms
ABAP El chequeo, la prueba y la utilización del Table Painter en los Smartforms
Hoal Compañeros:
Quiero compartir con vosotros estos apuntes, aunque están en inglés.
Tables: Topic Objectives
At the conclusion of this topic, you will be able to:
- Create tables and their line types
- Explain how tables are processed
- Output data in tables
- Create control levels
- Create headers and footers
Tables: Overview
- MAIN Main window
- BOOKINGS Booking table
- Header
- CARRID Beginning of control level
- C_FLIGHT Flight
- C_DATE Date
- C_PRICE Price
- CARRID End of control level
- Footer
Your bookings:
|Flight | Date | Price |CUR|
|AA017 |12/16/2000| 1,200.00 |USD|
|AA017 |12/31/2000| 1,200.00 |USD|
|Sum for AA | 2,400.00 |USD|
|LH400 |11/17/2000| 581.00 |DEM|
|LH402 |11/17/2000| 669.00 |DEM|
|Sum for LH | 1,250.00 |DEM|
|Total | 2,400.00 USD
| 1,250.00 DEM
Forms are frequently used to output data in tables. Tables in SAP Smart Forms are subnodes of windows and are created like all other subnodes using the context menu (right mouse button) of the navigation tree. Since the length of tables is dynamic, you should only use them in main windows since they may be truncated in secondary windows.
You can format the individual line types in the graphical Table Painter. Tables provide functions to output headers and footers, sorting levels, and subtotals.
Before you can fill tables with text, you must determine the table width and define line types on the Table tab of the maintenance screen. By doing this, you specify how many cells a table line should hold and what width these cells should have. (The height is determined automatically.) For simple applications, a single line type is sufficient. However, you can also create different types for hierarchical (multi-level) tables. You do this, for example, if you want to print the bookings for a flight in the next lines or if you want to use subtotals.
In the output options of the table text nodes you specify which line types should be used when. The following information (in addition to the name and description) is required for line types:
- * Default type: You can only mark one type as the default type. If no line type is assigned to a subnode of the table, the system uses the default type.
- * Page protection against page breaks
- * Number and width of the cells
The total width of the table must be identical to the total width of all cells for each line type. You use the horizontal alignment to determine how the table should be aligned with reference to the window margin. You can choose between Left, Right, and Centered. If you choose Left or Right, you can optionally specify a distance from the respective window margin.
The Table Painter
Instead of entering the line types in the table control, you can also define them in the graphical Table Painter. The entries you make in the Table Painter are automatically copied to the alphanumeric representation and vice versa.
You insert a new cell by vertically dragging the pencil-shaped mouse pointer at the desired position while keeping the left mouse button pressed. Alternatively, you can split the cell in which the mouse pointer is positioned using the context menu (right mouse button -> Split -> Cell).
You insert a new line by horizontally dragging the mouse pointer at the desired position. Alternatively, you can use the context menu (right mouse button -> Insert -> Line).
You change the width of a cell by placing the mouse on a cell boundary and dragging the boundary to the desired position while keeping the left mouse button pressed. (The mouse pointer assumes the shape of a double arrow.)
You cannot set the height of individual line types because the height is determined dynamically at application program runtime, depending on the data that is output.
The most important settings (which are basically identical to that of the Form Painter) are displayed in the detachable toolbar of the Table Painter. For further options, choose Utilities -> Settings -> Table Painter tab, or click the right pushbutton of the toolbar.
If the Draw lines and columns checkbox is selected, you can draw the cells of the line types directly with the mouse (as described on the previous slide). If you do not select this checkbox, you can move the table within the window width to the left or to the right - provided you have not chosen Centered as the horizontal alignment of the table.
Several zoom options are available to adjust the display. The most comfortable option is the automatic zoom. To make the drawing of cells easier, you can show a grid and/or the main grid. You can also make a setting in the Table Painter which ensures that vertical cell boundaries are automatically aligned with the grid when you move them with the mouse. You can set the step size of both grids. The crosshair cursor which you can set instead of the normal mouse pointer on the General tab of the Table Painter settings also facilitates the drawing of cells.
The Tracker tab of the Table Painter settings allows you to determine how the table should be highlighted against the background. To hide the toolbar, choose Utilities -> Settings ->Table Painter tab, and deselect the Toolbar checkbox.
Table Patterns
You can define gridlines for the columns and lines of a table. To do this, you select from a number of table patterns. Choose Select pattern on the Table tab. You can also set the line width on the Table tab.
- * Select the pattern you want to use by clicking it with the mouse. You can choose whether the first, the last or all lines should be separated by horizontal gridlines and/or whether the first, the last or all columns should be separated by vertical gridlines. All patterns are available with a border and without a border around them. The selected pattern then appears on the Table tab.
- * You cannot set separate patterns for different line types because the pattern is always applied to the entire table.
From a technical point of view, a table in an SAP Smart Form is filled by processing a specific table called an internal table on a line-by-line basis. This is referred to as a loop. The respective lines can be copied into a work area that has the same structure as the table. The internal table must be filled in the application program (which is the regular case) or in the form. The data is normally taken from database tables. If the data is read in the application program, the internal table must be defined in the interface of the SAP Smart Form.
- * If the internal table is very large, we recommend that you process the table using field symbols instead of a work area since field symbols can directly access the individual lines so that the lines need not be copied.
After defining the table design on the Table tab, you determine how the table should be processed. You do this on the Data tab.
Select the Internal table checkbox and enter a name for the table and for the work area field-symbol. Both the internal table and the work area must be known in the form. This means they must have been defined through the interface or as a global field. If you do not set the Internal table indicator, no loop processing takes place. This makes sense, for example, if you want to output text in parallel columns.
Possible assignment types are into and assigning. If you use into, the lines are copied from the table into the work area. If you use assigning, the lines are assigned to a field symbol. If you want to use tables with header lines, enter the name of the table as the work area.
It is possible to process only a specific line range of the internal table. To do this, specify the lines in the fields Line ... to...
You can also use logical conditions to determine which lines of the internal table should be processed. This corresponds to the WHERE clause of the ABAP command LOOP AT <itab>. Enter the name of a field of the work area, a relational operator and the comparison value. You can use all relational operators that you know from normal selection screens: With/without pattern, Equal to, Not equal to, Greater than or equal to, Greater, Less than or equal to, Less. If you do not enter an operator, Equal to is used automatically. You link several conditions with and; you can also use the OR pushbutton.
In order to output text in tables, you must create at least one text node as a subnode of the table. Table text nodes are "normal" text nodes. This means you can choose the text type (text element, text module, or include text) and you can select New paragraph or New line on the General attributes tab to determine that the text should be written into a new text line. There is one difference, however, on the Output options tab. On this tab, you determine the text output in table lines:
- * Option New line: - This option allows you to select one of the line types for this table line that you defined on the Table tab. If you do not select a line type, the system automatically uses the line type marked as the default type.
- - The new table line is displayed with gridlines - provided you have selected a table pattern for the table.
- * If you select New cell, the text is output in the next cell of the line type. If the line type has no more cells for the system to go to, an error message is issued during program execution. You can also skip several cells. If you select New line, the text is automatically output in the first cell of the line type selected unless you want to skip cells.
- * It is also possible to create other nodes or more than one node in a cell.
- * A table line may extend over two pages at the most.
- * Create a folder for all nodes in a line in the navigation tree to mark them as such. See Unit 7 - Flow Control.
You can sort the internal table within the form. To do this, enter the name of the fields as the Sort criteria to use. The order of the fields in this list determines the sort order. You can change the sort order later by placing your cursor on a field and moving it up or down one line by clicking one of the two black triangles displayed above the sort criteria. Two radio buttons to the right of each field allow you to determine whether the table should be sorted in ascending or descending order.
- * For technical reasons, the system cannot recognize whether the internal table has already been sorted (for example, in the data retrieval program). Hence you must enter the sort criteria and select the Already sorted checkbox. (Otherwise, the table will be sorted again.)
- * Sorting is required for subtotals and subheadings.
Frequently, tables are not output in exactly the same structure in which they are filled. For example, it should be possible to group data records and to output subheadings or subtotals. Grouped data records that have certain identical values are called control levels. SAP Smart Forms allow you to create any number of control levels in a table. In the above example, there is one control level for airline carriers and another for the respective flight connections.
If you select Beginning of control level and/or End of control level for a specific sort criterion, the corresponding control levels are inserted into the navigation tree of the table. A control level contains all records of the internal table that have the same value in the sort field. In the example above, all records of an airline carrier belong to one control level.
You can determine the data to be output at the individual control levels as required because you can insert all nodes that you could also insert as direct subnodes of a table, that is, in particular program lines for subtotals calculation, text nodes for the output of these subtotals, or command nodes for manual page breaks. The node of a control level, called an event node, has only one tab in the maintenance screen, the Output options tab. On this tab, you can make some of the settings that you can define for other subnodes of a table: You can set a style and determine the line type and the cell.
You can define control levels for all sort fields. This means you can set up a hierarchical table that contains, for example, one control level for airline carriers and one for flight connections. You cannot create control levels directly as nodes in the navigation tree. You must always follow the procedure described: Determine the sort criteria and then select the Beginning of control level and/or End of control level checkbox.
- * You can use events to control the output of headers and footers in a table. To do this, you select a header and/or footer on the Events tab of the table node. The corresponding event node then appears in the navigation tree.
- * You can output headers at the beginning of the table and/or after a page break. Similarly, footers can be output at the end of the table and/or before a page break. You must specify a height for the footer to enable the form processor to reserve sufficient space.
- * You use headers for column headings, for example. To do this, create a text node and - if required - select an appropriate line type on its Output options tab.
- * Footers are typically used to output subtotals since footers are not processed before the page break occurs. You calculate subtotals using nodes of the Program lines type. (See Unit 7 - Flow Control.)
- * You cannot create footers and headers directly as nodes in the navigation tree. You must always follow the procedure described for the Events tab.
- * Note that all lower-level nodes are lost if you deactivate a header or footer.
 
 
 
Sobre el autor
Publicación académica de Carlos Piles Rosell, en su ámbito de estudios para la Carrera Consultor ABAP.
Carlos Piles Rosell
Profesión: Analista de Sistemas y Programador - España - Legajo: GZ57B
✒️Autor de: 24 Publicaciones Académicas
🎓Egresado de los módulos:
Disponibilidad Laboral: PartTime
Certificación Académica de Carlos Piles