ERPClimb logoERPClimb
SAP function moduleObjectEND_FORMModuleABAP

END_FORM — End the Current SAPscript Form Instance

Ends the currently active SAPscript form instance within an output session but does not necessarily close the overall spool/form session. It is useful when several SAPscript form instances are produced between one OPEN_FORM and CLOSE_FORM lifecycle. The surrounding output session remains active until the corresponding CLOSE_FORM call finishes it.

Practitioner reference for END_FORM, including the real runtime boundary, important interface concepts, failure handling, lifecycle requirements, and S/4HANA guidance. Exact target-release parameter typing remains anchored to SE37 rather than copied from an unrelated release.

Published 20 Sept 2026· 667 words

What it does

Ends the currently active SAPscript form instance within an output session but does not necessarily close the overall spool/form session. It is useful when several SAPscript form instances are produced between one OPEN_FORM and CLOSE_FORM lifecycle. Use it only inside the runtime it was designed for: frontend, application server, spool, form composer, SAPoffice, or Application Log. The function does not automatically provide the business authorization, retention, content security, or transaction semantics of the application that calls it.

Important parameters

The page records only high-value interface elements. Exact typing, optional flags, and table structures must be taken from the active SE37 signature before implementation because these classic Basis/ABAP services have accumulated release-specific options.

  • No large business interface is involved; it finalizes the active form state before another START_FORM or the final CLOSE_FORM.
  • Use DDIC-typed structures and binary/text tables that match the function documentation; do not substitute similar-looking generic CHAR tables.
  • For file, spool, form, email, or log processing, carry the returned identifier/handle forward rather than trying to reconstruct it later.

Exceptions

Technical failures in these services are usually actionable and should not be collapsed into OTHERS. Preserve enough context to distinguish missing configuration from authorization, frontend/runtime availability, data conversion, or persistence problems.

  • No active form, incorrect lifecycle sequence, or assuming END_FORM also closes the output request are the main errors.
  • Check every declared exception and SY-SUBRC branch in the target release.
  • If a send/render/save call returns a technical success, still validate the returned spool/document/log identifier before telling the application that processing completed.

How to call it safely

Identify the runtime first: dialog versus background, frontend versus application server, text versus binary, and in-memory versus persisted state. Call with the smallest required dataset, check the returned handle/ID/length, and perform follow-on close/save/dispatch steps only in the documented sequence. Never make a destructive file or repository call from unchecked user input.

When producing several SAPscript forms in one output session, track which START_FORM opened the current form and call END_FORM only for that active form instance. After END_FORM, follow the OPEN_FORM/CLOSE_FORM lifecycle rather than assuming the spool request is already closed. Verify the generated spool output in SP01 and compare the page count or output request identifier before reporting success. If the script unexpectedly starts a fresh page or loses content, examine form/window control and the sequence of WRITE_FORM calls, not just printer configuration.

ECC vs S/4HANA

Legacy SAPscript lifecycle behavior remains in S/4HANA for existing forms. A function module being present in S/4HANA does not make it an ABAP Cloud-released API. For new clean-core work, prefer released classes, form/output services, content APIs, or Integration Suite patterns where SAP provides them.

Common pitfalls

  • Mixing presentation-server and application-server paths or assuming the same filesystem exists on every application-server instance.
  • Treating binary PDF/XSTRING content as text, causing code-page conversion or truncation.
  • Skipping the required OPEN/CLOSE or CREATE/SAVE lifecycle and leaving incomplete spool, form, mail, or log state.
  • Using a GUI popup or frontend file service in background/RFC processing where no interactive SAP GUI exists.
  • Assuming a queued mail/spool/log request proves downstream delivery, printing, or persistence without checking the relevant monitor.

Whose problem this is

ABAP owns correct lifecycle, typing, and exception handling. Basis owns spool devices, filesystem access, SAPconnect, ADS, and platform services. Functional/output teams own form choice and business content. Security/compliance owners define whether files, emails, attachments, or logs are permitted to contain the data being processed.

Related SAP objects

Reviewed pages this object connects to in the ERPClimb knowledge graph.

Source: ERPClimb — https://erpclimb.com/sap-function-modules/end-formERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.