Skip to Content
0
Former Member
Dec 08, 2009 at 11:31 AM

Error when Converting smartform into PDF

433 Views

Hello ..

I'm working on a development where I have to give an option to user to save the smartform in PDF forma ..

My code is as below:

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname = c_formname
    IMPORTING
      fm_name  = l_form_name
 EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.

if sf_pdf = 'X'. "RadioButton to save smartform as pdf
  x_cparam-getotf = 'X'.
endif.

 CALL FUNCTION l_form_name
 EXPORTING
   control_parameters = x_cparam
 IMPORTING
      job_output_info        = x_main_str
 EXCEPTIONS
      formatting_error       = 1
      internal_error         = 2
      send_error             = 3
      user_canceled          = 4
      OTHERS                 = 5.

endif.

*** FUNCTION MODULE TO CONVERT SMARTFORM TO PDF

IF sf_pdf = 'X'.

 CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
      IMPORTING
        bin_filesize          = v_fsize " RETURNS FILESIZE OF THE PDF
      TABLES
        otf                   = x_main_str-otfdata    "OTFDATA FIELD OF X_MAIN-STR
        lines                 = x_i_line
      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.

  
*** FUNCTION MODULE TO DOWNLOAD THE PDF ON USER'S SYSTEM.

    CALL FUNCTION 'DOWNLOAD'
      EXPORTING
        bin_filesize            = v_fsize
        filename                = 'c:\InspectionPlan_Report.pdf'
        filetype                = 'BIN'
      TABLES
        data_tab                = x_i_line
      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
        no_authority            = 10
        OTHERS                  = 11.

ENDIF.

when I execute the code, I get this error: OTF end command // missing in OTF data

I am not abl to solve it .. kindly help ..