cancel
Showing results for 
Search instead for 
Did you mean: 

Smartforms: PDF Conversion

Former Member
0 Kudos

Hi All,

When an output for invoice is converted to PDF, the Traditional Chinese language is not appearing ( The invoice is in the chinese language) . But in my print preview Or When its printed ( Not Via PDF ) its printing perfectly.

Any help is appreciated.

Regards,

Sai Srinivas D

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Downloading Smart Form to PDF from Application

You can pass data retrieved from the application to the Smart form using the Form Interface. The data could

also include the data retrieved from database tables. In addition, you can define exceptions to which the

application program must react. You trigger form printing by calling only two function modules. The first

module uses the name of the form to determine the name of the generated function module. Then you call

this Smart form.

Call function module SSF_FUNCTION_MODULE_NAME. It returns the name of the generated function

module. Call the generated function module. To do this, use the Insert statement function for CALL

FUNCTION in the ABAP Editor. Then replace the function module name with the variable FM_NAME. Set the

u2018GETOTFu2019 parameter to u2018Xu2019 and pass it to CONTROL_PARAMETERS. The function module would export the

Smart form to an internal table u2018T_OTFDATAu2019.

Call the function module u2018CONVERT_OTFu2019 to convert the smart form to PDF format. The function module

returns the size of downloaded file. Using u2018WS_DOWNLOADu2019 function module, you can download the Smart

form to a PDF file in the required directory.

Sample Code

REPORT zswar.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME.

PARAMETER: p_date LIKE sy-datum.

PARAMETER: p_rea TYPE char255.

SELECTION-SCREEN: END OF BLOCK b1.

DATA: ws_ucomm LIKE sy-ucomm.

INITIALIZATION.

SET PF-STATUS 'STANDARD' OF PROGRAM 'ZSWAR'.

AT SELECTION-SCREEN.

ws_ucomm = sy-ucomm.

CASE ws_ucomm.

WHEN '&PDF'.

PERFORM f1000_download_form.

EXIT.

WHEN '&BACK'.

SET SCREEN 0.

EXIT.

WHEN '&EXIT'.

SET SCREEN 0.

EXIT.

WHEN '&canc'.

SET SCREEN 0.

LEAVE TO SCREEN 0.

ENDCASE.

*&----


*

*& Form F1000_DOWNLOAD_FORM

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM f1000_download_form.

DATA: form_name TYPE rs38l_fnam.

DATA: wa_ctrlop TYPE ssfctrlop,

wa_outopt TYPE ssfcompop.

DATA: t_otfdata TYPE ssfcrescl,

t_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.

Tutorial on SMART FORMS

© 2005 SAP AG 7

DATA: t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE.

DATA: w_filesize TYPE i.

DATA: w_bin_filesize TYPE i.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZSMARTFORM_SWAR'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = form_name

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.

wa_ctrlop-getotf = 'X'.

wa_ctrlop-no_dialog = 'X'.

wa_outopt-tdnoprev = 'X'.

CALL FUNCTION form_name

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = wa_ctrlop

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

output_options = wa_outopt

user_settings = 'X'

mydate = p_date

reason = p_rea

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

job_output_info = t_otfdata

  • 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_otfdata-otfdata[].

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

Tutorial on SMART FORMS

© 2005 SAP AG 8

max_linewidth = 132

  • ARCHIVE_INDEX = ' '

IMPORTING

bin_filesize = w_bin_filesize

TABLES

otf = t_otf

lines = t_pdf_tab

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

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

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

bin_filesize = w_bin_filesize

  • CODEPAGE = ' '

filename = 'd: est.PDF'

filetype = 'BIN'

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

IMPORTING

filelength = w_filesize

TABLES

data_tab = t_pdf_tab

  • 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

.

IF sy-subrc <> 0.

MESSAGE i003(z00) WITH 'File not downloaded succesfully'.

ELSE.

MESSAGE i003(z00) WITH 'File Test.pdf downloaded succesfully '

'under D drive'.

ENDIF.

ENDFORM. " F1000_DOWNLOAD_FORM

Former Member
0 Kudos

you can use this code in print program to convert smart form out put into PDF format

*--Converting smartform output to pdf file with creating a spool request

REPORT ZFORM1_CALL .

DATA: OUTPUT_OPTIONS LIKE SSFCTRLOP.

DATA: V_SIZE TYPE I.

*OUTPUT_OPTIONS-TDDEST = 'OTF_MEM'.

*OUTPUT_OPTIONS-TDPRINTER = 'IND5'.

*OUTPUT_OPTIONS-TDIMMED = 'X'.

*OUTPUT_OPTIONS-TDCOPIES = '1'.

*OUTPUT_OPTIONS-DEVICE = 'PRINTER'.

OUTPUT_OPTIONS-GETOTF = 'X'.

OUTPUT_OPTIONS-no_dialog = 'X'.

DATA: s_job_output_info TYPE SSFCRESCL.

CALL FUNCTION '/1BCDWB/SF00000259'

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

CONTROL_PARAMETERS = OUTPUT_OPTIONS

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS = OUTPUT_OPTIONS

USER_SETTINGS = ' '

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

JOB_OUTPUT_INFO = s_job_output_info

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

ELSE.

        • 2. convert the OTF data to PDF

DATA: L_PDF_LEN TYPE I.

DATA: output_data LIKE ITCOO OCCURS 0 WITH HEADER LINE,

IT_LINES LIKE TLINE OCCURS 0 WITH HEADER LINE.

*--CONVERTING IT TO PDF CONTENT

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = l_pdf_len

  • bin_file = l_pdf_xstring

TABLES

otf = s_job_output_info-OTFDATA

lines = It_lines

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

*--DOWNLOADING PDF FILE

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

BIN_FILESIZE = l_pdf_len

  • CODEPAGE = ' '

FILENAME = 'C:\FILE.PDF'

FILETYPE = 'BIN'

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = IT_LINES

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

IF SY-SUBRC <> 0.

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

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

ELSE.

MESSAGE I004(ZBDC) WITH 'FILE DOWNLOADED'.

ENDIF.

ENDIF.

Former Member
0 Kudos

Hi,

For PDF conversion the font size should support.

Please check SAP note for this traditional language printing.

I also got the same problem for Arabic printing.

Regards,

Raju.