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

function module to down load the pdf

Former Member
0 Likes
1,781

Hai

I have a program that which converts the printfile file to a PDF and is getting stored in C drive in a separate folder.

How can i down load that pdf file into an internal table.what is the type of the internal table i must declare.

what are the necessary steps to follow.

kindly help me in this out.

6 REPLIES 6
Read only

Former Member
1,540

This message was moderated.

Read only

Former Member
0 Likes
1,540

Hi,

You can use GUI_UPLOAD to upload that file into an internal table.

Regards,

Manish

Read only

Former Member
0 Likes
1,540

Hi,

Refer to the given code:

DATA: lv_filetype(10) TYPE c,

lv_gui_sep TYPE c,

lv_file_name TYPE string.

lv_filetype = 'ASC'.(give PDF)

lv_gui_sep = 'X'.

lv_file_name = pa_dfile(give the path of the file).

  • FM call to upload file

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lv_file_name

filetype = lv_filetype

has_field_separator = lv_gui_sep

TABLES

data_tab = gi_tab

Regards,

Rajesh Kumar

Read only

Former Member
0 Likes
1,540

<and create Spool request for Internal Table or Output table..

CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'

EXPORTING

dest = 'LOCL'

  • LAYOUT =

  • NAME =

  • SUFFIX1 =

  • SUFFIX2 =

  • COPIES =

  • PRIO =

  • IMMEDIATE_PRINT =

  • AUTO_DELETE =

  • TITLELINE =

  • RECEIVER =

  • DIVISION =

  • AUTHORITY =

  • POSNAME =

  • ACTTIME =

  • LIFETIME = '8'

  • APPEND =

  • COVERPAGE =

  • CODEPAGE =

  • DOCTYPE =

IMPORTING

handle = v_handle

spoolid = gd_spool_nr

rc = v_rc

errmessage = v_errmessage.

LOOP AT i_mara.

v_text = i_mara-matnr.

CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'

EXPORTING

handle = v_handle

text = v_text

  • LENGTH =

  • CODEPAGE =

  • TRUNCATE =

IMPORTING

rc = v_rc

errmessage = v_errmessage

EXCEPTIONS

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

ENDLOOP.

CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'

EXPORTING

handle = v_handle

IMPORTING

rc = v_rc

errmessage = v_errmessage

EXCEPTIONS

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

and convert ABAP spool to PDF..

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = gd_spool_nr

no_dialog = c_no

dst_device = c_device

IMPORTING

pdf_bytecount = gd_bytecount

TABLES

pdf = it_pdf_output

EXCEPTIONS

err_no_abap_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_destdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11

OTHERS = 12.

CHECK sy-subrc = 0.

and Down load the PDF to desk top..

GUI_DOWNLOAD.

>

Regards,

ShreeMohan

Read only

Former Member
0 Likes
1,540

Hi,

To Convert Smartform to PDF and store in desktop,

*&---------------------------------------------------------------------*
*& Report  ZTEST_NREDDY_PDF
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  ZTEST_NREDDY_PDF.
* Internal table declaration
DATA: it_otf      TYPE STANDARD TABLE OF itcoo,
      it_docs     TYPE STANDARD TABLE OF docs,
      it_lines    TYPE STANDARD TABLE OF tline.
* Declaration of local variables.
DATA:
      st_job_output_info       TYPE ssfcrescl,
      st_document_output_info  TYPE ssfcrespd,
      st_job_output_options    TYPE ssfcresop,
      st_output_options        TYPE ssfcompop,
      st_control_parameters    TYPE ssfctrlop,
      v_len_in                 TYPE so_obj_len,
      v_language               TYPE sflangu VALUE 'E',
      v_e_devtype              TYPE rspoptype,
      v_bin_filesize           TYPE i,
      v_name                   TYPE string,
      v_path                   TYPE string,
      v_fullpath               TYPE string,
      v_filter                 TYPE string,
      v_uact                   TYPE i,
      v_guiobj                 TYPE REF TO cl_gui_frontend_services,
      v_filename               TYPE string,
      v_fm_name                TYPE rs38l_fnam.
CONSTANTS c_formname           TYPE tdsfname VALUE 'ZTEST'.
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
  EXPORTING
    i_language          = v_language
    i_application       = 'SAPDEFAULT'
  IMPORTING
    e_devtype           = v_e_devtype.
st_output_options-tdprinter = v_e_devtype.
st_control_parameters-no_dialog = 'X'.
st_control_parameters-getotf = 'X'.
*.................GET SMARTFORM FUNCTION MODULE NAME.................*
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname = c_formname
  IMPORTING
    fm_name  = v_fm_name
  EXCEPTIONS
    no_form  = 1
   no_function_module = 2   
    OTHERS   = 3.
*...........................CALL SMARTFORM............................*
CALL FUNCTION v_fm_name
  EXPORTING
    control_parameters = st_control_parameters
    output_options     = st_output_options
  IMPORTING
    document_output_info  = st_document_output_info
    job_output_info       = st_job_output_info
    job_output_options    = st_job_output_options
  EXCEPTIONS
    formatting_error = 1
    internal_error   = 2
    send_error       = 3
    user_canceled    = 4
    OTHERS           = 5.
*.........................CONVERT TO OTF TO PDF.......................*
  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.
 *........................GET THE FILE NAME TO STORE....................*
  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.
*..................................DOWNLOAD AS FILE....................*

  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.

Read only

Former Member
0 Likes
1,540

Hi,

When calling the function module generated by smart form we will pass the internal table name to get the desired output. But to save it as a PDF format

we have to export certain parameters to the generated function module.

They are

a) Control_Parameters: To access the OTF table, we have to pass

get-OTF =u2019Xu2019.

b) Output_options: To print settings. For this we have to pass tddest = 'LP01u2019.

We have to import following parameters:

They are

a) JOB_Ouput_Info: To import the table in the OTF format.

Now we can convert the OTF table into PDF format using function module 'Convert_OTF'. And we can save it using 'GUI_DOWNLOAD'.

Thank you,

Pavan.