How to print multiple Adobe Forms?
Printing multiple Adobe Forms at the same time is possible. You can print them together in a loop or in program flow.
To be able to print, you have to set parameter output_param-bumode = 'M'.
TRY.
"get master fm
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = mv_master_form "Form name
IMPORTING
e_funcname = fm_master.
IF mv_single_form IS NOT INITIAL.
"get single fm
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = mv_single_form "Form name
IMPORTING
e_funcname = fm_single.
ENDIF.
CATCH cx_fp_api_repository.
r_subrc = 1.
RETURN.
CATCH cx_fp_api_usage.
r_subrc = 1.
RETURN.
CATCH cx_fp_api_internal.
r_subrc = 1.
RETURN.
ENDTRY.
"open form
output_param-nodialog = 'X'.
output_param-preview = mv_preview.
output_param-bumode = 'M'. "!! should be M to print multiple form
output_param-reqnew = 'X'.
"get user printer device
SELECT SINGLE spld
FROM usr01
WHERE bname = @sy-uname
INTO @output_param-dest.
IF sy-subrc NE 0 OR output_param-dest IS INITIAL.
* r_subrc = 3.
* RETURN.
output_param-dest = 'PDFC'. ##TEST
ENDIF.
CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams = output_param
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
r_subrc = sy-subrc.
RETURN.
ENDIF.
doc_params-langu = sy-langu.
doc_params-country = 'DE'.
doc_params-replangu1 = 'E'.
doc_params-replangu2 = 'E'.
"print master
IF lt_output_master IS NOT INITIAL.
CALL FUNCTION fm_master
EXPORTING
/1bcdwb/docparams = doc_params
it_output = lt_output_master
* IMPORTING
* /1bcdwb/formoutput =
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
r_subrc = 3.
RETURN.
ENDIF.
ENDIF.
"print single
IF lt_output_single IS NOT INITIAL.
CALL FUNCTION fm_single
EXPORTING
/1bcdwb/docparams = doc_params
it_output = lt_output_single
* IMPORTING
* /1bcdwb/formoutput =
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
r_subrc = 3.
RETURN.
ENDIF.
ENDIF.
"Finish
CALL FUNCTION 'FP_JOB_CLOSE'
IMPORTING
e_result = result
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
r_subrc = 3.
RETURN.
ENDIF.