cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Converting Spool to PDF Document

Former Member
0 Likes
3,112

Hi Gurus,

      Can anyone tell me how to convert the Spool to a PDF Document ??

Thanks & Regards,

Sameej T.K.

View Entire Topic
Former Member
0 Likes

Hi, ABAP experts,

Do you know where the PDF file is stored after the function module "CONVERT_ABAPSPOOLJOB_2_PDF" is executed? is it possible to store the converted PDF file in the frontend computer and how? thanks in advance,

J. Zhan

thomas_jung
Developer Advocate
Developer Advocate
0 Likes

Wll the PDF contents are passed back to the calling program in an internal table of structure TLINE.  You then can covert it to a table format that is ready to attach in an Email or write to the frontend or the server. The following is the routine that I usually use to do this:

data: ipdf        like tline occurs 0 with header line.

data: objbin           like solisti1 occurs 10 with header line.

perform convert_pdf tables ipdf

                             objbin.

*&----


*

*&      Form convert_pdf

*&----


*

*       Take the PDF information returned by the function module

*       and convert it to a file readable format. It currently is

*       in a printable-only format.

*----


*

*      -->P_IPDF PDF Source

*      -->P_OBJBIN PDF Destination

*----


*

form convert_pdf tables   t_source_tab structure ipdf

                          t_target_tab structure objbin.

  data: l_hfeld(1600) type c,

         l_offset type p,

         l_tabix like sy-tabix,

         l_max type i,

         l_linecount_source type i,

         l_length_source type i,

         l_length_target type i.

  • Zeilenlänge des Quell-PDF-Files

  describe field t_source_tab length l_length_source.

  • Zeilenlänge der Ziel-Mime-Tabelle

  describe field t_target_tab length l_length_target.

  • Zeilenanzahl des Quell-PDF-Files

  describe table t_source_tab lines l_linecount_source.

  • Die maximale Zielgröße wird durch das Feld l_hfeld begrenzt.

  l_max = l_length_target + l_length_source.

*  IF L_MAX > 1600.

*

*    RAISE CONVERT_NOT_POSSIBLE.

*

*  ENDIF.

  refresh t_target_tab.

  loop at t_source_tab.

    l_tabix = sy-tabix.

    move t_source_tab to l_hfeld+l_offset.

  • falls letzte zeile der quelltabelle erreicht

    if l_tabix = l_linecount_source.

      l_length_source = strlen( t_source_tab ).

    endif.

    l_offset = l_offset + l_length_source.

    while l_offset ge l_length_target.

      clear t_target_tab.

      t_target_tab = l_hfeld(l_length_target).

      append t_target_tab.

      shift l_hfeld by l_length_target places.

      l_offset = l_offset - l_length_target.

    endwhile. " l_offset ge p_length_target

  • falls letzte zeile der quelltabelle erreicht

    if l_tabix = l_linecount_source.

      if l_offset gt 0.

        clear t_target_tab.

        t_target_tab = l_hfeld(l_offset).

        append t_target_tab.

      endif. " l_offset gt 0

    endif. " l_tabix = l_linecount_lines

  endloop. " p_source_tab

endform.                    " convert_pdf

These results can be written to the frontend using a call to GUI_DOWNLOAD or CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD.

Former Member
0 Likes

As an alternative, SAP do provide a device type to issue print output in PDF format.  

Upload this device type as detailed in SAPnet note 317851 and print your output to a printer defined with this device type.  It is then possible to copy away your spool file to any desired location by changing the parameter rspo/host_spool/print for your printer to a script of your own design.

Former Member
0 Likes

hey, just try the reports

RSTXPDFT4 "Konvertiere SAPscript (OTF) oder ABAP-Listen-Spooljob nach PDF "

or RSTXPDFT5 "Test: GUI-Download eines Spoolauftrags"

and you will be able to download the pdf to your frontend.

Former Member
0 Likes

Thank you all...

Former Member
0 Likes

Hi Wei-Ming Tchay ,

I am working in SAP GUI FOR HTML for upgration from 5.00 to ECC 6.0.

In the ECC 5.0 One of my Tranaction is having reports. all the reports we are converting into PDF.

It is working fine in ECC 5.0.

In ECC 6.0 because of UNICODE i am getting error "File does not begin with '%PDF-'.

i serached the OSS notes I found 1320163 .

In my program I am using FM to get PDF in Bytes CONVERT_ABAPSPOOLJOB_2_PDF.

The out put is coming in Internal Table.

I am using macros.

MIME-DOWNLOAD T_PDF MIMELENGTH 'application/pdf'. getting the PDF in ECC5.0 .

but in ECC 6.0 Unicode it is error.

I thought as per the note 1320163 i can convert into Xstring after that I can move to Table.

Kindly help me If you done for the MIME-DOWNLOAD Macros.

Thanks in advance.

dev