Problem converting ABAP list into PDF

Hello,
Having converted a spool request of an abap list into pdf the "intensified" attribute of the list items will disappeare. Text in the list with i.e. COL_BACKGROUND INTENSIFIED would be converted to text with blue and normal font. None of the possible combinations of colours and intenstions have produced an output in bold.
Any ideas would be appreciated.
Thank you in advance.
Best regards,
Michael Weiskat

Save Report Output to a PDF File
This report takes another report as input, and captures the output of that report. The output is then converted to PDF and saved to a local file. This shows how to use some of the PDF function modules, as well as an easy way to create PDF files.
Source Code Listing
report zabap_2_pdf.
*-- Enhancements: only allow to be run with variant.  Then called
*-- program will be transparent to users
*-- TABLES
tables:
  tsp01.
*-- STRUCTURES
data:
  mstr_print_parms like pri_params,
  mc_valid(1)      type c,
  mi_bytecount     type i,
  mi_length        type i,
  mi_rqident       like tsp01-rqident.
*-- INTERNAL TABLES
data:
  mtab_pdf    like tline occurs 0 with header line,
  mc_filename like rlgrap-filename.
*-- SELECTION SCREEN
parameters:
  p_repid like sy-repid, " Report to execute
  p_linsz like sy-linsz default 132, " Line size
  p_paart like sy-paart default 'X_65_132'.  " Paper Format
start-of-selection.
concatenate 'c:\'
            p_repid
            '.pdf'
  into mc_filename.
*-- Setup the Print Parmaters
  call function 'GET_PRINT_PARAMETERS'
   exporting
     authority= space
     copies   = '1'
     cover_page                   = space
     data_set = space
     department                   = space
     destination                  = space
     expiration                   = '1'
     immediately                  = space
     in_archive_parameters        = space
     in_parameters                = space
     layout   = space
     mode     = space
     new_list_id                  = 'X'
     no_dialog= 'X'
     user     = sy-uname
   importing
     out_parameters               = mstr_print_parms
     valid    = mc_valid
   exceptions
     archive_info_not_found       = 1
     invalid_print_params         = 2
     invalid_archive_params       = 3
     others   = 4.
*-- Make sure that a printer destination has been set up
*-- If this is not done the PDF function module ABENDS
  if mstr_print_parms-pdest = space.
    mstr_print_parms-pdest = 'LOCL'.
  endif.
*-- Explicitly set line width, and output format so that
*-- the PDF conversion comes out OK
  mstr_print_parms-linsz = p_linsz.
  mstr_print_parms-paart = p_paart.
  submit (p_repid) to sap-spool without spool dynpro
                   spool parameters mstr_print_parms
                   via selection-screen
                   and return.
*-- Find out what the spool number is that was just created
  perform get_spool_number using sy-repid
             sy-uname
    changing mi_rqident.
*-- Convert Spool to PDF
  call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
      src_spoolid= mi_rqident
      no_dialog  = space
      dst_device = mstr_print_parms-pdest
    importing
      pdf_bytecount                  = mi_bytecount
    tables
      pdf        = mtab_pdf
    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.
call function 'DOWNLOAD'
     exporting
          bin_filesize            = mi_bytecount
          filename                = mc_filename
          filetype                = 'BIN'
     importing
          act_filename            = mc_filename
     tables
          data_tab                = mtab_pdf.
      FORM get_spool_number *
      Get the most recent spool created by user/report              *
-->  F_REPID               *
-->  F_UNAME               *
-->  F_RQIDENT             *
form get_spool_number using f_repid
     f_uname
                changing f_rqident.
  data:
    lc_rq2name like tsp01-rq2name.
  concatenate f_repid+0(8)
              f_uname+0(3)
    into lc_rq2name separated by '_'.
  select * from tsp01 where  rq2name = lc_rq2name
  order by rqcretime descending.
    f_rqident = tsp01-rqident.
    exit.
  endselect.
  if sy-subrc ne 0.
    clear f_rqident.
  endif.
endform." get_spool_number

Similar Messages

  • Hi my question abt 2 convert a list into pdf format

    hi
    experts
    i had problem to convert displayed list into pdf format showing an error cannot open the file file format not supported, but i am have downloaded the file in .pdf format
    please help me
    thank you all

    Hi,
    check out this program. this might help:
    report zabap_pdf.
    tables:
      tsp01.
    data:
      mstr_print_parms like pri_params,
      mc_valid(1)      type c,
      mi_bytecount     type i,
      mi_length        type i,
      mi_rqident       like tsp01-rqident.
    *-- INTERNAL TABLES
    data:
      mtab_pdf    like tline occurs 0 with header line,
      mc_filename like rlgrap-filename.
    *-- SELECTION SCREEN
    parameters:
      p_repid like sy-repid, " Report to execute
      p_linsz like sy-linsz default 132, " Line size
      p_paart like sy-paart default 'X_65_132'.  " Paper Format
    start-of-selection.
    concatenate 'c:\'
                p_repid
                '.pdf'
      into mc_filename.
    *-- Setup the Print Parmaters
      call function 'GET_PRINT_PARAMETERS'
       exporting
         authority= space
         copies   = '1'
         cover_page                   = space
         data_set = space
         department                   = space
         destination                  = space
         expiration                   = '1'
         immediately                  = space
         in_archive_parameters        = space
         in_parameters                = space
         layout   = space
         mode     = space
         new_list_id                  = 'X'
         no_dialog= 'X'
         user     = sy-uname
       importing
         out_parameters               = mstr_print_parms
         valid    = mc_valid
       exceptions
         archive_info_not_found       = 1
         invalid_print_params         = 2
         invalid_archive_params       = 3
         others   = 4.
    *-- Make sure that a printer destination has been set up
    *-- If this is not done the PDF function module ABENDS
      if mstr_print_parms-pdest = space.
        mstr_print_parms-pdest = 'LOCL'.
      endif.
    *-- Explicitly set line width, and output format so that
    *-- the PDF conversion comes out OK
      mstr_print_parms-linsz = p_linsz.
      mstr_print_parms-paart = p_paart.
      submit (p_repid) to sap-spool without spool dynpro
                       spool parameters mstr_print_parms
                       via selection-screen
                       and return.
    *-- Find out what the spool number is that was just created
      perform get_spool_number using sy-repid
                 sy-uname
        changing mi_rqident.
    *-- Convert Spool to PDF
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        exporting
          src_spoolid= mi_rqident
          no_dialog  = space
          dst_device = mstr_print_parms-pdest
        importing
          pdf_bytecount                  = mi_bytecount
        tables
          pdf        = mtab_pdf
        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.
    call function 'DOWNLOAD'
         exporting
              bin_filesize            = mi_bytecount
              filename                = mc_filename
              filetype                = 'BIN'
         importing
              act_filename            = mc_filename
         tables
              data_tab                = mtab_pdf.
          FORM get_spool_number *
          Get the most recent spool created by user/report              *
    -->  F_REPID               *
    -->  F_UNAME               *
    -->  F_RQIDENT             *
    form get_spool_number using f_repid
         f_uname
                    changing f_rqident.
      data:
        lc_rq2name like tsp01-rq2name.
      concatenate f_repid+0(8)
                  f_uname+0(3)
        into lc_rq2name separated by '_'.
      select * from tsp01 where  rq2name = lc_rq2name
      order by rqcretime descending.
        f_rqident = tsp01-rqident.
        exit.
      endselect.
      if sy-subrc ne 0.
        clear f_rqident.
      endif.
    endform." get_spool_number

  • Convert ABAP List to PDF

    Hi, 
    I need to convert an ABAP List that is in the spool to a PDF file, but I want to separate the SPOOL in several pages so that each page is a new PDF file. Is there any way I can do this?
    Thanks
    PS:
    I prove the function <b>CONVERT_ABAPSPOOLJOB_2_PDF</b>, but this function convert all ABAP list to a pdf file.

    Hi John,
    interesting question, I think yes, but I'm sorry I have no time to invistigate, but I think the way to do that is :
    - Find how sap is able to print only one page from a spool ?  (Trans SP01)
    - Use a function like CONVERT_OTF_2_PDF or SX_OBJECT_CONVERT___S_PRT.
    That could be
    [SPOOL x pages] -> [ 1 OTF by page] -> [1 PDF]
    Good luck and gives us feedback
    Fred

  • Problem converting Word Documents into pdf

    Hi Folks - and Happy New Year to You!
    I'm using version Adobe 7.0. 
    I written an e-book and can't get the darn thing to convert into a pdf file. Sometimes it works -- sometimes it doesn't. 
    I suspect the problem is with my many embedded graphics. I have created Microsoft Powerpoint slides, and have cut and pasted them into my ebook as objects inserted between the paragraphs of text. 
    When converting from the "Convert to Adobe PDF" button in my Word Toolbar, it gets all the way through and finally has an error at the end saying: "an error occured while creating a temporary file; Word was unable to write some of the embedded objects due to insufficient memory or disk space" 
    I have Adobe set with a password to protect copying, and the Word file size is around 1Mb. 
    My computer is only a year old, and I have 23 Gb of free space. 
    I'm using Windows Professional XP and Word 2002 
    Please reply asap or email me on [email address deleted by host] 
    You Have My Best Regards 
    Dave

    Hi,
    I have tried to get this right for a few days now Finally found some info at
    http://kb.adobe.com/selfservice/viewContent.do?externalId=330729
    See point 2 below.
    Creating PDF files by using PDFMaker
    You can convert Word files from within either Word or Acrobat. Because both applications use PDFMaker, you can achieve the same results in either application.
    To create a PDF file from within Word:
    1. Exit from all applications except Word to minimize processing time. To further minimize processing time, complete the following:
    -- If the document contains several fonts, either reduce the number of fonts or replace TrueType fonts with Type 1 fonts.
    -- If the document contains large or complex tables, reduce the number of columns and rows.
    2. If the document contains hyperlinks, make sure that the page margins are .8 inch or larger.
    3. To add features such as font embedding and compression to your PDF file, choose Adobe PDF > Change Conversion Settings. (To create customized job options settings with these features, edit the conversion settings. For more information, see "Editing the PDFMaker Conversion Settings" in the Acrobat Help.)
    Isn't it totally obvious to anyone that the margins have to be at least 0.8 inches for hyperlinks to work.....
    I made a new page format slightly larger and increased the margins. After making the PDF file i trimmed it in Adobe. Worked like a dream...
    Roger
    Roger

  • Problem converting word doc into pdf

    I've just installed adobe acrobat 6.0 onto my laptop
    . Whenever I try to create a pdf file from a word doc it says there is a problem and will have to run in repair mode/ It then goes through the 'retrieving required info' instructs to restart the computer. Once Ihave done that though and retry, it does exactly the same thing.

    There is an easy and effective way to convert word to PDF through Microsoft word 2007. You can download Microsoft Save As PDF add-in from Microsoft.com.
    Also a newly release one Office 2007 Service Pack 2 (SP2) has built-in the add-in.
    1. Start Microsoft Word 2007
    2. Open a .DOC document and edit
    3. Select from main menu “Office button”->”Save As”
    4. Select “adobe PDF”.
    More you can refer this column of PDF Converter, which includes some tutorials about converting PDF to other files.
    Glad that you got it working.

  • Convert abap list to DOC

    how do i convert abap list to DOC .
    Rendi

    hi,
    this program to convert abap list to PDF file.
    *& Report  ZWARUN_TEST4
    REPORT  ZWARUN_TEST4.
    tables:mara,bseg.
    data:begin of itab occurs 2,
         matnr like mara-matnr,
         ernam like mara-ernam,
        end of itab.
    data:begin of it_bseg occurs 2,
         bukrs like bseg-bukrs,
         belnr like bseg-belnr,
         gjahr like bseg-gjahr,
         shkzg like bseg-shkzg,
         dmbtr like bseg-dmbtr,
        blart like bkpf-blart,
         end of it_bseg.
    data: lv_numbytes type i,
          lv_spoolno type tsp01-rqident,
          c_layout like pri_params-paart value 'X_65_132',
          C_X type c value 'X',
          numbers type i,
          cancel.
    data:it_pdf like tline occurs 10 with header line.
    data:p_down like rlgrap-filename.
    *at selection-screen.
    selection-screen:begin of  block blk with frame.
    select-options:s_matnr for mara-matnr,
                   s_bukrs for bseg-bukrs.
    parameter: download as checkbox default 'X',
               p_file like rlgrap-filename default 'c:\warun.pdf'.
              p_down LIKE RLGRAP-FILENAME DEFAULT 'c:\warun2.txt'.
    selection-screen:end of block blk .
    selection-screen pushbutton 12(20) push user-command cl1.
    at selection-screen.
      perform validate.
    top-of-page.
      write:/10 sy-repid inverse color 3.
      write:/2 'Date:' , sy-datum,
             40 'Time:' , sy-uzeit.
      write:/2 sy-uline.
    end-of-page.
      write:/50 'Intelligroup Asia Pvt'.
      write:/20 sy-pagno.
    start-of-selection.
      select matnr
             ernam
             into table itab
             from mara
             where matnr in s_matnr.
      if sy-subrc = 0.
        sort itab by matnr.
      endif.
      perform besg_data.
    set pf-status 'PUSH'.
    at user-command.
    if sy-ucomm = 'DOWNLOAD'.
      if download = space.
        perform get_file.
      endif.
    end-of-selection.
      if download = 'X'.
        perform PDFfile.
      ENDIF.
    *&      Form  validate
    FORM validate .
      data: v_temp(40).
      select single
             matnr
             into v_temp
             from mara
             where matnr in s_matnr.
      if sy-subrc <> 0.
        message e000(zz) with 'no data found'.
      endif.
    ENDFORM.                    " validate
    at line-selection.
      set parameter ID 'MAT' FIELD ITAB-MATNR.
      CALL TRANSACTION 'MM03' .
      WRITE:/ 'Material data displayed' .
      write:/2 itab-matnr.
    *&      Form  PDFfile
    FORM PDFfile .
      data:lk_params type pri_params,
            lv_valid.
    All the parameters passed are constants, so exceptions
    doesn't get raised
      call function 'GET_PRINT_PARAMETERS'
        EXPORTING
          immediately    = ' '
          layout         = c_layout                             "'X_65_132'
          no_dialog      = c_x
        IMPORTING
          out_parameters = lk_params
          valid          = lv_valid.
      if lv_valid <> space .
        new-page print on parameters lk_params no dialog.
    *--To display the final report
        perform print_report.
        new-page print off.
    *---To convert the download to PDF
        perform conv_to_pdf_download.
        perform download.
      endif.
    endif.
    *--To display the final report
      perform print_report.
    ENDFORM.                    " PDFfile
    *&      Form  print_report
    FORM print_report .
      loop at itab.
        write:/2 sy-vline,
               4 itab-matnr  color 4 HOTSPOT,
               40 sy-vline ,
               41 itab-ernam color 5,
               55 sy-vline.
        HIDE: ITAB-MATNR.
      endloop.
    ENDFORM.                    " print_report
    *&      Form  conv_to_pdf_download
    FORM conv_to_pdf_download .
      wait up to 2 seconds.
      lv_spoolno = sy-spono.
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        exporting
          src_spoolid                    =  lv_spoolno
         no_dialog                      = ''
       DST_DEVICE                     =
       PDF_DESTINATION                =
       importing
         pdf_bytecount                  = lv_numbytes
       PDF_SPOOLID                    = pdfspoolid
       LIST_PAGECOUNT                 =
       BTC_JOBNAME                    = jobname
       BTC_JOBCOUNT                   = jobcount
       tables
         pdf                            = it_pdf.
    ENDFORM.                    " conv_to_pdf_download
    *&      Form  download
    FORM download .
      check download = 'X'.
      call function 'DOWNLOAD'
        EXPORTING
          bin_filesize = lv_numbytes
          filename     = p_file
          filetype     = 'BIN'
        IMPORTING
          act_filename = p_file
          filesize     = lv_numbytes
          cancel       = cancel
        TABLES
          data_tab     = it_pdf.
      if cancel = space.
        write: / lv_numbytes, p_file.
      endif.
    ENDFORM.                    " download
    *&      Form  get_file
    FORM get_file .
      Data: s_filename like rlgrap-filename,
            s_filepath like rlgrap-filename,
            tm_filepath like rlgrap-filename.
      CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
         DEF_FILENAME           = s_filename
         DEF_PATH               = s_filepath
            MASK                   = ' '
            MODE                   = ' '
            TITLE                  = ' '
       IMPORTING
         FILENAME               =  tm_filepath
      IF SY-SUBRC = 0.
        p_down = tm_filepath.
        perform download2.
      endif.
    ENDFORM.                    " get_file
    *&      Form  download2
    FORM download2 .
      DATA: LV_STRING TYPE STRING.
      LV_STRING = P_DOWN.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                        = LV_STRING
         FILETYPE                        = 'ASC'
      APPEND                          = ' '
         WRITE_FIELD_SEPARATOR           = 'X'
        TABLES
          DATA_TAB                        = itab
       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 <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                                                    " download2
    *&      Form  besg_data
    FORM besg_data .
    if itab is initial.
    select bukrs
           belnr
           gjahr
           shkzg
           dmbtr
          into corresponding fields of table it_bseg
           from bseg
          where bukrs in s_bukrs.
    endif.
    ENDFORM.                    " besg_data
    regards
    warun

  • Problem in converting smart form into PDF

    HI Experts,
                      I am using a Function Module CONVERT_OTF for converting smart form into pdf file for send it to with attachment.
    But i got a error when i am using that FM.
    Runtime Errors         CONVT_NO_NUMBER
    unable to interpret *292 as a no.
    Is that because my file size too large about 13 pages of PDF?
    and when i run it for other smart forms which have 2 or 3 pages of PDF, its working perfectly.
    can anyone tell what is problem with that FM?
    Thanks
    Shakun

    Hi,
    I had the similar issue and after analysis I have that this is the issue by not passing the IMPORTING parameter of the Function Module "BIN_FILESIZE". Please try to pass some variable to this paramter and then this will be completely rectified.
    DATA ; v_filesize     TYPE i.
    *--Convert OTF data to PDF data
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
        IMPORTING
          bin_filesize          = v_filesize
        TABLES
          otf                   = it_otfdata
          lines                 = it_pdfdata
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          err_bad_otf           = 4
          OTHERS                = 5.
    Please verify whether this reolves the problem for you.
    Regards,
    SRinivas

  • Alignment problem in converting smartform printpreview into PDF

    Hi all,
    I am getting some alignment problem in converting smartform printpreview into PDF format, i.e the format of PDF is different from printpreviw of smartform.
    kindly suggest something so that alignment is not changed while converting to PDF.
    Regards,
    Sumalatha

    use below f.m to convert it into 255 characters....
         CALL FUNCTION 'QCE1_CONVERT'
            TABLES
              t_source_tab         = i_tline
              t_target_tab         = so_ali[]
            EXCEPTIONS
              convert_not_possible = 1
              OTHERS               = 2.

  • Converting the Transaction  into PDF

    Hi All,
    How to convert the standard transaction PZ11 into PDF.
    Presently this PZ11 giving the output in script format.
    i need to convert it into PDF.
    it is very urgent...
    Pls do the needful..
    Regards

    hi
    good
    *& Report  ZRICHA_OTF_PDF
    report  zricha_otf_pdf
        message-id zz.
    CONSTANTS                                                           *
    constants : c_x(1)      type c value 'X',      " For constant value
                c_otf(3)    type c value 'OTF',    " For format
                c_u(1)      type c value 'U'.      " Mail Option
    VARIABLES                                                           *
    data : v_rqident  type tsp01-rqident,  " For Spool Number
           v_rqclient type tsp01-rqclient, " For Client
           v_rqo1name type tsp01-rqo1name, " For Object name
           v_spool    type tsp01-rqident,  " For Spool Number
           v_spool1   type tsp01-rqident.  " For Spool Number
    FLAGS                                                               *
    data : f_spool type c.
      INTERNAL TABLES                                                    *
    Internal table for sending mails
    data: it_pdf          like tline      occurs 10 with header line,
          it_xi_pdf       like tline      occurs 0  with header line,
          it_html         like solisti1   occurs 0  with header line,
          it_xi_temp      like bapiqcmime occurs 0  with header line,
          it_xi_mime(255) type c          occurs 0  with header line.
    For sending mail
    data: it_objpack like sopcklsti1 occurs 2 with header line.
    Internal table for Single List with Column Length 255
    data : it_objbin like solisti1 occurs 10 with header line.
    Internal table for Single List with Column Length 255
    data : it_objtxt like solisti1 occurs 10 with header line.
    Internal table for Structure of the API Recipient List
    data : it_reclist like somlreci1 occurs 5 with header line.
    Structure of the API Recipient List
    data: x_doc_chng like sodocchgi1.
    Internal table for storing the variants
    data : begin of it_variant1 occurs 0,
            variant like varid-variant,
           end   of it_variant1.
    Internal table to store variants for the programs
    data: it_variant2 like it_variant1 occurs 0 with header line.
    Internal table for storing the selected values
    data it_return type ddshretval occurs 0 with header line.
    Internal table for storing the mail-ids
    data : begin of it_mailid occurs 0,
            kokrs like csks-kokrs,
            kostl like csks-kostl,
            datbi like csks-datbi,
            telx1 like csks-telx1,
           end   of it_mailid.
    Internal table for storing the mail-ids
    data : it_mailid1 like it_mailid occurs 0 with header line.
      SELECTION SCREEN                                                   *
    data : v_char type char50.
    selection-screen begin of block b1 with frame title text-001.
    select-options: s_email for v_char  no intervals
                    lower case
                    no-display.
    select-options: s_email1 for v_char  no intervals
                    lower case
                    no-display.
    selection-screen end of block b1.
    selection-screen begin of block a1 with frame title text-028.
    selection-screen begin of line.
    parameters : p_c1 as checkbox.
    selection-screen comment 3(66) text-026 for field p_c1.
    selection-screen end of line.
    parameters : p_set like tsp1d-papart matchcode object zh_tsp1d.
    selection-screen skip 1.
    parameters : p_vara1 type rs38m-selset.
    selection-screen end of block a1.
    selection-screen begin of block a2 with frame title text-029.
    selection-screen begin of line.
    parameters : p_c2 as checkbox.
    selection-screen comment 3(56) text-027 for field p_c1.
    selection-screen end of line.
    parameters : p_set1 like tsp1d-papart matchcode object zh_tsp1d.
    selection-screen skip 1.
    parameters : p_vara2 type rs38m-selset.
    selection-screen end of block a2.
    AT SELECTION SCREEN ON VALUE REQUEST
    at selection-screen on value-request for p_vara1.
    For fetching the variants available for the program
      perform fetch_variants.
    at selection-screen on value-request for p_vara2.
    For fetching the variants available for the program
      perform fetch_variants1.
    AT SELECTION SCREEN
    at selection-screen.
    For Validation
      perform validation.
    START OF SELECTION                                                  *
    start-of-selection.
    To get the output data and mail
      perform fetch_data.
    END OF SELECTION                                                    *
    end-of-selection.
      if f_spool = c_x.
        message e000 with 'Spool Not Generated'(060).
      endif.
    *&      Form  fetch_data
          To get the output data and mail
    form fetch_data .
    To send the output to spool
      perform generate_spool.
    endform.                    " fetch_data
    *&      Form  generate_spool
          To send the output to spool
    form generate_spool .
      data: l_params like pri_params,
            l_days(1)  type n value 2,
            l_count(3) type n value 1,
            l_valid    type c,
            l_valid1   type c,
            l_params1  like pri_params.
      data: l_device type usr01-spld.
    *Get the printer name for the user
      select single spld into l_device from usr01 where bname = sy-uname.
      if l_device is initial.
        l_device = 'LOCL'.
      endif.
    For report-1
      if p_c1 = 'X'.
    Setting the print parameters
        call function 'GET_PRINT_PARAMETERS'
          exporting
            destination    = l_device
            copies         = l_count
            list_name      = sy-uname
            list_text      = 'SUBMIT ... TO SAP-SPOOL'(008)
            release        = c_x
            new_list_id    = c_x
            expiration     = l_days
           LINE_SIZE      = 255
           LINE_COUNT     = 65
            layout         = p_set
            sap_cover_page = space
            cover_page     = space
            receiver       = 'SAP*'(010)
            department     = 'System'(011)
            no_dialog      = c_x
          importing
            out_parameters = l_params
            valid          = l_valid.
        if l_valid <> space.
          clear v_spool.
    Fetch the spool number b4 submit
          perform fetch_recent_spool using v_spool.
    Submitting the program to spool
          submit rkaep000 to sap-spool
            using selection-set p_vara1
            spool parameters l_params
            without spool dynpro
            and return.
          clear v_spool1.
    Fetch the spool number after submit
          perform fetch_recent_spool using v_spool1.
          if v_spool = v_spool1.
            f_spool = c_x.
            if p_c2 is initial.
              stop.
            endif.
          else.
    Checking the format ( ABAP/OTF)
            perform format_check tables s_email.
          endif.
        else.
          message e000 with 'Problem in print settings'(003).
          stop.
        endif.
      endif.
    For Report-2
      if p_c2 = 'X'.
    Setting the print parameters
        call function 'GET_PRINT_PARAMETERS'
          exporting
            destination    = l_device
            copies         = l_count
            list_name      = sy-uname
            list_text      = 'SUBMIT ... TO SAP-SPOOL'(008)
            release        = c_x
            new_list_id    = c_x
            expiration     = l_days
           LINE_SIZE      = 200
           LINE_COUNT     = 65
            layout         = p_set1
            sap_cover_page = space
            cover_page     = space
            receiver       = 'SAP*'(010)
            department     = 'System'(011)
            no_dialog      = c_x
          importing
            out_parameters = l_params1
            valid          = l_valid1.
        if l_valid1 <> space.
          clear v_spool.
    Fetch the spool number b4 submit
          perform fetch_recent_spool using v_spool.
    Submitting the program to spool
          submit gp3diehxy88snfj0391v7kf9ek7050 to sap-spool
            using selection-set p_vara2
            spool parameters l_params1
            without spool dynpro
            and return.
          clear v_spool1.
    Fetch the spool number after submit
          perform fetch_recent_spool using v_spool1.
          if v_spool = v_spool1.
            message e000 with 'Spool Not Generated'(060).
            stop.
          endif.
    Checking the format ( ABAP/OTF)
          perform format_check tables s_email1.
        else.
          message e000 with 'Problem in print settings'(003).
          stop.
        endif.
      endif.
    endform.                    " generate_spool
    *&      Form  fetch_recent_spool
          Fetch the recent spool number generated
    form fetch_recent_spool using p_v_spool type tsp01-rqident .
      data:  l_user like tsp01-rq2name.
      clear : v_rqident,
              v_rqclient,
              v_rqo1name.
      l_user = sy-uname.
    Get latest Spool No
      select single rqident
                    rqclient
                    rqo1name
             into (v_rqident , v_rqclient , v_rqo1name)
        from tsp01
       where rqcretime =   ( select max( rqcretime )
                                    from tsp01
                                   where rq2name eq l_user
                                     and rqfinal eq '.' ).
      if sy-subrc = 0 .
        p_v_spool = v_rqident.
      endif.
    endform.                    " fetch_recent_spool
    *&      Form  format_check
          Checking the format ( ABAP/OTF)
    form format_check tables p_s_email structure s_email.
      data : l_objtype    like rststype-type.
      call function 'RSTS_GET_ATTRIBUTES'
        exporting
          authority     = 'SP01'(019)
          client        = v_rqclient
          name          = v_rqo1name
          part          = 1
        importing
          objtype       = l_objtype
        exceptions
          fb_error      = 1
          fb_rsts_other = 2
          no_object     = 3
          no_permission = 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.
      if l_objtype(3) = c_otf.
    Convert OTF Spool to PDF
        perform convert_otf2pdf tables p_s_email.
      else.
    Convert ABAP Spool to PDF
        perform convert_abap2pdf tables p_s_email.
      endif.
    endform.                    " format_check
    *&      Form  convert_otf2pdf
          Convert OTF Spool to PDF
    form convert_otf2pdf tables p_p_s_email structure s_email .
      clear   it_pdf.
      refresh it_pdf.
      data : l_bytecount  type i.
    Fn. to get the PDF format
      call function 'CONVERT_OTFSPOOLJOB_2_PDF'
        exporting
          src_spoolid              = v_rqident
          no_dialog                = 'X'
        importing
          pdf_bytecount            = l_bytecount
        tables
          pdf                      = it_pdf
        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.
      if sy-subrc = 0.
    For page format
        perform page_format tables p_p_s_email.
      else.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " convert_otf2pdf
    *&      Form  convert_abap2pdf
           Convert ABAP Spool to PDF
    form convert_abap2pdf tables p_p_s_email structure s_email.
      clear   it_pdf.
      refresh it_pdf.
      data : l_bytecount  type i.
    Fn. to convert to PDF format
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        exporting
          src_spoolid              = v_rqident
          no_dialog                = 'X'
        importing
          pdf_bytecount            = l_bytecount
        tables
          pdf                      = it_pdf
        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.
      if sy-subrc = 0.
    For page formatting
        perform page_format tables p_p_s_email.
      else.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " convert_abap2pdf
    *&      Form  send_mail
          For sending mail
    form send_mail tables mail structure s_email .
    Structures and internal tables for the send data
      data: objpack like sopcklsti1 occurs 2  with header line,
            objhead like solisti1   occurs 1  with header line,
            objbin  like solisti1   occurs 0  with header line,
            objtxt  like solisti1   occurs 10 with header line,
            reclist like somlreci1  occurs 5  with header line.
      data: doc_chng like sodocchgi1,
            tab_lines like sy-tabix.
    Data for the status output after sending
      data: sent_to_all like sonv-flag.
      clear: it_reclist, it_reclist[],
             it_objtxt , it_objtxt[],
             it_objpack, it_objpack[],
             it_objbin , it_objbin[],x_doc_chng.
      loop at it_html.
        objbin-line = it_html-line.
        append objbin.
        clear objbin.
      endloop.
    Create the document which is to be sent
      doc_chng-obj_name  = 'List'(012).
      doc_chng-obj_descr = 'Mail'(013).
    Heading
      objtxt-line = 'Mail with pdf attachment'(014).
      append objtxt.
      clear objtxt.
    Size
      describe table objtxt lines tab_lines.
      read table objtxt index tab_lines.
      doc_chng-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).
    Fill the fields of the packing_list for the main document:
      clear objpack-transf_bin.
    The document needs no header (head_num = 0)
      objpack-head_start = 1.
      objpack-head_num = 0.
    Body
      objpack-body_start = 1.
      objpack-body_num = tab_lines.
      objpack-doc_type = 'RAW'(015).
      append objpack.
    Create the attachment (the list itself)
      describe table objbin lines tab_lines.
    Fill the fields of the packing_list for the attachment:
      objpack-transf_bin = 'X'.
    Header
      objpack-head_start = 1.
      objpack-head_num = 0.
    Body
      objpack-body_start = 1.
      objpack-body_num = tab_lines.
      objpack-doc_type = 'PDF'(016).
      objpack-obj_name = 'Attachment'(017).
      objpack-obj_descr = 'Mail with pdf Attachment'(018).
      objpack-doc_size = tab_lines * 255.
      append objpack.
    *-Fill the mail recipient list
      loop at mail.
        reclist-receiver = mail-low.
        reclist-rec_type = c_u.
        append reclist.
        clear: reclist,
               mail.
      endloop.
    *-Send the document by calling the SAPoffice API1 module for sending
    *-documents with attachments
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        exporting
          document_data              = doc_chng
          put_in_outbox              = c_x
          commit_work                = c_x
        importing
          sent_to_all                = sent_to_all
        tables
          packing_list               = objpack
          object_header              = objhead
          contents_bin               = objbin
          contents_txt               = objtxt
          receivers                  = reclist
        exceptions
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          others                     = 99.
      case sy-subrc .
        when 0.
          message i000 with 'Mail has been sent successfully'(006).
        when others.
          message e000 with 'Problem in sending the mail'(023).
      endcase.
    endform.                    " send_mail
    *&      Form  page_format
           For page foramtting
    form page_format tables email structure s_email .
      data : l_lines       type i,
             l_temp(500)   type c,
             l_offset      type p,
             l_lineslen(2) type p,
             l_mimelen(2)  type p,
             l_tabix       like sy-tabix.
      clear : it_xi_pdf,
              it_xi_temp.
      refresh : it_xi_pdf,
                it_xi_temp.
      it_xi_pdf[] = it_pdf[].
    Reformat the line to 255 characters wide (code from SAP)
      clear: l_temp, l_offset, it_xi_temp.
      describe table it_xi_pdf   lines  l_lines.
      describe field it_xi_pdf   length l_lineslen in character mode.
      describe field it_xi_temp  length l_mimelen in character mode.
      loop at it_xi_pdf.
        l_tabix = sy-tabix.
        move it_xi_pdf to l_temp+l_offset.
        if l_tabix = l_lines.
          l_lineslen = strlen( it_xi_pdf ).
        endif.
        l_offset = l_offset + l_lineslen.
        if l_offset ge l_mimelen.
          clear it_xi_temp.
          it_xi_temp = l_temp(l_mimelen).
          append it_xi_temp.
          shift l_temp by l_mimelen places.
          l_offset = l_offset - l_mimelen.
        endif.
        if l_tabix = l_lines.
          if l_offset gt 0.
            clear it_xi_temp.
            it_xi_temp = l_temp(l_offset).
            append it_xi_temp.
          endif.
        endif.
      endloop.
      clear : it_xi_mime,
              it_xi_mime[].
      loop at it_xi_temp.
        it_xi_mime(255) = it_xi_temp-line.
        append it_xi_mime.
        clear  it_xi_mime.
      endloop.
    Final Data
      clear : it_html,
              it_html[].
      it_html[] = it_xi_mime[].
    For sending mail
      perform send_mail tables email.
    endform.                    " page_format
    *&      Form  fetch_variants
          For fetching the variants available for the program
    form fetch_variants .
      data : l_program like rs38m-programm value 'RKAEP000',
             l_vara1 type dfies-fieldname value 'P_VARA1'.
      clear : it_variant1,
              it_variant1[].
    Get variants
      perform get_variants tables it_variant1
                           using l_program.
    F4 Help
      if not it_variant1[] is initial.
        perform get_f4_help tables it_variant1
                             using l_vara1
                            changing p_vara1.
      else.
        message e000 with 'No variants available for report1'(054).
      endif.
    endform.                    " fetch_variants
    *&      Form  validation
          For Validation
    form validation .
      data : l_pro1 like rs38m-programm value 'RKAEP000',
             l_pro2 like rs38m-programm value 'GP3DIEHXY88SNFJ0391V7KF9EK7050',
             l_c1,
             l_c2.
    If both check-box are unchecked
      if p_c1 is initial
    and p_c2 is initial.
        message e000 with 'Check any one check-box'(049).
      endif.
    If checked without varaint
      if not p_c1 is initial and p_vara1 is initial.
        message e000 with 'Please give any one of the variant for report1'(055).
      endif.
    If checked without varaint
      if not p_c2 is initial and p_vara2 is initial.
        message e000 with 'Please give any one of the variant for report2'(061).
      endif.
    Reading the variant and fetching the mail-ids
      if p_c1 = c_x.
        l_c1 = '1'.
        clear : s_email,
                s_email[].
        perform read_variants tables it_mailid
                                     s_email
                               using p_vara1
                                     l_pro1
                                     l_c1.
        if s_email[] is initial.
          message e000 with 'No Id available for given Cost report1'(066).
        else.
          sort s_email by low.
          delete adjacent duplicates from s_email comparing low.
        endif.
      endif.
    Reading the variant and fetching the mail-ids
      if p_c2 = c_x.
        clear : s_email1,
                s_email1[].
        l_c2 = '2'.
        perform read_variants tables it_mailid1
                                     s_email1
                               using p_vara2
                                     l_pro2
                                     l_c2.
        if s_email1[] is initial.
          message e000 with 'No Id available for given Cost report2'(067).
        else.
          sort s_email1 by low.
          delete adjacent duplicates from s_email1 comparing low.
        endif.
      endif.
    endform.                    " validation
    *&      Form  GET_VARIANTS
          Fetching Variants
    form get_variants  tables   p_it_variant structure it_variant1
                       using    p_v_program  type rs38m-programm.
      select variant
             from varid
             into table p_it_variant
             where report = p_v_program.
    endform.                    " GET_VARIANTS
    *&      Form  GET_F4_HELP
          text
    form get_f4_help  tables   p_it_variant1 structure it_variant1
                       using   p_l_vara1 like dfies-fieldname
                      changing p_p_vara like p_vara1.
    Fn. for Pop-Up
      call function 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
          retfield        = p_l_vara1
          value_org       = 'S'
          display         = ' '
        tables
          value_tab       = p_it_variant1
          return_tab      = it_return
        exceptions
          parameter_error = 1
          no_values_found = 2
          others          = 3.
      if sy-subrc = 0.
        p_p_vara = it_return-fieldval.
      else.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " GET_F4_HELP
    *&      Form  FETCH_VARIANTS1
          text
    form fetch_variants1 .
      data : v_program1 like rs38m-programm value 'GP3DIEHXY88SNFJ0391V7KF9EK7050',
             l_vara2  type dfies-fieldname value 'P_VARA2'.
      clear : it_variant2,
              it_variant2[].
    Get Variants
      perform get_variants tables it_variant2
                           using v_program1.
    F4 Help
      if not it_variant2[] is initial.
        perform get_f4_help tables it_variant2
                            using  l_vara2
                          changing p_vara2.
      else.
        message e000 with 'No variants available for report2'(050).
      endif.
    endform.                    " FETCH_VARIANTS1
    *&      Form  read_variants
           Reading the variant and fetching the mail-ids
    form read_variants tables p_it_mailid structure it_mailid
                              p_s_email   structure s_email
                       using  p_p_vara1   like p_vara1
                              p_l_pro1    like rs38m-programm
                              p_l_c1      type c.
      data : l_temp(44),
             it_valutab like rsparams occurs 0 with header line.
      ranges : r_cocen for csks-kostl.
    Function Module to get the variant contents
      call function 'RS_VARIANT_CONTENTS'
        exporting
          report               = p_l_pro1
          variant              = p_p_vara1
        tables
          valutab              = it_valutab
        exceptions
          variant_non_existent = 1
          variant_obsolete     = 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.
      clear : r_cocen,
              r_cocen[].
      loop at it_valutab where selname = 'KOSTL'
                            or selname = '_C-CCTR'.
    Getting the range of cost centers
        if it_valutab-option = 'BT'.
          r_cocen-low    = it_valutab-low.
    For Conversion Routine
          perform conversion using r_cocen-low.
          r_cocen-high   = it_valutab-high.
    For Conversion Routine
          perform conversion using r_cocen-high.
          r_cocen-option = 'BT'.
          r_cocen-sign   = 'I'.
          append r_cocen.
          clear  r_cocen.
        endif.
    Getting the single cost centers
        if it_valutab-option = 'EQ'.
          r_cocen-low    = it_valutab-low.
    For Conversion Routine
          perform conversion using r_cocen-low.
          r_cocen-option = 'EQ'.
          r_cocen-sign   = 'I'.
          append r_cocen.
          clear  r_cocen.
        endif.
      endloop.
    If no cost centers
      if not r_cocen[] is initial.
        select kokrs
               kostl
               datbi
               telx1
          from csks
               into table p_it_mailid
         where kostl in r_cocen.
        if p_it_mailid[] is initial.
          if p_l_c1 = '1'.
            message e000 with 'No IDs available for report1'(059).
          elseif p_l_c1 = '2'.
            message e000 with 'No IDs available for report2'(062).
          endif.
        endif.
    Deleting the blank entries
        delete p_it_mailid where telx1 = space.
        clear l_temp.
        read table p_it_mailid index 1.
        l_temp = p_it_mailid-telx1.
        data : l_check.
        loop at p_it_mailid where telx1 <> l_temp.
          l_check = c_x.
        endloop.
    For checking the unique ids
        if l_check = c_x.
          if p_l_c1 = '1'.
            message e000 with 'No unique mail-ids for  report1'(058).
          elseif p_l_c1 = '2'.
            message e000 with 'No unique mail-ids for  report2'(065).
          endif.
        endif.
    Populating the IDs for the cost centers
        loop at p_it_mailid.
          set locale language sy-langu.
          translate p_it_mailid-telx1 to lower case.
          set locale language space .
          concatenate p_it_mailid-telx1 '@allergan.com' into l_temp.
          p_s_email-low = l_temp.
          p_s_email-sign = 'I'.
          p_s_email-option = 'EQ'.
          append p_s_email.
          clear  p_s_email.
        endloop.
      else.
        if p_l_c1 = '1'.
          message e000 with 'No Cost Center Available for report1'(057).
        elseif p_l_c1 = '2'.
          message e000 with 'No Cost Center Available for report2'(063).
        endif.
      endif.
    endform.                    " read_variants
    *&      Form  CONVERSION
          For Conversion Routine
    form conversion  using    p_it_valutab_low type c.
      call function 'CONVERSION_EXIT_ALPHA_INPUT'
        exporting
          input  = p_it_valutab_low
        importing
          output = p_it_valutab_low.
    endform.                    " CONVERSION
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    thanks
    mrutyun^

  • Converting binary data into pdf and placing into application server

    Hi Friends,
    I am able to get PO details in binary format and then using GUI_DOWNLOAD  with file type with 'bin' and file name with 'sample.pdf' extension , got  PO in pdf  format.
    But i need to get with pdf extension in application server without using GUI_DOWNLOAD.
    Is there any functional modules for it?
    With Warm Regards,
    Madhu!!!

    Hi Madhu,
    Check this code.
    *& Report  ZSPOOLTOPDF                                                 *
    *& Converts spool request into PDF document and emails it to           *
    *& recipicant.                                                         *
    *& Execution                                                           *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on      *
    *& screen                                                              *
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Write statement to represent report output. Spool request is created
    if write statement is executed in background. This could also be an
    ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    Alternative way could be to submit another program and store spool
    id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
           to sap-spool
           spool parameters   %_print
           archive parameters %_print
           without spool dynpro
           and return.
    Get spool id from program called above
    IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
          FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
          FORM get_job_details                                          *
    FORM get_job_details.
    Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
          FORM convert_spool_to_pdf                                     *
    FORM convert_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.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
          FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    perform send_email using p_email2.
    ENDFORM.
          FORM send_email                                               *
    -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
          FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    Hope this resolves your query.
    <b>Reward all the helpful answers.</b>
    Regards

  • Acrobat XI Pro successfully installed, but it failed in converting word files into PDF, why?

    I just installed Adobe XI Pro through the download assistant, it looks the installation went well, but when I tried to convert word files into PDF (tried many times), it failed. Anyone has the same problems, any solutions?

    Please reply with more information - what your operating system is, do you have Office installed, and what exactly is happening. Is there an error message, does the application crash, and from where are you starting the conversion (using Word and PDFMaker, using Acrobat's Create button, or batch processing).

  • Converting PST files into PDF's & the recipient can't print

    I am having the following issue with Adobe: I am converting PST files into PDF's and the recipient can view the information, but they cannot print. Actually, some information such as whether there is an attachment is displayed in the printout, but none of the actual text appears. I do not see any security settings at this end that would be causing this, but I have been assured that there is nothing on the recipients either. The same thing was happening when I sent it to a colleague here in the office.

    I discovered the problem and solution. Often PST's contain damaged text. It is not easy to deal with the damaged text. It is more efficient to have the recipient print the file as an image.Select the print tab, go to advanced, select print as image. I got the information by looking through the more specific information on the Adobe site.

  • How to convert word doc into pdf - which product of adobe i need to use- what upgrades - am a newbie

    How to convert word doc into pdf - which product of adobe i need to use- what upgrades - am a newbie -  simple answers please - Thanks in advance.

    @Pipeline2007 - which version of Microsoft Office have you got? Older versions of Acrobat aren't compatible with the latest versions of Office, see this link for info:
    http://helpx.adobe.com/acrobat/kb/compatible-web-browsers-pdfmaker-applications.html

  • Adobe Product API for converting mulptiple formats into PDF and to Embed PDF into PDF ?

    Hi Team,
    Is there any adobe product that allow us to convert multiple formats into .pdf format and also allow us to attach (embed) other pdf files object into a pdf, is there any .net API for that, I want to do this through programming.
    Regards
    Amit

    We want to use this product for our application, for the purpose of converting different files formats into a PDF file and also for attaching files into a single PDF using a web application and windows service. I have to evaluate some features and point regarding this product which are as below:
    1. PDF form creation in future requirement.
    2. Maximum files size that i can convert into PDF.
    3. Memory management when converting N number of files.
    4. Compatibility with C#, .Net Framework 4.0, using MS Visual Studio 2010.
    5. Support of the product for future.
    6. Primary requirement to use PDFLiveCyle for above features.
    7. Basic guidelines before using PDFLiveCyle.
    8. Ease of coding using PDFLiveCyle.
    9. 32bit or 64bit support.
    10. Lisencing information
    Regards
    Amit Mishra

  • About converting a file into PDF

    why an error always occur when converting a file into pdf ?

    oceanblue1968 wrote:
    why an error always occur when converting a file into pdf ?
    Why is, when I just missed my train, the next train always late? (sigh)

Maybe you are looking for

  • Safari Pop up buttons / javascript

    I want to be able to select a specific item in a list of a pop up button in safari, i can do it by using a repeat statement and get value of button, with key codes simulating down arrow. This is tediously slow to the say the least. When i go view sou

  • After HTML and CSS, what to learn next..?

    My knowledge of css and html are ok and I understand that with time can only get better. I'd like to take the next step and start looking at another language. Which one..? Is it javascript or php..? Is one more beneficial that the other...? Any advic

  • I need to send encoded Blu Ray File to be Burned somewhere else?

    Usually I click burn Blu ray in Final Cut's share feature and I run it all the way through to create disc. Now I would like to send the encoded file to get burnt somewhere else. What would be the best recommended way to do this and keep the menu inta

  • How to configurate Weblogic using DNS round robin?

              Thanks to Cameron for your reply.           So if I cluster servers using DNS round robin,           how can I configurate?           Could you show me step by step please?           Because I've tried to config it so many times.           

  • MS mouse stopped working on Safari

    My MS mouse won't scroll anymore in Safari. Im using windows 7, I tried a second identical mouse and same problem, no more scroll function