Code: Alles auswählen.
DATA: "[...]
lv_fmname TYPE rs38l_fnam,
ls_docparams TYPE sfpdocparams,
ls_outparams TYPE sfpoutputparams,
ls_formoutput TYPE fpformoutput,
ls_jobresult TYPE sfpjoboutput.
" [...]
" Namen des Druck-Funktionsbausteins ermitteln
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = 'Z_NAME_DES_FORMULARS'
IMPORTING
e_funcname = lv_fmname.
" [...]
" Parameter für Ausgabe festlegen
ls_outparams-getpdf = abap_true. " <-- wichtig, Ausgabe als PDF
" [...]
" Druckjob öffnen
CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams = ls_outparams
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
" [...]
" Formular generieren
CALL FUNCTION lv_fmname
EXPORTING
/1bcdwb/docparams = ls_docparams
is_apprvl_data = ls_head
IMPORTING
/1bcdwb/formoutput = ls_formoutput " <-- PDF steckt hier drin im Feld PDF
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
" [...]
" Abschluss des Druckauftrags
CALL FUNCTION 'FP_JOB_CLOSE'
IMPORTING
e_result = ls_jobresult
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
" [...]
" --> PDF-Dokument als XSTRING im Feld ls_formoutput-pdf
Code: Alles auswählen.
lo_email = cl_bcs=>create_persistent( ).
" [...]
lo_email->add_attachment(
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = 'Mein Formular'
i_att_content_hex = lv_xstring " <-- PDF-Dokument
i_attachment_language = sy-langu ).
" [...]
Folgende Benutzer bedankten sich beim Autor Lukas Sanders für den Beitrag (Insgesamt 2):
ZF_SAPler • Sebastian82