Application Development 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: 

Download to PDF

Former Member
0 Kudos

Hi Gurus,

I have added a 'Download to PDF' button in my report output. I am able to save the report output in PDF format in local system,

but I am unable to open it, it shows some error while opening the report.

Currently, I am using CALL FUNCTION 'GUI_DOWNLOAD' to save the report in PDF format.

Can anyone please help me in opening the saved PDF file ?

Thanks,

Chandan

17 REPLIES 17

Former Member
0 Kudos

Hi,

What is the file type you are mentioning in the GUI_DOWNLOAD FM? Did u try with


filetype  = 'BIN'

Regards,

Vik

0 Kudos

No I am using file type like rlgrap-filetype VALUE 'ASC'.

Please suggest more on this.

Former Member
0 Kudos

Hi,

Then try setting the file type as 'BIN' in GUI_DOWNLOAD and check. Also what is the FM you are using to convert the report output to PDF?

- For ABAP LIST use : CONVERT_ABAPSPOOLJOB_2_PDF.

- For Sapscript and smartforms use: CONVERT_OTFSPOOLJOB_2_PDF.

If you are using CONVERT_OTFSPOOLJOB_2_PDF, you have to convert OTF to PDF with the below FM


CALL FUNCTION "CONVERT_OTF"
       EXPORTING   FORMAT                = "PDF"
       IMPORTING    BIN_FILESIZE         = FILE_LEN
       TABLES         OTF                        = OTFDATA
                             LINES                      = PDFDATA

Regards,

Vik

0 Kudos

Using BIN is slowing down the processing. Taking long time. Can not afford that.

I am not using any of the FMs that you mentioned.

I just did the below:

DATA: filename   TYPE string,
          ftype      LIKE rlgrap-filetype VALUE 'BIN',
          filetype   TYPE char10.
* fix problem with gui_download
    filename = 'C:\SPD_Analys2_Report.PDF'.
    filetype = ftype.
    w_act_filename = filename.
**ctf 12768  replaced ws_download with GUi_download
    CLEAR w_filecopy_ok.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                      = filename
        filetype                      = filetype
        write_field_separator         = 'X'
*     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                     = ' '
*   IMPORTING
*     FILELENGTH                    =
      TABLES
        data_tab                      = t_download
     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.

Can you please describe in details.....

which FM to use first and then which one next...

Edited by: chandan sinha on Aug 11, 2009 1:45 PM

0 Kudos

Hi,

Well before using GUI_DOWNLOAD you have to use the FM CONVERT_OTF to convert the internal table to PDF and then use it in GUI_DOWNLOAD.

Check this for your reference.



DATA: pdftab type standard TABLE OF tline.

CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = BINFILE
TABLES
otf = t_download
lines = pdftab

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = binfile
filename = 'D:\MYFILE.PDF' //give the address where u want output.
FILETYPE = 'BIN'.

Regards,

Vik

0 Kudos

Vik,

This is what I did....I am getting an exception " RAISE ERR_CONV_NOT_POSSIBLE" , hence a short dump.

DATA: filename   TYPE string,
          ftype      LIKE rlgrap-filetype VALUE 'BIN',
          filetype   TYPE char10,
          binfile    type i,
          pdftab     type standard table of tline.
* fix problem with gui_download
    filename = 'C:\SPD_Analys2_Report.PDF'.
    filetype = ftype.
    w_act_filename = filename.

**--> PDF FM Used
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        FORMAT       = 'PDF'
      IMPORTING
        BIN_FILESIZE = binfile
      TABLES
        otf          = t_download
        lines        = pdftab.

**ctf 12768  replaced ws_download with GUi_download
    CLEAR w_filecopy_ok.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        BIN_FILESIZE                  = binfile
        filename                      = filename
        filetype                      = filetype
        write_field_separator         = 'X'

Please help yaar....

0 Kudos

Hi,

Looks like CONVERT_OTF can only convert smartform or script to pdf instead of internal table. One more way is to convert the internal table to spool and then convert the spool to pdf and diwnload it.

Check this link, a clear example is given.

[]

Regards,

Vik

0 Kudos

This seems a long and hectic process.

Can you tell me any easy and faster process ???

0 Kudos

Hi,

I dont think its possible to convert a internal table to pdf without using the spool concept. So i dont think there is any other way to do this.

Regards,

Vik

0 Kudos

Even Spool is not working, it is converting into some garbage data.

Please suggest some accurate ways.....

0 Kudos

Hi,

Check this wiki. Its clear and self descriptive.

[https://wiki.sdn.sap.com/wiki/display/ABAP/PDFDownlaodByCreatingSpool+Request]

Regards,

Vik

Former Member
0 Kudos

Hi Frn ,

Please refer the given below link

u2022 NAME / TITLE OF WIKI : Spool request program for pdf

u2022 URL OF THE WIKI POSTED : https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/pdfDownlaodByCreatingSpool+Request

Thanks and Regards ..

Priyank dixit

0 Kudos

This message was moderated.

0 Kudos

Hello Frn ,

i had already given an example in the above mentioned wikki ....Please read and use that code ..

Thanks and Regards ..

Priyank

0 Kudos

Hello

I consider that you has received it is enough information for decision of your problem. SDN - not that place where someone will do your work for you.

Former Member
0 Kudos

solved

Former Member
0 Kudos

Hi

Plz tell us how did you solve the problem

Thanks