SAP中PDF文件本地保存方法
1、對于scriptform或者smartform已經(jīng)ABAP list都可以通過SAP標準程序RSTXPDFT4進行本地保存。
使用本方法需要獲得要打印內(nèi)容的假脫機請求號,可以通過事務碼SP02獲得。
2、通過自己書寫代碼實現(xiàn):
①對于scriptform:首先要設置 函數(shù)?OPEN_FORM?的參數(shù)?OPTIONS?,OPTIONS中的參數(shù)?tdgetotf?設置為'X'.
通過函數(shù)????CALL?FUNCTION?'CLOSE_FORM'
????????????????IMPORTING
??????????????????RESULT??=?RESULT
????????????????tables
??????????????????otfdata?=?otfdata.
取得otfdata數(shù)據(jù),用于下面的函數(shù):
????CALL?FUNCTION?'CONVERT_OTF'
???EXPORTING
?????format??????????????????????=?'PDF'
???IMPORTING
?????bin_filesize????????????????=?bin_size
????TABLES
??????otf?????????????????????????=?otfdata
????lines???????????????????????=?pdf_lines?.
調(diào)用文件保存對話框:
????CALL?METHOD?cl_gui_frontend_services=>file_save_dialog
????EXPORTING
????default_extension????=?'PDF'
??????file_filter??????????=?'*.PDF'
????CHANGING
??????filename?????????????=?filename
??????path?????????????????=?path
??????fullpath?????????????=?fullpath?.
將數(shù)據(jù)保存到本地:
????CALL?FUNCTION?'GUI_DOWNLOAD'
????EXPORTING
???bin_filesize????????????????????=?bin_size
??????filename????????????????????????=?fullpath
???filetype????????????????????????=?'BIN'
???codepage????????????????????????=?'4110'
???IGNORE_CERR?????????????????????=?ABAP_TRUE
????TABLES
??????data_tab????????????????????????=?pdf_lines.
②對于smartform:調(diào)用的時候需要設置參數(shù)control_parameters,getotf?值設置為'X'.
在打開smartform時候,通過importing參數(shù)job_output_info獲得'CONVERT_OTF'函數(shù)的tables參數(shù)OTF的值。job_output_info-otfdata[],,可以通過SSFCOMP_PDF_PREVIEW函數(shù)預覽smartform的內(nèi)容:
call?function?‘SSFCOMP_PDF_PREVIEW’
??exporting
????i_otf??????????????????????????=?t_otf[].
或者通過下面代碼下載PDF文件到本地:
CALL?FUNCTION?'CONVERT_OTF'
EXPORTING
format?=?'PDF'
IMPORTING
bin_filesize = bin_size
TABLES
otf = otfdata
lines?= pdf_lines .
調(diào)用文件保存對話框:
CALL?METHOD?cl_gui_frontend_services=>file_save_dialog
EXPORTING
default_extension =?'PDF'
file_filter =?'*.PDF'
CHANGING
filename = filename
path = path
fullpath = fullpath?.
將數(shù)據(jù)保存到本地:
CALL?FUNCTION?'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_size
filename = fullpath
filetype =?'BIN'
codepage =?'4110'
IGNORE_CERR = ABAP_TRUE
TABLES
data_tab = pdf_lines.
總結(jié)
以上是生活随笔為你收集整理的SAP中PDF文件本地保存方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于程序变式中动态选择的一点说明
- 下一篇: SAP中国际贸易条款的含义