In this blog post, we’ll teach you how to prepare an interactive PDF form for SAP, using SAP Interactive Forms by Adobe.
First, prepare a new form object to use in the following instructions. To be able to check this form object quickly, you should use the Preview PDF. To do this, create a print program, and then set the preview data for the form. We’ll describe how to do so in the following sections.
For the first steps with interactive PDF forms you need a very simple interface that has a single table. For this purpose, the table of customers from a flight booking application will be used. Follow these steps to create the interface:
Next, create a new form. Follow these steps:
Now you need a print program to test the form in print view or to generate test data. Create the print program for this example as follows:
At this point, it should be noted that the print program shown below creates a dynamic, interactive PDF form for the preview. For this purpose, the two fields fillable and dynamic are set in docparams. These two lines of code are highlighted in bold.
PROGRAM z_ifba_book_interactive.
* Screen definition
PARAMETERS:
p_form TYPE fpwbformname DEFAULT 'Z_IFBA_BOOK_FORM_03',
p_langu TYPE spras DEFAULT 'D',
p_ctry TYPE land1 DEFAULT 'DE'.
* Data declaration
DATA:
" variables
gv_fmname TYPE rs38l_fname,
gv_err_string TYPE string,
" structures
gs_docparams TYPE sfpdocparams,
gs_outputpar TYPE sfpoutputparams,
" tables
gt_customers TYPE ty_customers,
" references
gx_exc_api TYPE REF TO cx_fp_api.
* Processing
" data determination
SELECT *
INTO TABLE gt_customers
FROM scustom
UP TO 10 ROWS
ORDER BY PRIMARY KEY.
" Determination of the generated function module
TRY.
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = p_form
IMPORTING
e_funcname = gv_fmname.
" Error handling
CATCH cx_fp_api_repository " TRY.
cx_fp_api_usage
cx_fp_api_internal
INTO gx_exc_api.
gv_err_string = gx_exc_api->get_text( ).
MESSAGE gv_err_string TYPE 'E'.
ENDTRY. " CATCH cx_fp_api_repository " TRY.
" Start printjob
gs_outputpar-reqnew = abap_true.
CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams = gs_outputpar
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
IF NOT sy-subrc IS INITIAL. "CALL FUNCTION
" Error, inform user
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1
sy-msgv2
sy-msgv3
sy-msgv4.
ENDIF. "IF NOT sy-subrc IS INITIAL. "CALL FUNCTION
" define language and country
gs_docparams-langu = p_langu.
gs_docparams-country = p_ctry.
" define form as interactive
gs_docparams-fillable = abap_true.
gs_docparams-dynamic = abap_true.
" Call the generated function module (form)
CALL FUNCTION gv_fmname
EXPORTING
/1bcdwb/docparams = gs_docparams
customers = gt_customers
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF NOT sy-subrc IS INITIAL. " CALL FUNCTION gv_fmname
" Error, inform user
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1
sy-msgv2
sy-msgv3
sy-msgv4.
ENDIF. " IF NOT sy-subrc IS INITIAL. " CALL FUNCTION gv_fmnam
" Close print job
CALL FUNCTION 'FP_JOB_CLOSE'
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF NOT sy-subrc IS INITIAL. "CALL FUNCTION
" Error, inform user
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1
sy-msgv2
sy-msgv3
sy-msgv4.
ENDIF. "IF NOT sy-subrc IS INITIAL. "CALL FUNCTION
To use the Preview PDF, you need to set its properties as the last step of the preparations. To do this, follow these steps:
In the following three steps, you set the properties of the PDF form for preview. Like the print program, the Preview PDF should display a dynamic, interactive PDF form. In addition, you define the preview data. The Form Properties dialog and the corresponding page are shown in the next figure.
When a PDF document is created in Adobe LiveCycle Designer, usage rights aren’t added. Therefore, when using Preview PDF to test interactive PDF forms, the warning dialog that inputs can’t be saved appears. You can select the Don’t Show Again checkbox to avoid having to confirm the dialog each time you test.
Note that due to the lack of usage rights, individual functions may be available in a limited way. In this case, you must create the PDF form using the print program created in this chapter and then use it for testing.
You can create a copy of the form you’ve just created at this point. This makes it possible to distribute the following examples over several forms for test purposes. You can create a new form at your discretion, for example, after each section, by copying the empty form.
Now create a copy of the Z_IFBA_BOOK_FORM_03 form and give it the name “Z_IFBA_BOOK_FORM_03_LEER”, for example. This completes the preparations.
Editor’s note: This post has been adapted from a section of the book SAP Interactive Forms by Adobe by Timo Ortiz.