SmartForm Tables, Templates and Conditions
Learn when to use tables, templates and conditions in SmartForm layout.
Explanation
SmartForms provide table nodes for repeated item data and template nodes for fixed grid-style layout. Use a table when the number of rows is dynamic, such as invoice items or PO items. Use a template when the layout is fixed, such as a signature block or fixed bank details section. Conditions can control whether a node is displayed based on language, country, company code, item category or business status. Conditions make forms flexible, but too many conditions can make them hard to debug.
Code example
* Purpose:* Driver prepares display flags so SmartForm conditions remain simple.* Instead of writing complex logic in form nodes, calculate flags in ABAP. DATA ls_header TYPE zstr_delivery_print. * Example: show export declaration only for export deliveriesIF ls_header-country_to <> ls_header-country_from. ls_header-show_export_text = abap_true.ENDIF. * In SmartForm condition tab:* IS_HEADER-SHOW_EXPORT_TEXT = 'X' * Why this is better:* Complex business logic stays in driver program.* SmartForm condition remains simple and readable.Real project scenario
A delivery note uses a table node for item lines and a template for fixed signature boxes at the bottom of the page.
Common mistakes
- Using template for dynamic item lines. - Putting complex business logic in form conditions. - Not testing conditions for all languages/countries. - Creating too many nested nodes.
Best practices
- Use table nodes for item loops. - Use templates for fixed layout. - Keep conditions simple. - Prepare display flags in driver program.
Interview angle
A strong answer explains table for dynamic rows and template for fixed layout.