Spool to PDF using RSTXPDFT4

Hello experts,
I am using <b>RSTXPDFT4</b> to convert SPOOL(<b>Script</b>)  to PDF. It works fine in foreground if the number of pages is < 100.
But, if the pages are > 100 then it asks for running in background. I have chosen to run in background. But It did not ask me to specify the file path for creating the pdf file!
I am wondering where the pdf file is stored in this case ?? !!!.   Anybody has encountered this before ????
It also noticed that it is creating one more spool number (<b>binary format</b>)  when u specify it run the program <b>RSTXPDFT4</b> in background.

Hello experts,
RSTXPDFT4 works fine for me if i want to convert spools to pdf files in foreground mode.
If i want to do this in background mode as a daily job i am not able to use RSTXPDFT4.
With report RSTXPDFT5  i am able to download in background as binary data but not as pdf.
So, i want to download spools to network shared folder in pdf formaat.
Thanks for suggestions & Regards
Janez

Similar Messages

  • Convert spool to pdf for Chinese characters

    Hi,
       I need to convert spool to pdf for chinese font.
       Spool is creating successfully, and contents are displaying properly. When try to convert the spool to pdf using 'RSTXPDFT4', the pdf is generated successfully, when trying open the pdf, contents are missing, its like empy white pdf page. This is happening for the Chinese font. The same script is working fine for the English font.
    Plz suggets
    Thanks
    Balaji

    Hi Balaji,
    I am having a similar issue with Simplified Chinese, Traditional Chinese, and Thai fonts when saving spools to PDF.  Have you found any more information on why the output shows up as a blank screen?
    We are printing Purchase Orders and the T&Cs are coming through fine because they are saved as picture files but the smartform does not display at all.
    Any information would be appreciated!
    Thanks,
    Josh

  • Error in Spool to PDF conversion using 'CONVERT_ABAPSPOOLJOB_2_PDF'.

    Hi
    I am sending classical report output from the Spool to PDF using 'CONVERT_ABAPSPOOLJOB_2_PDF'.
    This is done through a batch job.
    Step 1 is RVKRED01 report
    Step 2 is a program that picks up the spool number of step1 and converts the spool to PDF.
    Now in step 2 I am getting following error.
    TEMSE_READ_LISTLINE error, TemssPart 1
    What can be the reason?
    What can be the solution?

    HI,
    I checked your FM CONVERT_ABAPSPOOLJOB_2_PDF.
    in the include LSTXWFPL line 1006, the IF condition is failing (if eop = 'X'. "end of part, read next part? )
    so you are getting that message,
    you can check that failing job in the debugging mode why it was failing at that point.
    Note: for checking the background job you need to do below things.
            1) go to sm37, and select you job.
            2) and just type "JDBG" in the command line it goes to the debugging mode of your job.
    by this way you will find. how and why its that error.
    Alternative to your FM ( CONVERT_ABAPSPOOLJOB_2_PDF ) you can also use the
    FM FPCOMP_CREATE_PDF_FROM_SPOOL.

  • Send email with spool as PDF attachment using class CL_BCS

    Hi,
    I am converting a spool to PDF using the function module CONVERT_OTFSPOOLJOB_2_PDF. The spool contains graphic images etc just like a script output.
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
          EXPORTING
            src_spoolid                    = v_rqident
            no_dialog                      = 'X'
          IMPORTING
            pdf_bytecount                  = numbytes
            pdf_spoolid                    = pdfspoolid
          TABLES
            pdf                            = 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.
    After this I want to attach the pdf as an attachment to an email and send it. For this purpose I am using the code found in the example BCS_EXAMPLE_5.
    CALL METHOD document->add_attachment
            EXPORTING
              i_attachment_type    = 'PDF'
              i_attachment_subject = 'My attachment'
              i_att_content_hex    = binary_content.
    How do I convert the script text into binary content, could you please suggest some help.

    Old code, but I use:
      DATA: lt_pdf           TYPE soli_tab,
            lt_pdfbin        TYPE solix_tab.
    * Convert the lines
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        EXPORTING
          line_width_src              = 134
          line_width_dst              = 255
          transfer_bin                = 'X'
        TABLES
          content_in                  = i_pdf
          content_out                 = lt_pdf
        EXCEPTIONS
          err_line_width_src_too_long = 1
          err_line_width_dst_too_long = 2
          err_conv_failed             = 3
          OTHERS                      = 4.
      IF sy-subrc NE 0.
        RAISE convert_error.
      ENDIF.
      lt_pdfbin = lt_pdf.
    Also, keep in mid that that OTF convert function has a 99 page limit - if you can potentially reach that limit, you need to handle the background job process and retrieval of the RAW data from the spool.

  • Problem while converting Spool to PDF

    Hi,
    I am sending ALV report output to Spool then converting the Spool to PDF using  'CONVERT_ABAPSPOOLJOB_2_PDF'.
    I am able to send the mail but in the PDF, the first page contains data statistics(no. of records passed) but I want to supress it. I need to get my Actual output only.
    Please help me regarding this.
    Thanks,
    Swathi

    You need to set the print parameter of the ALV to avoid the statistics in the Spool.
    Like:
    data:   ls_prnt      type slis_print_alv.
    ls_prnt-NO_PRINT_LISTINFOS = 'X'.
      call function 'REUSE_ALV_GRID_DISPLAY'
          is_print                          = ls_prnt
    Regards,
    Naimesh Patel

  • Problem in converting spool to PDF file

    Hi guys,
    My spool contains Russian characters which are shown as one special char in pdf file. I guess the russian char. are not recognized by pdf.
    I convert the spool to pdf using following FM
      CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
             EXPORTING
                  src_spoolid   = wa_spool-spool
                  no_dialog     = ' '
             IMPORTING
                  pdf_bytecount = v_numbytes
                  pdf_spoolid   = v_pdfspoolid
                  btc_jobname   = v_jobname
                  btc_jobcount  = v_jobcount
             TABLES
                  pdf           = pdf.
    Then i download the file using FM:
    CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
                bin_filesize = v_numbytes
                filename     = v_return1
                filetype     = 'BIN'
           TABLES
                data_tab     = pdf
    Help me....
    Point will be rewarded on helpful answers.
    Regards,
    GURU

    HI
    use my code
    it will do the entire job
    *& Report  Z8VM_SPOOL2PDF                                              *
    report  z8vm_spool2pdf                          .
    **---- Author     :    vivekanand meghmala
    **---- Purpose    :    Create Single PDF file with outputs of
    **----                 Multiple Spools.
    **---- Create Date:    July 05th, 2006
    **---- Analyst    :    Vivek Maheshwari
    **---- Tables
    tables : tsp01.
    **---- Select Options for Multiple spools
    select-options :
      s_spool for tsp01-rqident obligatory.
    **---- Parameters for File Path.
    parameters :
    p_file type localfile default 'C:combined.pdf' obligatory.
    **---- Get the Spool Requests entered in Select-options for Spools.
    data : i_tsp01 like tsp01 occurs 0 with header line.
    **---- Work Areas and Variables
    data:  wa_eof type soli,            "----- End of File Work Area
           v_file type string,          "----- String
           v_size type i,               "----- Size
           v_lines type i.              "----- Lines in Internal Table
    **---- Internal Table for Spool Details and PDF and Document Details
    data : i_spool_table type table of soli,
           i_spool_total type table of soli  with header line,
           i_otf         type table of itcoo with header line,
           i_doc         like table of docs,
           i_pdf         like table of tline.
    **---- Move File name to Variable
    v_file = p_file.
    **---- Clear and Refresh Internal Tables before first use
    clear i_tsp01.            refresh i_tsp01.
    clear i_spool_table.      refresh i_spool_table.
    clear i_spool_total.      refresh i_spool_total.
    **---- Get Spool ID Details from TSP01
    select * from tsp01 into table i_tsp01 where rqident in s_spool.
    **---- Sort Table in Ascending order based on Spool Id
    sort i_tsp01 by rqident.
    **---- Get information about Multiple spools
    loop at i_tsp01.
    **---- Get Multiple Spool information
      call function 'RSPO_RETURN_SPOOLJOB'
        exporting
          rqident              = i_tsp01-rqident
        tables
          buffer               = i_spool_table
        exceptions
          no_such_job          = 1
          job_contains_no_data = 2
          selection_empty      = 3
          no_permission        = 4
          can_not_access       = 5
          read_error           = 6
          type_no_match        = 7
          others               = 8.
      if sy-subrc = 0.
      endif.
    **---- Get the Last line index (Number of Lines)
      describe table i_spool_table lines v_lines.
    **---- Clear Work Area for End of File (EOF) and read
    **---- End of File String into it and Delete it
      clear wa_eof.
      read table i_spool_table index v_lines into wa_eof.
      delete i_spool_table index v_lines.
    **---- Collect All individual Spool Details into one internal table.
      append lines of i_spool_table to i_spool_total.
      at last.
    **---- Append End of File information to Internal table
    **---- Containing information about all the invidual spools -
    **---- Thus forming one single spool
        append wa_eof to i_spool_total.
      endat.
    endloop.
    **---- Clear OTF tables before initial use
    clear i_otf. refresh i_otf.
    **---- Fill in the OTF internal table
    loop at i_spool_total.
      clear i_otf.
      i_otf = i_spool_total.
      append i_otf.
    endloop.
    **---- Convert the OTF information to PDF.
    call function 'CONVERT_OTF_2_PDF'
      exporting
        use_otf_mc_cmd         = 'X'
      importing
        bin_filesize           = v_size
      tables
        otf                    = i_otf
        doctab_archive         = i_doc
        lines                  = i_pdf
      exceptions
        err_conv_not_possible  = 1
        err_otf_mc_noendmarker = 2
        others                 = 3.
    if sy-subrc <> 0.
      message i002(sy) with 'Cannot convert to PDF, exiting....'.
      leave program.
    endif.
    **---- Download PDF file thus formed onto frontend
    call method cl_gui_frontend_services=>gui_download
      exporting
        filename                = v_file
        filetype                = 'BIN'
      changing
        data_tab                = i_pdf
      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
        not_supported_by_gui    = 22
        error_no_gui            = 23
        others                  = 24.
    if sy-subrc <> 0.
      message i002(sy) with 'Cannot download PDF, exiting....'.
      leave program.
    endif.

  • Spool to PDF file

    I have sevaral spools and I need to transform them to one PDF. is it possible to put all the spool and to create only one ''big spool'' and then transform it to pdf (or to have several pdf files and concatenate them to one pdf file).
    Benjamin

    Hi,
    You can convert the SPOOL to PDF using the beelow function module
    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.
    So,lets say you want 3 spools in a single PDF,
    DO 3 TIMES.
    Call the function module and create an internal table, in another internal table append the data. do like this in 3 times.
    ENDDO.
    After the END DO , you will get all the data in a Single PDF.
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    Regards
    Sudheer

  • What happens to attachment in a PO when it is converted to PDF using SPOOL.

    Hi Experts,
    While converting a PO to PDF using a spool number, it works fine but i have a question as If the PO has an attachment, does the spool take care of that also?
    If not how to download the attachment as well.
    Thanks & Regards,
    K

    Hi Shan,
    No in ME21N there is a tab called Attachment, by which we can attach a note or something(I am thou not sure why this is done), yes a script is generated into a PDF but this attachment which is part of PO does it get attached or we need to do somthing to attach it to PDF was my question?
    Cheers,
    K
    Edited by: Ken Thompson on Sep 29, 2008 5:58 AM

  • Convert Script to PDF using RVADOPFO, w/o using spool and send via email

    I want to convert output type script to pdf using the standard include RVADOPFO in the program. The output type is defined as medium '5' and comm starategy is also defined as INT(email) as want to send the output via email.
    Now the Include RVADOPFO contains ADDR_KEY-ADDRNUMBER & ADDR_KEY-PERSNUMBER. Where to maintain this info and how to pass in the include..below code is in the include..
    IF NOT NAST-TCODE IS INITIAL AND NAST-NACHA EQ '5'.
      ... use stratagy to get communication type
        CALL FUNCTION 'ADDR_GET_NEXT_COMM_TYPE'
             EXPORTING
                  STRATEGY           = NAST-TCODE
                ADDRESS_TYPE       =
                ADDRESS_NUMBER     = VBDKA-ADRNR
                PERSON_NUMBER      = VBDKA-ADRNP
                  ADDRESS_NUMBER     = ADDR_KEY-ADDRNUMBER
                  PERSON_NUMBER      = ADDR_KEY-PERSNUMBER
             IMPORTING
                  COMM_TYPE          = LVS_COMM_TYPE
                  COMM_VALUES        = LVS_COMM_VALUES
           TABLES
                STRATEGY_TABLE     =
             EXCEPTIONS
                  ADDRESS_NOT_EXIST  = 1
                  PERSON_NOT_EXIST   = 2
                  NO_COMM_TYPE_FOUND = 3
                  INTERNAL_ERROR     = 4
                  PARAMETER_ERROR    = 5
                  OTHERS             = 6.
    Please provide solution asap. Thanks in advance

    Hi,
    Check this links:
    Sending Mail from SAP
    https://wiki.sdn.sap.com/wiki/display/sandbox/SendMailwithPDFAttachment?showChildren=false#children
    Thanks.

  • Sapscript output(Spool) to PDF problem when viewed

    We have a number of documents which are output in Russian using the Cyrillic courier font within our Uincode SAP system. They look fine on the spool when viewed, print okay, and all look fine when converted to a PDF file (using RSTXPDFT4) and viewed via Adobe PDF viewer (vers 9.1.20), except one form, the invoice, which will not display properly in Adobe, showing square blocks with crosses through them when viewed. The strange thing is that when this same PDF is viewed via Sumatra (Open source PDF viewer) it looks perfect, but will not display via the Adobe PDF viewer, even though all the other delivery/dispatch docuemnts (all Sapscript) print and view fine via the Adobe PDF viewer.
    I guess I could suggest that we just use Sumatra from now on, but that is not really the answer when you have a multinational company which has Adobe already installed on all hardware as default.
    Has anyone come across this problem before. I was wondering if there could be anything in Sapscript that might have caused this as this is a copy of SAP standard Russian Invoice Sapscript (J_3RVINVOICE)?
    I'm going to check OSS to see if there's a fault with the PDF convertion program (RSTXPDFT4) but I would like to hear from anyone that may have encountered the same problem.
    Regards
    Gary

    Hi Gary
    How the issue is resolved, please let me know. Since i am also facing same issue.
    Thanks
    M G Shankar

  • Smart form: Spool to PDF Conversion more than 100 pages.

    Hi folks,
    I have an issue with Function Module (FM) CONVERT_ABAPSPOOLJOB_2_PDF when the report to be converted has more than 100 pages.....i have explained this scenario as below
    We have been using the FM CONVERT_ABAPSPOOLJOB_2_PDF to convert ABAP report to PDF file and then send this via mail using FM SO_DOCUMENT_SEND_API1.....
    PDF conversion using FM CONVERT_ABAPSPOOLJOB_2_PDF works well if the number of report pages is less than 100....i.e the table pdf of the FM will contain the output as expected.....
    If the report has more than 100 pages, the the FM CONVERT_ABAPSPOOLJOB_2_PDF will schedule the conversion job as a background job and returns with a SY-subrc eq 0 and the table parameter pdf will ne empty.
    Could you suggest me a woorkaround in this situtaion...i.e how do I then get the output of the background job
    And  any process to convert Spool to PDF if having more than 100 pages.
    Thanks in Advance............

    Pb,
    If the report has more than 100 pages, the the FM CONVERT_ABAPSPOOLJOB_2_PDF will schedule the conversion job as a background job and returns with a SY-subrc eq 0 and the table parameter pdf will ne empty
    i would suggest you to if pages are more than 100 than you need to send report output to sp01 with spool request number by using fm job_open..job_close..
    than from sp01 you can convert pdf by running RSTXPDFT4 in se38.
    hope this would solve your problem.
    Amit.

  • Problem in converting Spool to PDF file, having non-English characters

    Hi All,
            I have problem in converting Spool to PDF format.
    Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF  FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
    I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
    Regards,
    Navin.

    Hi All,
            I have problem in converting Spool to PDF format.
    Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF  FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
    I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
    Regards,
    Navin.

  • Convert Spool to PDF and mail for the jobs not run in background.

    Dear All,
    I need to convert the spool job into pdf and mail as attachment for job not run in background.
    I am printing the bills  using the program  SD70AV3A to print the bills in a batch using the SUBMIT.
    But i am not using the spool options since its going to into waiting state in spool...and i need to change the printer properties to G
    to get the printer to print the reports as these jobs run in backgroud....but this solution is not acceptable solution.
    SUBMIT SD70AV3A
             WITH RG_KSCHL-LOW = 'ZRR'
             WITH RG_NACHA-LOW = '1'
             WITH PM_VERMO = '2'
             WITH PM_NSORT = '1'
             WITH RG_VBELN IN range.
    *        TO SAP-SPOOL
    *        SPOOL PARAMETERS print_parameters
    *        WITHOUT SPOOL DYNPRO
    *        VIA JOB name NUMBER number
    *        AND RETURN.
    so how do i get the spool number from the above after the job is submitted....and then convert into pdf and mail
    please suggest some solution. I have searched on net but most the solutions are say to run the job as background job...
    i have also looked into the program RSTXPDFT4 but it asks for the spool id ....how can i get spool id for the job that has been completed.
    please suggest some solution.
    Thanks
    Bhargava.

    Hi,
    Spool to PDF : FM 'CONVERT_ABAPSOOLJOB_2_PDF'
    Table TSP01 to get spool number
    You ,may need to convert OTF to PDF: FM CONVERT_OTF
    and the to binary : FM 'SMCS_XSTRING_TO_BINARY'
    To send mail use class: cl_document _bcs.
    Regards,
    Maria João Rocha

  • How to convert spool to pdf & then sent mail ?

    For Billing document in SD module ,via VF02 we are creating spools.
    We are using RSTXPDFT4, to convert spool request to PDF.
    There are some 100 Invoices, & hence there are 100 spools.
    We have to give this spool no one by one in the above program to convert to PDF, which is taking time.
    Is there any way, where we can convert all the spools at one go & conver to PDF ?.Also, can this Billing document PDF, be directly sent to some recipients via e-mail from SAP ??
    for the above problem ..i got the below link
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8cd6adbb-0301-0010-39ba-938c601d5db9
    in the program,what to give in selection screen.
    which program is being called in submit.
    also when i run the report....no mail is fired.
    <removed_by_moderator>
    Edited by: Julius Bussche on Oct 31, 2008 12:43 PM

    try following code:
    PERFORM frm_pro_email.
    FORM frm_pro_email.
      PERFORM convert_spool_to_pdf.
      DESCRIBE TABLE gt_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email.
    ENDFORM.                    " process_email
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
          EXPORTING
            src_spoolid                    = gs_scriptresults-tdspoolid
            no_dialog                      = ' '
          DST_DEVICE                     =
          PDF_DESTINATION                =
          IMPORTING
            pdf_bytecount                  = numbytes
            pdf_spoolid                    = pdfspoolid
          OTF_PAGECOUNT                  =
            btc_jobname                    = jobname
            btc_jobcount                   = jobcount
          TABLES
            pdf                            = 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.
        RAISE conversion_to_pdf.
      ENDIF.
      CHECK sy-subrc = 0.
      CLEAR: gd_buffer, gt_mess_att.
      REFRESH: gt_mess_att[].
    Transfer the 132-long strings to 255-long strings
      LOOP AT pdf.
        TRANSLATE pdf USING ' ~'.
        CONCATENATE gd_buffer pdf INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        gt_mess_att = gd_buffer.
        APPEND gt_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.                    " conv
    FORM send_email .
      DATA: lv_sub(80).
      CLEAR gd_subject.
      REFRESH it_mess_bod.
    Default subject matter
      CONCATENATE 'IBM GLOBAL FINANCING ORDER CONFIRMATION'
                  vbdka-vbeln
                  INTO lv_sub SEPARATED BY space.
      gd_attachment_desc = lv_sub.
      DATA : p_sender LIKE somlreci1-receiver.
      p_sender = gs_user-email.
    If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
      it_mess_bod-line = c_head_text.
      APPEND it_mess_bod.
      it_mess_bod-line = c_email_text.
      APPEND it_mess_bod.
      it_mess_bod-line = c_email_text1.
      APPEND it_mess_bod.
      it_mess_bod-line = c_head_text.
      APPEND it_mess_bod.
      it_mess_bod-line = c_end_text.
      APPEND it_mess_bod.
      it_mess_bod-line = c_end_text.
      APPEND it_mess_bod.
      CLEAR it_mess_bod.
    Send file by email as .pdf speadsheet
      PERFORM send_file_as_email_attachment
                                   TABLES it_mess_bod
                                          gt_mess_att
                                   USING  lv_sub
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 CHANGING gd_error
                                          gd_reciever.
    ENDFORM.                    " send_email
    FORM send_file_as_email_attachment TABLES it_message
                                              it_attach
                                        USING 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_mtitle LIKE sodocchgi1-obj_descr,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription(50), "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_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
              t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
              w_cnt TYPE i,
              w_sent_all(1) TYPE c,                             "#EC NEEDED
              w_doc_data LIKE sodocchgi1.
      DATA : BEGIN OF gt_shptoemail OCCURS 0,
               lv_email LIKE somlreci1-receiver,
           END OF gt_shptoemail.
      CLEAR gt_shptoemail.
      REFRESH gt_shptoemail.
      TABLES: vbpa.
      SELECT SINGLE *  FROM vbak
             WHERE  vbeln = vbdka-vbeln.
      SELECT SINGLE * INTO vbpa FROM vbpa
             WHERE  vbeln = vbdka-vbeln
             AND    parvw = 'RE'.                        " Bill to party
      IF sy-subrc = 0.
        SELECT smtp_addr INTO  TABLE gt_shptoemail FROM adr6
               WHERE addrnumber = vbpa-adrnr.
      ELSE.
    Can not find the Bill to part
        MESSAGE e999(zm) WITH
               text-e01.
      ENDIF.
      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.
      IF NOT gt_shptoemail[] IS INITIAL.
        SORT gt_shptoemail .
        DELETE ADJACENT DUPLICATES FROM gt_shptoemail.
        LOOP AT gt_shptoemail.
          t_receivers-receiver = gt_shptoemail-lv_email.
          t_receivers-rec_type = 'U'.
          t_receivers-com_type = 'INT'.
          t_receivers-notif_del = 'X'.
          t_receivers-notif_ndel = 'X'.
          APPEND t_receivers.
          CLEAR t_receivers.
        ENDLOOP.
      ELSE.
    There is no one to email the output to
        CLEAR: syst-msgv1, syst-msgv2, syst-msgv3, syst-msgv4.
        retcode = 1.
        syst-msgid = 'ZM'.
        syst-msgno = 005.
        syst-msgty = 'E'.
        syst-msgv1 = text-e02.
        PERFORM protocol_update.
      ENDIF.
      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.
      IF sy-subrc = 0.
        LOOP AT gt_shptoemail.
          syst-msgid = 'Z1'.
          syst-msgno = 075.
          syst-msgty = 'S'.
          syst-msgv1 = text-s01.
          syst-msgv2 = gt_shptoemail-lv_email.
          CLEAR syst-msgv3.
          CLEAR syst-msgv4.
          PERFORM protocol_update.
          IF sy-batch = 'X'.
            MESSAGE i999(z1) WITH text-s01 gt_shptoemail-lv_email.
          ENDIF.
        ENDLOOP.
      ENDIF.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.

  • Thai characters to PDF using smart forms

    Hi All,
    I have created a smartform which displays order details. The address contains thai characters. While viewing the preview, the characters are displayed correctly.
    The OTF form of this print is converted into PDF using the function module CONVERT_OTF and sent as mail attachment.
    The issue is in the PDF attachment, thai characters are converted to junk characters. Can anyone suggest how to overcome this?
    FYI, for displaying thai characters, chinese font THANGSAN is used.
    Thanks & regards,
    Juli.

    Hi,
    There is no command like this. If you use device type PDFUC or SWINCF to create the  spool before converting via RSTXPDFT4, then the PDF conversion will be unicode. See SAP note #999712. But you still need to upload true type fonts to support the Thai characters, this time via report RSTXPDF2UC as per note 999712 and the attached guide. The Adobe fonts don't support Thai so it is needed to embed Angsana new true type font into the PDF file to support Thai characters.
    Regards,
    Aidan

Maybe you are looking for