SmartForms
ABAP Developmentintermediate

Smart Forms Part 3: Output Determination and the Print Program Entry

Key takeaway

Connect a Smart Form to SD/MM output control: output types in NACE, processing routines (program, FORM ENTRY, form name in TNAPR), condition records, NAST fields in the driver, return codes, reprocessing with VF31/RSNAST00, and debugging output issues.

Explanation

📌 KEY POINTS
✅ In output control, the output type (e.g. RD00 invoice) has a processing routine: program, FORM routine (ENTRY) and Smart Form name (stored in TNAPR).

✅ The driver's FORM ENTRY USING return_code us_screen receives the output record in NAST (document number in NAST-OBJKY, language, printer, copies).

✅ RETURN_CODE = 0 marks the output as processed successfully; non-zero marks it as failed (visible in the document's output log).

⚠️ Always use NAST-OBJKY and the form name from TNAPR in the driver — never hard-code document numbers or form names.

━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE

Part 2 printed from a report. In SD/MM, printing is triggered by output control, which calls your driver.

━━━━━━━━━━━━━━━━━━━━
▶ 1. OUTPUT TYPE CONFIGURATION (NACE)

  • Application (V3 billing, V1 sales, V2 shipping, EF purchasing) → output type (RD00, BA00, LD00, NEU).
  • Processing routines: medium 1 (print), program ZSD_INVOICE_PRINT, FORM routine ENTRY, Smart Form ZSF_INVOICE.
  • Condition records (VV31 for billing) decide when the output is proposed; dispatch time (e.g. 4 immediately, 1 with RSNAST00 job).

━━━━━━━━━━━━━━━━━━━━
▶ 2. DRIVER INTERFACE FOR OUTPUT CONTROL

  • FORM entry USING return_code us_screen.
  • NAST global (TABLES nast): OBJKY (document), SPRAS (language), LDEST (printer), ANZAL (copies), TDIMMED etc.
  • TNAPR (global structure filled by output control): SFORM = Smart Form name.
  • us_screen = 'X' when called for print preview.

━━━━━━━━━━━━━━━━━━━━
▶ 3. OUTPUT OPTIONS FROM NAST

Map NAST-LDEST → TDDEST, NAST-ANZAL → TDCOPIES, NAST-DIMME → TDIMMED, NAST-DELET → TDDELETE; preview when us_screen = 'X'.

━━━━━━━━━━━━━━━━━━━━
▶ 4. ERROR HANDLING

  • Set return_code = 0 on success, 1 on error.
  • Write messages to the processing log with NAST_PROTOCOL_UPDATE so users see them in the output log.

━━━━━━━━━━━━━━━━━━━━
▶ 5. REPROCESSING

  • VF31 (billing), VL71 (delivery), ME9F (purchasing) — or generically RSNAST00 for outputs with dispatch time 1/2.
  • Repeat output from the document (Extras → Output → Repeat).

━━━━━━━━━━━━━━━━━━━━
▶ 6. DEBUGGING

  • Set breakpoint in the driver's FORM ENTRY; process the output via preview (dialog) — for update-task processing, use the output "Further data" dispatch time and process via VF31 in dialog.

━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP

  1. NACE: display RD00 processing routines and note program, FORM routine and form.
  2. Create a copy of the output type in a sandbox with your driver ZSD_INVOICE_PRINT.
  3. Preview the invoice from VF03 and debug FORM ENTRY.

✅ CHECKPOINT: you can connect a Smart Form driver to output control and handle return codes.

Code example

ABAP Code
REPORT zsd_invoice_print. TABLES: nast, tnapr.                    " filled by output control DATA: gv_retcode TYPE sy-subrc. *---------------------------------------------------------------------** Entry point configured in NACE (processing routine)*---------------------------------------------------------------------*FORM entry USING return_code TYPE sy-subrc                 us_screen   TYPE c.  CLEAR gv_retcode.  PERFORM process_output USING us_screen.  return_code = gv_retcode.             " 0 = processed, else errorENDFORM. FORM process_output USING iv_screen TYPE c.  DATA: lv_fm      TYPE rs38l_fnam,        ls_control TYPE ssfctrlop,        ls_output  TYPE ssfcompop,        ls_header  TYPE zsf_inv_header,        lt_items   TYPE ztt_inv_items,        lv_vbeln   TYPE vbeln_vf. * ===== Document from NAST, form from TNAPR =====  lv_vbeln = nast-objky.  PERFORM prepare_data USING lv_vbeln CHANGING ls_header lt_items.   CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'    EXPORTING formname = tnapr-sform    IMPORTING fm_name  = lv_fm    EXCEPTIONS OTHERS  = 1.  IF sy-subrc <> 0.    PERFORM protocol USING 'E' 'ZSD' '010' tnapr-sform.    gv_retcode = 1.    RETURN.  ENDIF. * ===== Output options from NAST =====  ls_output-tddest   = nast-ldest.  ls_output-tdcopies = nast-anzal.  ls_output-tdimmed  = nast-dimme.  ls_output-tddelete = nast-delet.  ls_control-no_dialog = 'X'.  IF iv_screen = 'X'.    ls_control-preview = 'X'.           " called for print preview  ENDIF.  ls_control-langu = nast-spras.   CALL FUNCTION lv_fm    EXPORTING control_parameters = ls_control              output_options     = ls_output              user_settings      = space              is_header          = ls_header              it_items           = lt_items    EXCEPTIONS OTHERS = 1.  IF sy-subrc <> 0.    PERFORM protocol USING sy-msgty sy-msgid sy-msgno sy-msgv1.    gv_retcode = 1.  ENDIF.ENDFORM. FORM protocol USING iv_ty TYPE any iv_id TYPE any iv_no TYPE any iv_v1 TYPE any.  DATA: lv_msgty TYPE sy-msgty,        lv_msgid TYPE sy-msgid,        lv_msgno TYPE sy-msgno,        lv_msgv1 TYPE sy-msgv1.  lv_msgty = iv_ty. lv_msgid = iv_id. lv_msgno = iv_no. lv_msgv1 = iv_v1.  CALL FUNCTION 'NAST_PROTOCOL_UPDATE'      " shown in the document's output log    EXPORTING msg_arbgb = lv_msgid msg_nr = lv_msgno msg_ty = lv_msgty              msg_v1 = lv_msgv1 msg_v2 = space msg_v3 = space msg_v4 = space    EXCEPTIONS OTHERS = 1.ENDFORM. FORM prepare_data USING iv_vbeln TYPE vbeln_vf                  CHANGING cs_header TYPE zsf_inv_header ct_items TYPE ztt_inv_items.  " selection as in Part 2ENDFORM.

Real project scenario

Invoices printed in English for French customers. The driver called the form with the logon language of the batch user instead of NAST-SPRAS, and the output type's language was ignored.
Setting CONTROL_PARAMETERS-LANGU from NAST-SPRAS and maintaining the French translation of the form fixed it. The team also added NAST_PROTOCOL_UPDATE messages so failed outputs show a clear reason in the output log.

Common mistakes

  • Hard-coding the form name instead of TNAPR-SFORM.
  • Ignoring NAST fields (printer, copies, language).
  • Not setting RETURN_CODE (outputs shown as processed despite errors).
  • No messages in the output log.
  • Dialog popups in output processing (NO_DIALOG missing).

Best practices

  • Use NAST and TNAPR consistently.
  • Map NAST output options to SSFCOMPOP.
  • Set return code and write protocol messages.
  • Support preview via us_screen.
  • Test via document preview, VF31 and RSNAST00.

Interview angle

Questions: "How is a Smart Form linked to output control?", "What is FORM ENTRY?", "How do you reprocess failed outputs?"
Strong answer: NACE output type processing routine with program, FORM ENTRY and Smart Form (TNAPR-SFORM); FORM entry USING return_code us_screen reads NAST (OBJKY, SPRAS, LDEST, ANZAL); map to SSFCOMPOP, NO_DIALOG, preview on us_screen; return_code 0/1 plus NAST_PROTOCOL_UPDATE; reprocess via VF31/RSNAST00 or repeat output.

Practice this lesson

Quick check

1. Which FORM routine does output control typically call in a Smart Form print program?

2. Output is not triggered at all for an invoice. What should be checked before debugging SmartForm layout?

3. Output requests are stored in:

Interview questions

1. What is NAST and how is it linked?

Answer it in your own words first, then compare.

2. Invoice output is not printing. What would you check first?

Answer it in your own words first, then compare.

Practice more with Interview AI →

Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.

More lessons in this topic

Interview questions on this topic

Related SAP topics