smartforms 转 PDF 并 BASE64 加密
DATA:lv_fmname TYPE tdsfname,
ls_control_param TYPE ssfctrlop,
ls_job_output_info TYPE ssfcrescl,
ls_output_options TYPE ssfcompop,
l_fm TYPE rs38l_fnam,
l_num TYPE i.
DATA:ls_bkpf TYPE bkpf,
ls_foot TYPE zsntfi0111.
CLEAR:lv_ots_xstring,encode_str.
"脚标
CLEAR:ls_foot.
SELECT SINGLE a~zzdr,a~zshr,b~butxt
FROM zsntfi0111 AS a
INNER JOIN t001 AS b
ON a~bukrs = b~bukrs
INTO (@ls_foot-zzdr,@ls_foot-zshr,@ls_foot-butxt)
WHERE a~bukrs = @p_bukrs
AND zsflx = 'C08'.
ls_bkpf = CORRESPONDING #( wa_bkpf ).
l_num = 1.
LOOP AT lt_form ASSIGNING FIELD-SYMBOL(<f_form>).
<f_form>-znum = l_num.
l_num = l_num + 1.
ENDLOOP.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSNFISF0002' "调用模板
IMPORTING
fm_name = l_fm
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc = 0.
ls_output_options-tddelete = 'X'.
ls_control_param-preview = 'X'.
ls_output_options-tdimmed = 'X'.
ENDIF.
ls_control_param-no_dialog = 'X'.
ls_control_param-getotf = 'X'.
CALL FUNCTION l_fm
EXPORTING
control_parameters = ls_control_param
output_options = ls_output_options
* USER_SETTINGS = 'X'
i_head = ls_bkpf
i_foot = ls_foot
IMPORTING
job_output_info = ls_job_output_info
TABLES
it_item = lt_form[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE '获取审批进度查询数据流失败!' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ELSE.
CLEAR:lt_tsfotf.
LOOP AT ls_job_output_info-otfdata INTO DATA(wa_otfdata).
APPEND wa_otfdata TO lt_tsfotf.
ENDLOOP.
ENDIF.
CLEAR: lv_pdf_len,lv_ots_xstring,lt_tline.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_pdf_len
bin_file = lv_ots_xstring
TABLES
otf = lt_tsfotf
lines = lt_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE '转换PDF流失败'
ls_control_param TYPE ssfctrlop,
ls_job_output_info TYPE ssfcrescl,
ls_output_options TYPE ssfcompop,
l_fm TYPE rs38l_fnam,
l_num TYPE i.
DATA:ls_bkpf TYPE bkpf,
ls_foot TYPE zsntfi0111.
CLEAR:lv_ots_xstring,encode_str.
"脚标
CLEAR:ls_foot.
SELECT SINGLE a~zzdr,a~zshr,b~butxt
FROM zsntfi0111 AS a
INNER JOIN t001 AS b
ON a~bukrs = b~bukrs
INTO (@ls_foot-zzdr,@ls_foot-zshr,@ls_foot-butxt)
WHERE a~bukrs = @p_bukrs
AND zsflx = 'C08'.
ls_bkpf = CORRESPONDING #( wa_bkpf ).
l_num = 1.
LOOP AT lt_form ASSIGNING FIELD-SYMBOL(<f_form>).
<f_form>-znum = l_num.
l_num = l_num + 1.
ENDLOOP.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSNFISF0002' "调用模板
IMPORTING
fm_name = l_fm
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc = 0.
ls_output_options-tddelete = 'X'.
ls_control_param-preview = 'X'.
ls_output_options-tdimmed = 'X'.
ENDIF.
ls_control_param-no_dialog = 'X'.
ls_control_param-getotf = 'X'.
CALL FUNCTION l_fm
EXPORTING
control_parameters = ls_control_param
output_options = ls_output_options
* USER_SETTINGS = 'X'
i_head = ls_bkpf
i_foot = ls_foot
IMPORTING
job_output_info = ls_job_output_info
TABLES
it_item = lt_form[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE '获取审批进度查询数据流失败!' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ELSE.
CLEAR:lt_tsfotf.
LOOP AT ls_job_output_info-otfdata INTO DATA(wa_otfdata).
APPEND wa_otfdata TO lt_tsfotf.
ENDLOOP.
ENDIF.
CLEAR: lv_pdf_len,lv_ots_xstring,lt_tline.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_pdf_len
bin_file = lv_ots_xstring
TABLES
otf = lt_tsfotf
lines = lt_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE '转换PDF流失败'