cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Smartform to PDF

former_member230486
Contributor
0 Kudos

When I am converting Smartform to PDF it shows that 0 bytes transfered.

I used convert_otf function module like this

CALL FUNCTION 'CONVERT_OTF'
 EXPORTING
   FORMAT                      = 'PDF'
   MAX_LINEWIDTH               = 132
 IMPORTING
   BIN_FILESIZE                = V_bin_filesize
  TABLES
    otf                         = st_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
          .
  CONCATENATE 'smrt' '.pdf' INTO v_name.
  CREATE OBJECT v_guiobj.
  CALL METHOD v_guiobj->file_save_dialog
    EXPORTING
      default_extension  = 'pdf'
      default_file_name  = v_name
      file_filter        = v_filter
    CHANGING
      filename           = v_name
      path               = v_path
      fullpath           = v_fullpath
      user_action        = v_uact.
  IF v_uact = v_guiobj->action_cancel.
    EXIT.
  ENDIF.
 MOVE v_fullpath TO v_filename.
 CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
    BIN_FILESIZE                    = v_bin_filesize
     filename                        = v_filename
    FILETYPE                        = 'BIN'
   tables
     data_tab                        = IT_LINES
  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.

<Added code tages>

Edited by: Suhas Saha on Jul 20, 2011 12:15 PM

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

Try tp pass the otf data like this in the FM convert_otf,use the body operator.

st_job_output_info-otfdata[]

Former Member
0 Kudos

Hi,

Please check the below sample code:

data: tl_otfdata TYPE STANDARD TABLE OF itcoo,

tl_doctab TYPE STANDARD TABLE OF docs,

tl_pdf TYPE STANDARD TABLE OF tline,

vl_filename TYPE string,

vl_bytes TYPE i.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = vl_bytes

TABLES

otf = tl_otfdata "Your OTF data

doctab_archive = tl_doctab "Empty

lines = tl_pdf "Return pdf data

EXCEPTIONS

err_conv_not_possible = 1

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

vl_filename = 'test.PDF'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = vl_bytes

filename = vl_filename

filetype = 'BIN'

TABLES

data_tab = tl_pdf

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 NE 0.

MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Former Member
0 Kudos

Hi,

Please check the below sample code to convert it into PDF and to download it in presentations erver.

Data: t_otf TYPE table of itcoo   WITH HEADER LINE,
      t_pdf_tab type table of tline  WITH HEADER LINE.

* 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
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
F 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
CHANGING
filename = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_FULL_PATH
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'
tables
data_tab = T_pdf_tab.

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Hope this solves your issue.

Please let me know if any queries.

Thanks,

Rajani

Former Member
0 Kudos

Hi sapabap403,

Follow the below code , i have used this and got exact output.

*Getting the device parameters and transmission mode
  CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
    EXPORTING
      pi_nast       = nast
      pi_country    = lv_dlv-land
      pi_addr_key   = lv_addr_key
      pi_repid      = sy-repid
      pi_screen     = lc_x
    IMPORTING
      pe_returncode = gv_retcode
      pe_itcpo      = lv_itcpo
      pe_device     = lv_device
      pe_recipient  = lv_recipient
      pe_sender     = lv_sender.
  IF gv_retcode = 0.
*moving the data to composer and control parameters for output
    MOVE-CORRESPONDING lv_itcpo TO lv_composer_param.
    lv_control_param-device      = lv_device.
    lv_control_param-no_dialog   = lc_x.
    lv_control_param-preview     = lc_x.
    lv_control_param-getotf      = lv_itcpo-tdgetotf.
    lv_control_param-langu       = nast-spras.
    lv_composer_param-tdnoprint = space.
  ENDIF.

*Getting the Smartform Function module using Standard Function module
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname                 = lv_formname           "Smartform Name
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
   IMPORTING
     fm_name                  = lv_fm_name
   EXCEPTIONS
     no_form                  = 1
     no_function_module       = 2
     OTHERS                   = 3
            .
  IF sy-subrc <> 0.
*   error handling
    gv_retcode = sy-subrc.
    PERFORM protocol_update.
* get SmartForm protocoll and store it in the NAST protocoll
    PERFORM add_smfrm_prot.
  ENDIF.

**Smartform function module to get the output
  CALL FUNCTION lv_fm_name
    EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
     control_parameters         = lv_control_param
*   MAIL_APPL_OBJ              =
   mail_recipient             = lv_recipient
   mail_sender                = lv_sender
     output_options             = lv_composer_param
     user_settings              = ' '
      is_bil_invoice             = lv_bil_invoice
      gt_header                  = gt_header
   IMPORTING
*   DOCUMENT_OUTPUT_INFO       = gv_job_output
     job_output_info            = gv_job_output
*   JOB_OUTPUT_OPTIONS         =
    TABLES
      gt_item                    = gt_item
   EXCEPTIONS
     formatting_error           = 1
     internal_error             = 2
     send_error                 = 3
     user_canceled              = 4
     OTHERS                     = 5
            .
  IF sy-subrc <> 0.
*   error handling
    gv_retcode = sy-subrc.
    PERFORM protocol_update.
* get SmartForm protocoll and store it in the NAST protocoll
    PERFORM add_smfrm_prot.
  ENDIF.

Thanks

Suren

koolspy_ultimate
Active Contributor
0 Kudos

hi use this code instead of CALL FUNCTION 'CONVERT_OTF'


  call function 'CONVERT_OTF_2_PDF'
* EXPORTING
*   USE_OTF_MC_CMD               = 'X'
*   ARCHIVE_INDEX                =
     importing
       bin_filesize                 = v_bin_filesize
     tables
       otf                          = st_job_output_info-otfdata
       doctab_archive               = it_docs
       lines                        = it_lines
     exceptions
       err_conv_not_possible        = 1
       err_otf_mc_noendmarker       = 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 method v_guiobj->file_save_dialog
    EXPORTING
      default_extension = 'pdf'
      default_file_name = v_name
      file_filter       = v_filter
    CHANGING
      filename          = v_name
      path              = v_path
      fullpath          = v_fullpath
      user_action       = v_uact.
  if v_uact = v_guiobj->action_cancel.
    exit.
  endif.

*..................................DOWNLOAD AS FILE....................*
  move v_fullpath to v_filename.

  call function 'GUI_DOWNLOAD'
.
.

hope this solves your problem.

former_member230486
Contributor
0 Kudos

When I am converting Smartform to PDF it shows that 0 bytes transfered.

I used convert_otf function module and then download using gui_download.

Former Member
0 Kudos

Hi,

Are you using GUI_download to downloa dteh smartform PDF ?

Gui download is used to download internal tables.

Former Member
0 Kudos

Hi,

Just change the Convert_otf Function module like this

no need to pass the value in Export Parameters.


  CALL FUNCTION 'CONVERT_OTF_2_PDF'
    IMPORTING
      bin_filesize   = v_bin_filesize
    TABLES
      otf            = st_job_output_info-otfdata
      doctab_archive = it_docs
      lines          = it_lines
    EXCEPTIONS
      err_conv_not_possible  = 1
      err_otf_mc_noendmarker = 2
      OTHERS                            = 3.

Just ref the link : http://wiki.sdn.sap.com/wiki/display/Snippets/ConvertSmartformtoPDFformat

Regards,

Dhina..

former_member230486
Contributor
0 Kudos

Even if I am using convert_otf_2_pdf according to you I am getting OTF end command // missing in OTF data error and goes to dump.

Former Member
0 Kudos

hi,

use CONVERT_OTF_2_PDF function module and pass archive_index = tao_dara as importing parameter. after that archive the PDF file by using the FM CONVERT_OTF_AND_ARCHIVE.

you can also refer to the following link:

http://sap.ittoolbox.com/groups/technical-functional/sap-dev/smartform-will-not-archive-when-outputt...

i hope it helps.

Regards,

Dhina..

Former Member
0 Kudos

Dear All,

I am facing the problem OTF end command // missing in OTF data error and the system is throwing dump.

I am using CONVERT_OTF_2_PDF FM.

Best wishes,

Atanu