Applying sorting and subtotaling to table fields
In this recipe, we will see how we can sort a given table within the Smart Form and calculate totals based on a particular field as the sort criterion. In this recipe, we will use an example of employees and their allowances and amounts.
Getting ready
For this recipe, we define a structure in the database ZST9_EMPLOYEES comprising three fields PERNR, ALLOWANCE, and AMOUNT. We define a table type also based on this structure, as shown in the following screenshot:
A table EMPLOYEE_TABLE (based on the defined dictionary table type) is included in the TABLES tab of the Smart Form interface, and a corresponding work area WA_EMPLOYEE in the global definition.
A table is then created on the Smart Form layout. The loop of the table is shown as follows:
Appropriate texts are created within the cells in order to print the employee number, allowance, and amount values passed. A program is then created and the Smart Form is called. A tabular output is generated...