cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform .OTF to PDF download.

0 Kudos

Plz help me

How can i convert and download the Smart form Into Pdf .

User shd be able to download the Pdf format of the layout .

thanks in advance .

Accepted Solutions (1)

Accepted Solutions (1)

narin_nandivada3
Active Contributor
0 Kudos

Hi Pols,

Please check these threads

This link is to convert smarform to PDF and send that PDF as attachment to a mail..

Check this WIKI... to convert SMARTFORM Output to PDF

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convert%2bsmartform%2bto%2bpdf%2bformat

Check this blog to send the SMARTFORM output in form of PDF as an attachment to mail

Hope this would help you.

Good luck

Narin

Answers (6)

Answers (6)

Former Member
0 Kudos

hi

PARAMETERS:lifnr like lfa1-lifnr.

DATA:number(3) TYPE n value 90.

DATA:ktab TYPE TABLE OF lfa1.

DATA:ltab TYPE TABLE OF ekko.

DATA:w_fmodule TYPE rs38l_fnam,

w_cparam TYPE ssfctrlop,

w_outoptions TYPE ssfcompop,

w_bin_filesize TYPE i,

w_file_name type string,

w_file_path type string,

w_full_path type string.

  • 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.

SELECT * from lfa1 into TABLE ktab where lifnr = lifnr.

IF sy-subrc = 0.

SELECT * from ekko into TABLE ltab FOR ALL ENTRIES IN ktab WHERE

lifnr = ktab-lifnr.

ENDIF.

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 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZBHSFORM'

IMPORTING

FM_NAME = w_fmodule.

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 =

TABLES

ITAB = ktab

JTAB = ltab

  • 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.

START-OF-SELECTION.

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

TABLES

otf = t_otf

lines = t_pdf_tab.

  • 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.

  • Use the FM GUI_DOWNLOAD to download the generated PDF file onto the PC

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = w_bin_filesize

filename = w_full_path

FILETYPE = 'BIN'

tables

data_tab = t_pdf_tab.

hope this wud be useful to u

regards,

prashanti

Former Member
0 Kudos

&----


*& Report ZMR_INVOICE_TO_PDF

*&

&----


*&

*&

&----


report zmr_invoice_to_pdf.

data : v_fname type rs38l_fnam.

data : v_retdoc type ssfcrespd,

v_retval type ssfcrescl,

v_retspr type ssfcresop,

spoll_id type ssfcrescl-spoolids,

wa_spoll_id like line of spoll_id,

rspool_id type rspoid.

parameters : p_vbeln type vbrp-vbeln.

start-of-selection.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZSD_INVOICE'

importing

fm_name = v_fname

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.

call function v_fname

exporting

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

v_vbeln = p_vbeln

importing

document_output_info = v_retdoc

job_output_info = v_retval

job_output_options = v_retspr

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.

spoll_id = v_retval-spoolids.

read table spoll_id into wa_spoll_id index 1.

rspool_id = wa_spoll_id.

submit rstxpdft4

with spoolno = rspool_id

and return.

Former Member
0 Kudos

Hi Pols,

Check these links for sample code:

Regards,

Chandra Sekhar

Former Member
0 Kudos

Hi Pols,

Please check out the program RSTXPDFT4.

It enable to change a Spool order ( your form ) into a PDF file and download it.

Hope this helps,

Erwan

Former Member
0 Kudos

Hi,

Hope help this code to you.

DATA:
w_form_name TYPE tdsfname VALUE 'ZSURESH_TEST',
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
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
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
* 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 the generated PDF file onto the
* presentation server

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_FULL_PATH
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = T_pdf_tab
* FIELDNAMES =
* 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.

Thanks,

PhaniDiwakar.

Former Member
0 Kudos