In many cases, we need to assemble mutiple PDF form output into one PDF file.
In this case, you need to refer the the standard program FP_CHECK_BATCH_PDF_RETURN.
Simple, please do as following:
1. Call the function FP_JOB_OPEN, in the importing parameter, there is field named 'assemble', set it to be ABAP_TRUE. Please be noted that, when you set the value for it, there is constrain that you should set value for other fields under rule. Otherewise, there will be errro when calling the FP_JOB_OPEN
fp_outputparams-nodialog = abap_true.
fp_outputparams-getpdf = 'M'.
fp_outputparams-assemble = abap_true.
fp_outputparams-preview = abap_false.
2. Call the function modules of the the PDF forms(using the function FP_FUNCTION_MODULE_NAME to get the function name) for as many times as you like.
3. Call the function module FP_JOB_CLOSE to close the process.
4. Call the function module FP_GET_PDF_TABLE to get the output xstring of the PDF forms.
5. Using following code to open the PDF file from frontend.
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY CHANGING TEMP_DIR = L_FILE EXCEPTIONS CNTL_ERROR = 1 ERROR_NO_GUI = 2 NOT_SUPPORTED_BY_GUI = 3 OTHERS = 4. IF SY-SUBRC IS NOT INITIAL. MESSAGE ID 'ED' TYPE 'E' NUMBER '256'. ENDIF. CALL METHOD CL_GUI_CFW=>FLUSH EXCEPTIONS CNTL_SYSTEM_ERROR = 1 CNTL_ERROR = 2 OTHERS = 3. IF SY-SUBRC IS NOT INITIAL. MESSAGE ID 'ED' TYPE 'E' NUMBER '256'. ENDIF. CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_FILE_SEPARATOR CHANGING FILE_SEPARATOR = LV_SEP EXCEPTIONS CNTL_ERROR = 1 ERROR_NO_GUI = 2 NOT_SUPPORTED_BY_GUI = 3 OTHERS = 4. IF SY-SUBRC IS NOT INITIAL. MESSAGE ID 'ED' TYPE 'E' NUMBER '256'. ENDIF. CONCATENATE L_FILE LV_SEP SY-REPID C_FILE_EXT_PDF INTO L_FILE. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING BUFFER = L_PDF_XSTRING TABLES BINARY_TAB = LT_DATA. L_LEN = XSTRLEN( L_RESULT-CONTENT ). CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD EXPORTING BIN_FILESIZE = L_LEN FILENAME = L_FILE FILETYPE = 'BIN' CHANGING DATA_TAB = LT_DATA EXCEPTIONS FILE_WRITE_ERROR = 1 NO_BATCH = 2 GUI_REFUSE_FILETRANSFER = 3 INVALID_TYPE = 4 NO_AUTHORITY = 5 UNKNOWN_ERROR = 6 HEADER_NOT_ALLOWED = 7 SEPARATOR_NOT_ALLOWED = 8 FILESIZE_NOT_ALLOWED = 9 HEADER_TOO_LONG = 10 DP_ERROR_CREATE = 11 DP_ERROR_SEND = 12 DP_ERROR_WRITE = 13 UNKNOWN_DP_ERROR = 14 ACCESS_DENIED = 15 DP_OUT_OF_MEMORY = 16 DISK_FULL = 17 DP_TIMEOUT = 18 FILE_NOT_FOUND = 19 DATAPROVIDER_EXCEPTION = 20 CONTROL_FLUSH_ERROR = 21 NOT_SUPPORTED_BY_GUI = 22 ERROR_NO_GUI = 23 OTHERS = 24. IF SY-SUBRC IS NOT INITIAL. MESSAGE ID 'ED' TYPE 'E' NUMBER '256'. ENDIF. CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE EXPORTING DOCUMENT = L_FILE SYNCHRONOUS = 'X' EXCEPTIONS CNTL_ERROR = 1 ERROR_NO_GUI = 2 BAD_PARAMETER = 3 FILE_NOT_FOUND = 4 PATH_NOT_FOUND = 5 FILE_EXTENSION_UNKNOWN = 6 ERROR_EXECUTE_FAILED = 7 SYNCHRONOUS_FAILED = 8 NOT_SUPPORTED_BY_GUI = 9 OTHERS = 10. IF SY-SUBRC IS NOT INITIAL. MESSAGE ID 'ED' TYPE 'I' NUMBER '256'. ENDIF. CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE EXPORTING FILENAME = L_FILE CHANGING RC = L_RC EXCEPTIONS FILE_DELETE_FAILED = 1 CNTL_ERROR = 2 ERROR_NO_GUI = 3 FILE_NOT_FOUND = 4 ACCESS_DENIED = 5 UNKNOWN_ERROR = 6 NOT_SUPPORTED_BY_GUI = 7 WRONG_PARAMETER = 8 OTHERS = 9. IF SY-SUBRC IS NOT INITIAL. MESSAGE ID 'ED' TYPE 'E' NUMBER '256'. ENDIF.
1 Comment
Satyabrata Sahoo
Can we assemble 2 PDF in "Preview" ? I tried the above solution to add a "Terms & Condition" PDF of 7 pages to Quote form but it works well upon "Print". On preview I am getting 2 different pages.. (with 'Next' page). Please suggest..?