In a print program, several PDF-based print forms are created for a customer. The forms should all be combined into a single PDF file and sent via email.
Set parameters in the structure SFOUTPUTPARAMS
When the function module JOB_OPEN is called, print parameters can be specified in the structure SFOUTPUTPARAMS. The following parameters are set for bundled output of several forms in a PDF file:
SFOUTPUTPARAMS-GETPDF = M Send the form as a PDF file to the calling program
SFOUTPUTPARAMS-BUMODE = M Bundle forms into one file
SFOUTPUTPARAMS-ASSEMBLE = S Assemble forms
Create the forms in a loop
The forms are generated in a loop. The call to JOB_OPEN occurs before the loop, followed by JOB_CLOSE after the loop.
Read the PDF file after JOB_CLOSE
After the function module JOB_CLOSE the generated forms can be save in a PDF file. The function module ‘FPCOMP_GET_PDF_TABLE’ is called for this purpose. The PDF file can now be sent by email using the usual methods and function blocks.
Code example
* Formular öffnen —————————————————- *
PERFORM job_open USING lv_bundle.
* Texte für Formular ermitteln ————————————— *
LOOP AT it_fonam INTO ls_fonam.
PERFORM get_data CHANGING gs_data.
* FuBa zum Formular holen ——————————————– *
PERFORM get_fm_name USING ls_fonam-fonam
CHANGING gv_fm_name
gv_if_type.
* Fomular prozessieren ———————————————– *
PERFORM process_form USING gv_fm_name
gs_data
CHANGING ls_output.
ENDLOOP.
* Formular schließen ————————————————- *
PERFORM job_close using lv_bundle
CHANGING ls_output.
The ls_output-pdf field contains all the forms in a PDF file.
It can now be sent by email or saved as a file by the usual routines.
*&———————————————————————*
*& Form JOB_OPEN
*&———————————————————————*
FORM job_open USING lv_bundle TYPE xfeld.
DATA: ls_outparam TYPE sfpoutputparams.
“Alle Formulare in einem PDF sammeln
IF lv_bundle NE space.
ls_outparam-bumode = ‘M’.
ls_outparam-assemble = ‘S’.
ls_outparam-getpdf = ‘M’.
ELSE.
ls_outparam-getpdf = ‘X’.
ENDIF.
…..
CALL FUNCTION ‘FP_JOB_OPEN’
CHANGING
ie_outputparams = ls_outparam
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
ENDFORM.
*&———————————————————————*
*& Form GET_FM_NAME
*&———————————————————————*
FORM get_fm_name USING pv_fpname TYPE fpname
CHANGING gv_fm_name TYPE rs38l_fnam
gv_if_type TYPE fpinterfacetype.
CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’
EXPORTING
i_name = pv_fpname
IMPORTING
e_funcname = gv_fm_name
e_interface_type = gv_if_type.
ENDFORM.
*&———————————————————————*
*& Form PROCESS_FORM
*&———————————————————————*
FORM process_form USING gv_fm_name TYPE rs38l_fnam
gs_data TYPE zcor_data_s
CHANGING ls_output TYPE fpformoutput.
DATA: ls_docparms TYPE sfpdocparams.
ls_docparms-langu = ‘D’.
ls_docparms-country = ‘DE’.
CALL FUNCTION gv_fm_name
EXPORTING
/1bcdwb/docparams = ls_docparms
gs_data = gs_data
IMPORTING
/1bcdwb/formoutput = ls_output
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
* gfs. hier noch ein Commit work
ENDFORM.
*&———————————————————————*
*& Form JOB_CLOSE
*&———————————————————————*
FORM job_close USING pv_bundle TYPE xfeld
CHANGING ls_output TYPE fpformoutput.
DATA: lt_pdf TYPE tfpcontent,
ls_pdf TYPE fpcontent.
CALL FUNCTION ‘FP_JOB_CLOSE’
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF pv_bundle NE space.
CALL FUNCTION ‘FPCOMP_GET_PDF_TABLE’
IMPORTING
e_pdf_table = lt_pdf.
READ TABLE lt_pdf INTO ls_pdf INDEX 1.
ls_output-pdf = ls_pdf.
ENDIF.
ENDFORM.