SmartForms
ABAP DevelopmentBeginner

SmartForm Driver Program Flow

Understand how a driver program prepares data and calls a SmartForm safely.

Explanation

A SmartForm normally should not contain heavy business logic. The driver program is responsible for reading database data, applying business rules, preparing header/item structures and calling the SmartForm function module. The form should mainly handle layout and printing. The most common driver flow is: collect input document number, fetch business data, prepare final form structures, call SSF_FUNCTION_MODULE_NAME to get the generated function module name, then call that function module with control parameters, output options and form data. This separation makes the print output easier to debug and maintain.

Code example

ABAP Code
* Purpose:* Driver program prepares data and calls SmartForm.* SmartForm should focus mainly on layout, not heavy database selection. DATA lv_fm_name TYPE rs38l_fnam.DATA ls_header  TYPE zstr_invoice_header.DATA lt_items   TYPE STANDARD TABLE OF zstr_invoice_item. * Step 1: Prepare all invoice data before calling the formPERFORM fetch_invoice_data  USING    p_vbeln  CHANGING ls_header           lt_items. * Step 2: Get generated function module name for SmartFormCALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'  EXPORTING    formname = 'ZSF_INVOICE'  IMPORTING    fm_name  = lv_fm_name. IF sy-subrc <> 0 OR lv_fm_name IS INITIAL.  MESSAGE 'SmartForm function module could not be determined' TYPE 'E'.ENDIF. * Step 3: Call generated SmartForm function moduleCALL FUNCTION lv_fm_name  EXPORTING    is_header = ls_header  TABLES    it_items  = lt_items  EXCEPTIONS    formatting_error = 1    internal_error   = 2    send_error       = 3    user_canceled    = 4    OTHERS           = 5. IF sy-subrc <> 0.  MESSAGE 'SmartForm output failed' TYPE 'E'.ENDIF.

Real project scenario

An invoice print driver reads billing header from VBRK, billing items from VBRP, customer details from KNA1 and prepares one final structure for the SmartForm instead of letting the form read tables itself.

Common mistakes

- Writing SELECT logic inside SmartForm nodes. - Calling hardcoded generated FM directly. - Not checking sy-subrc after SmartForm call. - Passing raw database tables instead of prepared output structures.

Best practices

- Prepare data in driver program. - Use SSF_FUNCTION_MODULE_NAME. - Pass clean structures to form interface. - Handle SmartForm exceptions.

Interview angle

Interviewers often ask how driver program and SmartForm are connected. A strong answer mentions SSF_FUNCTION_MODULE_NAME and generated FM call.