Wednesday, May 20, 2009

Create PDF file from SMTF without spool number

REPORT ZISI_TEST.


DATA: cparam TYPE ssfctrlop,

      outop TYPE ssfcompop,
     
fm_name TYPE rs38l_fnam,
     
my_tabix TYPE sy-tabix,
     
file_size TYPE i,
     
bin_filesize TYPE i.



DATA: tab_otf_data TYPE ssfcrescl,
     
pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
     
otab TYPE TABLE OF sflight WITH HEADER LINE,
     
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE.



START-OF-SELECTION.

  outop-tddest = 'LP01'.

  cparam-no_dialog = ''.

  cparam-preview = space.

  cparam-getotf = 'X'.



*****************for the first smartform********************************

  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

      formname           = 'I18N_PRINT_TEST_SF_EN'

    IMPORTING

      fm_name            = fm_name

    EXCEPTIONS

      no_form            = 1

      no_function_module = 2

      OTHERS             = 3.



  CALL FUNCTION fm_name

    EXPORTING

      control_parameters = cparam

      output_options     = outop

      user_settings      = space

    IMPORTING

      job_output_info    = tab_otf_data

    EXCEPTIONS

      formatting_error   = 1

      internal_error     = 2

      send_error         = 3

      user_canceled      = 4

      OTHERS             = 5.

  tab_otf_final[] = tab_otf_data-otfdata[].

  CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

      format                = 'PDF'

      max_linewidth         = 132

    IMPORTING

      bin_filesize          = bin_filesize

    TABLES

      otf                   = tab_otf_final

      lines                 = pdf_tab

    EXCEPTIONS

      err_max_linewidth     = 1

      err_format            = 2

      err_conv_not_possible = 3

      err_bad_otf           = 4

      OTHERS                = 5.



*************downloading the converted PDF data to your local PC********



  CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

      bin_filesize            = bin_filesize

      filename                = 'D:\TEST.PDF'

      filetype                = 'BIN'

    IMPORTING

      filelength              = file_size

    TABLES

      data_tab                = pdf_tab

    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.




No comments:

Post a Comment