Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

pdf Print

Former Member
0 Likes
818

Hi All,

when i execute my form i'll get two options i,e Print & Print Preview.

user needs when he clicks on Print he needs output in PDF format how to

approach to this..

Regards

Suprith

8 REPLIES 8
Read only

Former Member
0 Likes
768

Hi Suprit,

Refer to this link...

Converting Script to pdf..

Converting SMARTFORM to pdf..

for more info:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/49e15474-0e01-0010-9cba-e62df824...

Thanks!!

Read only

Former Member
0 Likes
768

Hi,

In the NACE transaction, you can assign PDF TYPE for the output type and the smartform which you are using.

Go to Nace, find the appication and then output types and then click your output type then processing routines,

Now check the printout as medium and at the last type as PDF..

Regards,

Venkatesh

Read only

Former Member
0 Likes
768

Hi,

look after this wiki.

https://wiki.sdn.sap.com/wiki/display/Snippets/Smartform%2boutput%2bto%2bPDF%2bformat

If required make changes according to this wiki.It might help you a lot.

Regards,

Anand

Read only

Former Member
0 Likes
768

hi

try using the program 'RSTXPDFT4'.

also try to convert the spool job to PDF using function module CONVERT_OTFSPOOLJOB_2_PDF

hope this helps

regards

Aakash Banga

Read only

Former Member
0 Likes
768

click on the print button of Print Prieview

then u will get the spool number.

go to SE38 -> report name 'RSTXPDFT4' run it and give the spool number and run that report.

It will ask you to save that print in PDF.

Regards,

Joan

Read only

Former Member
0 Likes
768

at first put this...


  CALL FUNCTION 'K_KKB_POPUP_RADIO2'
    EXPORTING
      i_title   = 'Type Of OutPut'
      i_text1   = 'Normal Output'
      i_text2   = 'PDF Output'
      i_default = '1'
    IMPORTING
      i_result  = i_result
    EXCEPTIONS
      cancel    = 1
      OTHERS    = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

then...


  IF i_result = '2'.

    DATA:
    w_form_name TYPE tdsfname VALUE '<SAMRTFORM_NAME>',
    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.


    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 = 'LOCL'.

    CALL FUNCTION w_fmodule
    EXPORTING
       wa_ekko                   = wa_ekko
         wa_adrc                 = wa_adrc
         wa_ecc                  = wa_ecc
         wa_range1               = wa_range1
         wa_range2               = wa_range2
         wa_bednr                = wa_bednr
         wa_banfn                = wa_banfn
         wa_revno                = wa_revno
         wa_vat                  = wa_vat
         wa_cst                  = wa_cst
         count                   = count
         wa_slfdt                = wa_slfdt
         wa_menge1               = wa_menge1
         wa_menge                = wa_menge
         wa_telfx                =  wa_telfx
         wa_month                = wa_month
         wa_year                 = wa_year
         wa_ernam                = wa_ernam
         wa_email                = wa_email
         wa_adrc_copy            = wa_adrc_copy
         wa_pspel                = wa_pspel
         wa_werks                = wa_werks
*        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
        job_output_info = t_otf_from_fm
*        DOCUMENT_OUTPUT_INFO =
        TABLES
         it_eket                = it_eket
         it_text                = it_text
         line                   = line
         it_adrc_new            = it_adrc_new
         it_esll                = it_esll

*     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
*************************************************************************
    DATA : w_archive LIKE	toa_dara VALUE space.

    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
        max_linewidth         = 132
        archive_index         = w_archive
        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 = 'c:\Documents and Settings\2q\Desktop' "'\\jumbo\fileshares'
*     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.
*************************************************************************
*  ENDIF.


  ENDIF.

Read only

Former Member
0 Likes
768

copy-paste from: sixth such offense from the same user

If you repeat next time you will loose 100 points

Edited by: Vijay Babu Dudla on Jan 21, 2009 7:15 AM

Read only

Former Member
0 Likes
768

Hi,

One more thing what you can do is .....comment this code ...ST_CONTROL_PARAMETERS-GETOTF = 'X'. and pass space to ST_CONTROL_PARAMETERS-NO_DIALOG ...when you get the Pop-up screen for the Print and print priview ..click on the print privew you get the view window from the menu TEXT->Print. then the spool is generated.

Use this RSTXPDFT4 to convert the spool to PDF. If the there is any error in generating the PDF then the what ever deveice type your getting in this V_E_DEVTYPE is enable to conver to PDF....try check for the any other Device Type and test.

You can find the Device types from Tcode SPAD.