Vous êtes sur la page 1sur 4

Converting SMART FORMS output to PDF format

REPORT * DATA: w_form_name w_fmodule w_cparam w_outoptions W_bin_filesize w_FILE_NAME w_File_path w_FULL_PATH * * DATA: t_otf Internal TYPE table Variable TYPE tdsfname TYPE TYPE TYPE i, " type type type VALUE zsuresh_test. declarations 'ZSURESH_TEST', rs38l_fnam, ssfctrlop, ssfcompop, File Size string, string, string. declaration the WITH recd from OTF HEADER the data LINE,

TYPE

Binary

Internal table itcoo to hold to OCCURS OTF hold 0 data TYPE

tables

* Internal t_otf_from_fm * Internal T_pdf_tab

SMARTFORM ssfcrescl,

table LIKE

to tline

hold

the data OCCURS

from 0

the WITH

FM CONVERT_OTF HEADER LINE.

* *

This

function module

module call generated

is used when

to retrieve the name the SMARTFORM

of is

the

Function activated

CALL FUNCTION EXPORTING formname * VARIANT * DIRECT_CALL IMPORTING fm_name EXCEPTIONS no_form no_function_module OTHERS . IF sy-subrc MESSAGE ID sy-msgid WITH sy-msgv1 ENDIF. * Calling the SMARTFORM * GET_OTF parameter in the * format of the output

'SSF_FUNCTION_MODULE_NAME' = = = = = = = <> TYPE sy-msgv2 sy-msgty NUMBER sy-msgv3 ' ' w_form_name ' ' w_fmodule 1 2 3 0. sy-msgno sy-msgv4.

using the function CONTROL_PARAMETERS

module retrieved above is set to get the OTF

w_cparam-no_dialog w_cparam-preview

space.

"

= Suppressing

the

dialog

'X'. box

" w_cparam-getotf * Printer name * w_outoptions-tddest to be used is =

for

print

preview 'X'. export parameter OUTPUT_OPTIONS 'LP01'. w_fmodule = = = w_cparam = = = w_outoptions 'X' = t_otf_from_fm = 1 2 3 4 5 0. sy-msgno sy-msgv4.

provided =

in

the

CALL FUNCTION EXPORTING * ARCHIVE_INDEX * ARCHIVE_INDEX_TAB * ARCHIVE_PARAMETERS control_parameters = * MAIL_APPL_OBJ * MAIL_RECIPIENT * MAIL_SENDER output_options = * USER_SETTINGS = IMPORTING * DOCUMENT_OUTPUT_INFO job_output_info = * JOB_OUTPUT_OPTIONS EXCEPTIONS formatting_error = internal_error = send_error = user_canceled = OTHERS = . IF sy-subrc <> MESSAGE ID sy-msgid TYPE sy-msgty NUMBER WITH sy-msgv1 sy-msgv2 sy-msgv3 ENDIF. t_otf[] * Function Module CONVERT_OTF = is used to convert the

t_otf_from_fm-otfdata[]. OTF format to PDF

CALL FUNCTION EXPORTING FORMAT = MAX_LINEWIDTH = * ARCHIVE_INDEX = * COPYNUMBER * ASCII_BIDI_VIS2LOG = * PDF_DELETE_OTFTAB = IMPORTING BIN_FILESIZE = * BIN_FILE TABLES otf = lines = EXCEPTIONS ERR_MAX_LINEWIDTH = ERR_FORMAT = ERR_CONV_NOT_POSSIBLE =

'CONVERT_OTF' 'PDF' 132 ' 0 ' ' W_bin_filesize = T_OTF T_pdf_tab 1 2 3

' = ' '

ERR_BAD_OTF OTHERS . IF sy-subrc MESSAGE ID SY-MSGID WITH SY-MSGV1 ENDIF.

= = <> SY-MSGTY NUMBER SY-MSGV3

4 5 0. SY-MSGNO SY-MSGV4.

TYPE SY-MSGV2

* To display File SAVE dialog window CALL METHOD cl_gui_frontend_services=>file_save_dialog * EXPORTING * WINDOW_TITLE = * DEFAULT_EXTENSION = * DEFAULT_FILE_NAME = * FILE_FILTER = * INITIAL_DIRECTORY = * WITH_ENCODING = * PROMPT_ON_OVERWRITE = 'X' CHANGING filename = w_FILE_NAME path = w_FILE_PATH fullpath = w_FULL_PATH * USER_ACTION = * FILE_ENCODING = EXCEPTIONS CNTL_ERROR = 1 ERROR_NO_GUI = 2 NOT_SUPPORTED_BY_GUI = 3 others = 4 . IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

* *

Use

the

FM

GUI_DOWNLOAD

to download presentation

the

generated

PDF

file

onto the server

CALL EXPORTING BIN_FILESIZE filename FILETYPE * * * * * * * * * * * *

FUNCTION = = = APPEND WRITE_FIELD_SEPARATOR HEADER TRUNC_TRAILING_BLANKS WRITE_LF COL_SELECT COL_SELECT_MASK DAT_MODE CONFIRM_OVERWRITE NO_AUTH_CHECK CODEPAGE IGNORE_CERR = = = = = = = = = = = = ' ' ' ' ' ' '

'GUI_DOWNLOAD' W_bin_filesize w_FULL_PATH 'BIN' ' ' '00' ' 'X' ' ' ' ' ' ' ABAP_TRUE

' '

* * * * * * * * * tables data_tab * * * * * * * * * * * * * * * * * * * * * * * * . IF * MESSAGE * WITH ENDIF.

REPLACEMENT WRITE_BOM = TRUNC_TRAILING_BLANKS_EOL WK1_N_FORMAT = WK1_N_SIZE = WK1_T_FORMAT = WK1_T_SIZE = FILELENGTH = FIELDNAMES FILE_WRITE_ERROR NO_BATCH GUI_REFUSE_FILETRANSFER INVALID_TYPE NO_AUTHORITY UNKNOWN_ERROR HEADER_NOT_ALLOWED SEPARATOR_NOT_ALLOWED FILESIZE_NOT_ALLOWED HEADER_TOO_LONG DP_ERROR_CREATE DP_ERROR_SEND DP_ERROR_WRITE UNKNOWN_DP_ERROR ACCESS_DENIED DP_OUT_OF_MEMORY DISK_FULL DP_TIMEOUT FILE_NOT_FOUND DATAPROVIDER_EXCEPTION CONTROL_FLUSH_ERROR OTHERS sy-subrc SY-MSGID SY-MSGV1

= ' = ' ' ' '

'#' ' 'X' ' ' ' ' IMPORTING = T_pdf_tab = EXCEPTIONS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 0. SY-MSGNO SY-MSGV4.

= = = = = = = = = = = = = = = = = = = = = =

ID

<> TYPE SY-MSGTY NUMBER SY-MSGV2 SY-MSGV3

Vous aimerez peut-être aussi