ERPClimb logoERPClimb

Code examples · Modern ABAP · Intermediate

Print or get a PDF from an Adobe Form: FP_JOB_OPEN, generated function module, FP_JOB_CLOSE

The problem

Sales wants an order confirmation as a PDF.

How we solve it

  1. 1Output settingsno dialog, PDF
  2. 2Open jobFP_JOB_OPEN
  3. 3Call the formgenerated FM
  4. 4Close jobFP_JOB_CLOSE

The result

The method returns the PDF of the order confirmation as an xstring.

Overview drawn by ERPClimb from this example. The steps are the same as in the code below.

1. The requirement

Sales wants an order confirmation as a PDF. The form ZF_ORDER_CONFIRM was designed in transaction SFP with an interface that has one importing parameter IS_ORDER. The ABAP program must fill that parameter and return the PDF as binary data, without showing a print dialog.

2. How we design it

An Adobe Form has two parts. The design (layout and interface) is made in SFP. The ABAP program only supplies data. When the form is activated, the system generates a function module whose name is different in every system, so the program asks for it by form name with FP_FUNCTION_MODULE_NAME. The call to the form must be wrapped by FP_JOB_OPEN and FP_JOB_CLOSE, which open and close the spool job.

Why we decided it this way

  1. 1Find the function module by form nameThe generated module name changes between systems. Hard-coding it breaks the transport.
  2. 2Set output parameters before FP_JOB_OPENWith nodialog and getpdf set, no popup appears and the generated module returns the PDF in /1BCDWB/FORMOUTPUT.
  3. 3Always close the jobA job that was opened and never closed leaves a half-finished spool request. Close it also when the call to the form failed.

Before you start

  • Adobe Document Services configured (transaction SFP shows a form preview when ADS works).
  • A form ZF_ORDER_CONFIRM with interface parameter IS_ORDER. Replace the name and parameter with your own.

3. The code, step by step

Step 1 of 4: Set the output parameters

Ask for the PDF back and suppress the print dialog.

ABAP · Class · ZCL_ORDER_FORM (method get_pdf, part 1)
" SFPOUTPUTPARAMS with nodialog and getpdf
CLASS zcl_order_form DEFINITION PUBLIC FINAL CREATE PUBLIC.
  PUBLIC SECTION.
    CLASS-METHODS get_pdf
      IMPORTING is_order      TYPE zorder_form_data
      RETURNING VALUE(rv_pdf) TYPE xstring.
ENDCLASS.

CLASS zcl_order_form IMPLEMENTATION.
  METHOD get_pdf.
    DATA: ls_outputparams TYPE sfpoutputparams,
          ls_docparams    TYPE sfpdocparams,
          ls_formoutput   TYPE fpformoutput,
          lv_fm_name      TYPE rs38l_fnam.

    ls_outputparams-nodialog = abap_true.
    ls_outputparams-getpdf   = abap_true.
Part by part (plain text)
  1. SFPOUTPUTPARAMS with nodialog and getpdf. SFPOUTPUTPARAMS controls where the output goes. nodialog = abap_true avoids the printer popup. getpdf = abap_true tells the system to hand the PDF back to the program instead of only sending it to the spool.

Open in the portal

The SAP objects named in this code are linked in the code above and listed here. Each opens its page in the SAP Library.

4. The final outcome

The method returns the PDF of the order confirmation as an xstring.

What you should see

ev_pdf holds the binary PDF (starts with the bytes %PDF). You can save it to a file, attach it to an e-mail or return it from an OData service.

Try it and check the result

  • In SFP first test the form alone with the Test button and sample data. If this does not work, the problem is the form or ADS, not your ABAP.
  • Call ZCL_ORDER_FORM=>GET_PDF from a small test class and check that the result is not empty.
  • Write the xstring to a file on your PC (cl_gui_frontend_services=>gui_download) and open it in a PDF reader.

Common mistakes

  • Parameter names and the structure type of IS_ORDER come from your form interface. The generated module only accepts what the interface declares.
  • Forms with a Smart Forms-style interface open and close the job themselves. Check the interface type in SFP before you add FP_JOB_OPEN and FP_JOB_CLOSE.
  • Calling several forms between one OPEN and CLOSE is possible, but the assembling options need care. Test the PDF count.
  • ADS problems (no connection, certificate, fonts) show up as exceptions from the generated module. Check transaction SM59 and ADS ping first.

Keep learning

Checking status: Reviewed line by line against SAP documentation. Not executed on a live system. Reviewed 2026-11-26. Release: SAP system with Adobe Document Services (ADS) connected. The form ZF_ORDER_CONFIRM and its interface are examples that you must create in SFP; they are not part of this code.

Original ERPClimb teaching code with illustrative names. Not taken from a customer system. Syntax can differ by release; check the references below and activate in a sandbox first. ERPClimb is independent of SAP SE.