on 12-08-2009 11:31 AM
Hello ..
I'm working on a development where I have to give an option to user to save the smartform in PDF forma ..
My code is as below:
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_formname
IMPORTING
fm_name = l_form_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
if sf_pdf = 'X'. "RadioButton to save smartform as pdf
x_cparam-getotf = 'X'.
endif.
CALL FUNCTION l_form_name
EXPORTING
control_parameters = x_cparam
IMPORTING
job_output_info = x_main_str
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
endif.
*** FUNCTION MODULE TO CONVERT SMARTFORM TO PDF
IF sf_pdf = 'X'.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = v_fsize " RETURNS FILESIZE OF THE PDF
TABLES
otf = x_main_str-otfdata "OTFDATA FIELD OF X_MAIN-STR
lines = x_i_line
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*** FUNCTION MODULE TO DOWNLOAD THE PDF ON USER'S SYSTEM.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
bin_filesize = v_fsize
filename = 'c:\InspectionPlan_Report.pdf'
filetype = 'BIN'
TABLES
data_tab = x_i_line
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11.
ENDIF.
when I execute the code, I get this error: OTF end command // missing in OTF data
I am not abl to solve it .. kindly help ..
Your OTF is corrupted because // MUST be defined as first and last lines. Please check how you get the OTF BEFORE converting the OTF to PDF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Just user this code below
DATA: W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP,
W_RETURN TYPE SSFCRESCL.
DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_formname
IMPORTING
fm_name = l_form_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
if sf_pdf = 'X'. "RadioButton to save smartform as pdf
x_cparam-getotf = 'X'.
endif.
W_CTRLOP-GETOTF = 'X'.
W_CTRLOP-NO_DIALOG = 'X'.
W_COMPOP-TDNOPREV = 'X'.
CALL FUNCTION l_form_name
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = 'X'
IMPORTING
job_output_info = W_RETURN
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
endif.
FUNCTION MODULE TO CONVERT SMARTFORM TO PDF
IF sf_pdf = 'X'.
I_OTF[] = W_RETURN-OTFDATA[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = v_fsize " RETURNS FILESIZE OF THE PDF
TABLES
OTF = I_OTF
LINES = I_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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
FUNCTION MODULE TO DOWNLOAD THE PDF ON USER'S SYSTEM.
DATA W_FILESIZE.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = v_fsize
FILENAME = 'c:\InspectionPlan_Report.pdf'F_NAME
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = W_FILESIZE
TABLES
DATA_TAB = I_TLINE
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10
.
ENDIF.
regards,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Which FM gives you the given error?
It's not abap relevant, but I'm using PDFCreator freeware software for creating PDF-s... It is installed as a windows printer, so anything I print will be printed as a PDF document...
Regards
Tamá
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try using "GUI_DOWNLOAD" for downloading the pdf format.
Regards,
Sharin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check the below link. It will help you.
[https://wiki.sdn.sap.com/wiki/display/Snippets/Smartform%20output%20to%20PDF%20format]
Aslo do check the below url.
[https://wiki.sdn.sap.com/wiki/display/Snippets/Convert%20Smartform%20to%20PDF%20format]
Regards
SunilKumar
Edited by: sunil kumar on Dec 8, 2009 5:08 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.