Code20080403 - ooxxvv/MySAPnotes GitHub Wiki

PageOutline {{{#!comment -------------------- 以上的部份是固定的,不要變動 ----- --------------------------------------- 在建立連結時,請標明連結的頁面類型,例如:wiki:WikiStart,而不要只用 WikiStart ----- }}}

Code20080403

  • 將 SmartFrom 轉成 PDF

Code

{{{#!abap REPORT ytest.

CONSTANTS: c_format_pdf(10) VALUE 'PDF'.

DATA: g_filesize TYPE i, l_otfdata_tab LIKE itcoo OCCURS 1 WITH HEADER LINE, g_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE, objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE, objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE, objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE, objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE, reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE, doc_chng LIKE sodocchgi1, tab_lines LIKE sy-tabix, wa_print TYPE ssfcrescl , wa_control TYPE ssfctrlop, l_file TYPE string .

*-Call Smart form wa_control-getotf = 'X'. SET LOCALE LANGUAGE 'M'.

CALL FUNCTION '/1BCDWB/SF00000005' EXPORTING control_parameters = wa_control IMPORTING job_output_info = wa_print EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5.

*-Smart form to PDF CALL FUNCTION 'SSFDISPLAY_OTF' TABLES otf = wa_print-otfdata EXCEPTIONS error = 1 OTHERS = 2.

IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.

CALL FUNCTION 'CONVERT_OTF' EXPORTING format = c_format_pdf IMPORTING bin_filesize = g_filesize TABLES otf = wa_print-otfdata lines = g_pdf_tab EXCEPTIONS err_max_linewidth = 1 err_format = 2 err_conv_not_possible = 3 OTHERS = 4.

*-Download to PC l_file = 'C:\TEST.PDF'.

CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING bin_filesize = g_filesize filename = l_file filetype = 'BIN' TABLES data_tab = g_pdf_tab 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 OTHERS = 22. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. }}}

{{{#!comment -------------------- 以下的部份是固定的,不要變動 ----- }}}