cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in converting smartform to PDF

0 Kudos

Hi Experts,

I am facing the issue while converting the smartform to pdf form with the help of FM convert_otf_2_pdf .

Problem is that

CH3OH4OD7 3 , 4 and 7 are the subscipts in SMARTFORM like in a chemical formula ,but after conveting to PDF # is replacing the subscripts like CH#OH#OD# .

Kindly help in this issue.

Thanks

Sachin

Edited by: Rob Burbank on Feb 6, 2012 10:13 AM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Try this example it will be help full

REPORT YSAMPLE5.

DATA:

w_form_name TYPE tdsfname VALUE 'YSAMPLE2',

w_fmodule TYPE rs38l_fnam,

w_cparam TYPE ssfctrlop,

w_outoptions TYPE ssfcompop,

W_bin_filesize TYPE i, " Binary File Size

w_FILE_NAME type string,

w_File_path type string,

w_FULL_PATH type string.

  • Internal tables declaration

  • Internal table to hold the OTF data

DATA:

t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

  • Internal table to hold OTF data recd from the SMARTFORM

t_otf_from_fm TYPE ssfcrescl,

  • Internal table to hold the data from the FM CONVERT_OTF

T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.

  • This function module call is used to retrieve the name of the Function

  • module generated when the SMARTFORM is activated

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = w_form_name

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = w_fmodule

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • Calling the SMARTFORM using the function module retrieved above

  • GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF

  • format of the output

w_cparam-no_dialog = 'X'.

w_cparam-preview = space. " Suppressing the dialog box

" for print preview

w_cparam-getotf = 'X'.

  • Printer name to be used is provided in the export parameter

  • OUTPUT_OPTIONS

w_outoptions-tddest = 'LP01'.

CALL FUNCTION w_fmodule

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = w_cparam

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

output_options = w_outoptions

  • USER_SETTINGS = 'X'

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

job_output_info = t_otf_from_fm

  • JOB_OUTPUT_OPTIONS =

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 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.

t_otf[] = t_otf_from_fm-otfdata[].

  • Function Module CONVERT_OTF is used to convert the OTF format to PDF

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

IMPORTING

BIN_FILESIZE = W_bin_filesize

  • BIN_FILE =

TABLES

otf = T_OTF

lines = T_pdf_tab

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.

  • To display File SAVE dialog window

CALL METHOD cl_gui_frontend_services=>file_save_dialog

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 the generated PDF file onto the

  • presentation server

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = W_bin_filesize

filename = w_FULL_PATH

FILETYPE = 'BIN'

tables

data_tab = T_pdf_tab

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Former Member
0 Kudos

Hi friend,

There might be some problem in the device type settings.

Just check whether you have done your code based on this see the below wikis and let me know,

Link : [Smartform to Mail as PDF attachment|http://wiki.sdn.sap.com/wiki/display/Snippets/SmartformtoMailasPDF+attachment]

Link : [Smartform output to PDF format|http://wiki.sdn.sap.com/wiki/display/Snippets/SmartformoutputtoPDFformat].

These wiki should clear your doubts if no please see the SAP note 940205.

I think this will solve your problem. If you still have issues please revert back to me i will help you.

Thanks,

Sri Hari

Former Member
0 Kudos

Hi,

Create a Spool for the smartform and use the program RSTXPDFT4 to download it as a pdf to local drive. Once you craete a spool for the smartform use the below command,

SUBMIT rstxpdft4 WITH spoolno EQ ls_spoolid " Spool number

WITH download EQ 'X'

WITH p_file EQ gv_file " Local drive path

EXPORTING LIST TO MEMORY

AND RETURN. " use this only if you want to return back to the calling program.

The above command will download the PDF format of the spool to your local drive. use the above command in your program. To get the spool id for a smartform set the OUTPUT_OPTIONS parameter accordingly.

please go through the below link as well. This will give you more options.

[;

Please let me know if you have any further doubts.