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

Converting Spool to PDF Document

Former Member
0 Likes
3,107

Hi Gurus,

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

Thanks & Regards,

Sameej T.K.

View Entire Topic
thomas_jung
Developer Advocate
Developer Advocate
0 Likes

This is from a previous posting...

If you want to go to PDF, there is another approach.  There are SAP functions to convert SPOOL to PDF. They are CONVERT_ABAPSPOOLJOB_2_PDF and CONVERT_OTFSPOOLJOB_2_PDF. What you can do here is schedule your report as one step in a job and then your post processing as another step. You can use GET_JOB_RUNTIME_INFO to get the jobcount and jobname of the currently running job. You can then read back in table TBTCP to get the spool list number (listident) of a previous step.

Example:

clear jselect.

jselect-jobname = ''.

  jselect-username = '*'.

****Have this program get its own Job Name

  call function 'GET_JOB_RUNTIME_INFO'

       importing

*         EVENTID =

*         EVENTPARM =

*         EXTERNAL_PROGRAM_ACTIVE =

          jobcount = jselect-jobcount

          jobname = jselect-jobname

*         STEPCOUNT =

       exceptions

            no_runtime_info = 1

            others = 2.

****Read the spool number for this job step.

  clear tbtcp.

  select single listident from tbtcp

         into tbtcp-listident

         where jobname = jselect-jobname

           and jobcount = jselect-jobcount

           and stepcount = step.

  if tbtcp-listident = 0.

    message i009 with step.

  endif.

data: spool_id like tsp01-rqident.

  move tbtcp-listident to spool_id.

****Is this ABAP List Processing?

  if abap = 'X'.

    call function 'CONVERT_ABAPSPOOLJOB_2_PDF'

      exporting

        src_spoolid = spool_id

*       NO_DIALOG =

*       DST_DEVICE =

*       PDF_DESTINATION =

*     IMPORTING

*       PDF_BYTECOUNT =

*       PDF_SPOOLID =

*       LIST_PAGECOUNT =

*       BTC_JOBNAME =

*       BTC_JOBCOUNT =

      tables

        pdf = ipdf

     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.

    if sy-subrc <> 0.

      message i016 with sy-subrc.

    endif.

  else.

****Or is this SAPscript?

    call function 'CONVERT_OTFSPOOLJOB_2_PDF'

      exporting

        src_spoolid = spool_id

*       NO_DIALOG =

*       DST_DEVICE =

*       PDF_DESTINATION =

*     IMPORTING

*       PDF_BYTECOUNT =

*       PDF_SPOOLID =

*       OTF_PAGECOUNT =

*       BTC_JOBNAME =

*       BTC_JOBCOUNT =

      tables

        pdf = ipdf

     exceptions

       err_no_otf_spooljob = 1

       err_no_spooljob = 2

       err_no_permission = 3

       err_conv_not_possible = 4

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

    if sy-subrc <> 0.

      message i016 with sy-subrc.

    endif.

  endif.