Generate Adobe PDF in background
Sometimes you need to generate an Adobe PDF in the background, for example to send it as attachment or store it on a remote storage.
Info:to be able to generate the PDF in the background, the J2EE engine / Adobe Server must be set up and connected to the ABAP stack properly. This example is about programming, and not about the configuration.
When you know the name of the Adobe PDF to be generated, you can execute the printing job programmatically and get the pdf as raw data. You need to fill the PDF interface with the required input and set language and local properties.
DATA: ls_address TYPE bapiaddr3, lv_printer TYPE rs38l_fnam, ls_prm_form TYPE sfpdocparams, ls_prm_output TYPE sfpoutputparams, ls_pdf TYPE fpformoutput, lt_message TYPE bapirettab. "Print paremeters ls_prm_output-getpdf = abap_true."I want print to rawdata (instead of dialog processing) ls_prm_form-langu = sy-langu. CALL FUNCTION 'BAPI_USER_GET_DETAIL' EXPORTING username = sy-uname IMPORTING address = ls_address TABLES return = lt_message. IF ls_address-country IS NOT INITIAL. ls_prm_form-country = ls_address-country. ELSE. ls_prm_form-country = 'HU'. ENDIF. "PDF generation CALL FUNCTION 'FP_JOB_OPEN' CHANGING ie_outputparams = ls_prm_output EXCEPTIONS cancel = 1 usage_error = 2 system_error = 3 internal_error = 4 OTHERS = 5. IF sy-subrc NE 0. RETURN. ENDIF. CALL FUNCTION 'FP_FUNCTION_MODULE_NAME' EXPORTING i_name = 'HERE COMES THE NAME OF THE ADOBE FORM' IMPORTING e_funcname = lv_printer. IF sy-subrc NE 0. RETURN. ENDIF. CALL FUNCTION lv_printer EXPORTING /1bcdwb/docparams = ls_prm_form "HERE PASS THE ADOBE FORM INTERFACE PARAMETERS, "you can get it from tx.: SFP, entering the Adobe Form name IMPORTING /1bcdwb/formoutput = ls_pdf EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3. IF sy-subrc NE 0. RETURN. ENDIF. CALL FUNCTION 'FP_JOB_CLOSE' EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3 OTHERS = 4. IF sy-subrc NE 0. RETURN. ENDIF. "Rawdata can be found in ls_pdf-pdf.
Share this content: