PDF to Internal Table

Hi All,
I want to convert my generated PDF output into an internal table.
Please suggest some way to do that.
Thanks & Regards,
Vivek

Hi,
please follow this thread
extracting the data from pdf  file to internal table in abap
Reg: To PDF document in to internal table of a report
Hope this helps
Regards,
Manish
Edited by: MANISH GUPTA on Sep 5, 2008 8:48 AM

Similar Messages

  • How to read pdf to internal table

    hi,
    i have pdf file having reprot for multiple invoices ,one report per page per invoice.
    i want to split this pdf into multiple pdf  for each invoices.
    please advice.
    regards,
    sheetal.

    HI Srivijaya
    I have to upload details from PDF document saved into C drive into internal table.
    While refering to the programme FP_PDF_TEST_03,it actually upload the details into excel sheet.
    in this programme "PERFORM download_file USING l_data p_xml." is actually uploading the details(Stored in l_data) into XLS format through path p_xml.
    What i need is to upload records into internal table .But the fromat of the l_data is in hexadecimal(Ex : 3C3F786D6C2076657273696F).
    I cannot read these values and upload into internal table
    Do you know any FM which convert Hexa into xml format or any thing else so that i can read the details into my internal table.
    Or you have any other suggestions
    Waiting for your reply

  • Internal table in pdf output

    Hi All,
    My requirement is on click of a button i need to opwn a new window and display the table output through pdf.
    I am displaying a table through my bsp page using html code.
    On click of a button i need to open a window and show up the table data in pdf which should be printable.
    Am not using any iterator for my table. i just need transfer the internal table output to pdf and display.
    Please help.
    Thanks,
    Sandeep.

    Hi Alonso,
    Am not able to get the solution for my requirement, could you please give me the detailed solution.
    Can i go in this way.
    What parameters should i use for otf FM
    //...convert otf FM
    CONCATENATE cl_abap_char_utilities=>byte_order_mark_little
                    l_xstring
               INTO l_xstring IN BYTE MODE.
        CONCATENATE 'attachment; filename=NIM2_matter_Summary_'
                    sy-uzeit
                    '.pdf'
               INTO l_content.
        CALL METHOD cl_bsp_utility=>download
           EXPORTING
               object_s            = l_xstring
               content_type        = app_type
               content_disposition = l_content
               response            = _m_response
               navigation          = _m_navigation.
    Thanks in advance.

  • How to Extract Data from the PDF file to an internal table.

    HI friends,
    How can i Extract data from a PDF file to an internal table....
    Thanks in Advance
    Shankar

    Shankar,
    Have a look at these threads:-
    extracting the data from pdf  file to internal table in abap
    Adobe Form (data extraction error)
    Chintan

  • PDF File from an internal table data

    I have an internal table ready for grid display of a report. But according to the new requirement, it shouldn't create a Spool request as it is affecting the performance of the system (because its a huge file with 3000+ pages).
    So, now we want to create a (non-editable) PDF File and store it in an application server.
    From the forum, i see that i have only one option, which is to Convert internal table data to OTF Format and then to PDF.
    Right now i am using  PRINT_TEXT to convert to OTF file and FM CONVERT_OTF for PDF file.
    The challenges i am facing right now is..
    1. After getting the OTF file from PRINT_TEXT, i couldn't get the correct PDF File. It shows random characters instead..
    2. My internal table has 103 columns. So how should i accommodate data from all these columns into a single row on a PDF?
    3. I couldn't create a table kind of view/display in PDF
    Please help/advice me on the above issue.
    Thanks,
    Sarada

    Hi,
    103 columns need to be seen in at least 7 pages or more. Cant display in just 1 page.
    I guess that better to create a smartforms and pass all the information from the table to the smartforms.
    There you can create multipages.
    Probably, that huge table need to separete it in 7 tables, so each page will get the information from one table...
    i will try to do sth like that.
    Regards
    Miguel

  • Create Spool from Internal table & converrt the spool to PDF

    Hi All,
    My requirement is take data from a table and find amount specific to each Vendors . So I took all the data into ITAB and do all the calculation. Later after calculation I have to create a spool from this ITAB and this spool have to convert to PDF. Later this PDF have to seend via email.
    To convert the internal table to Spool , I used
    LOOP AT t_summ INTO wa_summ.
        w-amount = wa_summ-remittanceamount.
        CONCATENATE wa_summ-vendorcode
                    wa_summ-controlnum
                    w-amount INTO wa_textdata SEPARATED BY space.
        APPEND wa_textdata TO t_textdata.
      ENDLOOP.
      DESCRIBE TABLE t_textdata .
      w-file_length = syst-tfill * 1022.
      l_doctype = 'LIST'.
      l_layout = 'X_POSTSCRIPT'.
      CONCATENATE ' Listbill Summary Report for' syst-datum INTO
                          l_title SEPARATED BY space.
      l_receiver = syst-uname.
    * Create Spool
      CALL FUNCTION 'RSPO_SR_OPEN'
       EXPORTING
          dest                   = 'LOCL'
    *   LDEST                  =
          layout                 = l_layout
          name                   = 'SUMREP'
    *   SUFFIX1                =
    *   SUFFIX2                =
       copies                 = '1'
    *   PRIO                   =
    *      immediate_print        = ' '
    *   AUTO_DELETE            =
          titleline              = l_title
          receiver               = syst-uname           "
    *      division               = l_pri_params-prabt " abteilung
    *      authority              = l_pri_params-prber           "
    *   POSNAME                =
    *   ACTTIME                =
    *   LIFETIME               = '8'
    *   APPEND                 =
    *   COVERPAGE              =
    *   CODEPAGE               =
          doctype                = l_doctype
    *   ARCHMODE               =
    *   ARCHPARAMS             =
    *   TELELAND               =
    *   TELENUM                =
    *   TELENUME               =
         IMPORTING
          handle                 = l_spool_handle
          spoolid                = w-spoolid
    EXCEPTIONS
       device_missing         = 1
       name_twice             = 2
       no_such_device         = 3
       operation_failed       = 4
       OTHERS                 = 5
                .                                            "#EC DOM_EQUAL
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'SLVC_C1022_TO_C255'
        EXPORTING
          i_file_length = w-file_length
        TABLES
          it_c1022      = t_textdata
          et_c255       = lt_spool.
      l_length = w-file_length.
      LOOP AT lt_spool INTO ls_spool.
        l_length = l_length - 255.
        IF ( l_length > 0 ).
          l_line_length = 255.
        ELSE.
          l_line_length = l_length + 255.
        ENDIF.
    *   Write contents to spool
        CALL FUNCTION 'RSPO_SR_WRITE'
          EXPORTING
            handle = l_spool_handle
            text   = ls_spool
            length = l_line_length.
      ENDLOOP.
    * Close Spool
      CALL FUNCTION 'RSPO_SR_CLOSE'
        EXPORTING
          handle                 = l_spool_handle
         pages                  = 1
      FINAL                  = 'X'
       EXCEPTIONS
         handle_not_valid       = 1
         operation_failed       = 2
         OTHERS                 = 3
    By this I can see the spool with data in SP02.
    Then to conver to PDF, I used
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          src_spoolid                    = w-spoolid
          no_dialog                      = 'X'
          DST_DEVICE                     = 'LOCL'
    *      PDF_DESTINATION                =
        IMPORTING
    *      PDF_BYTECOUNT                  =
    *      PDF_SPOOLID                    =
          list_pagecount                 = list_pagecount
    *      BTC_JOBNAME                    =
    *      BTC_JOBCOUNT                   =
       TABLES
         pdf                            = t_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
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
        CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
    *   BIN_FILESIZE                    =
          filename                        = 'D:\t\t.pdf'
         filetype                        = 'BIN'
        TABLES
          data_tab                        = t_pdf
    *   FIELDNAMES                      =
       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
    But later when I go and open the PDF, I am getting an error saying'Page cannot be open because it dont have any pages'
    Please help me
    Regards,
    Nikhil

    Hi Nikhil,
    <li>If you are still not able to find out the problem. You can an alternative way , which is used for the same purpose.
    <li>Try this way. It creates spool and and same CONVERT_ABAPSPOOLJOB_2_PDF fm is used to convert spool to PDF. It works. Test this test program.
       REPORT ztest_notepad.
       DATA:g_val         TYPE c,
            w_pripar      TYPE pri_params,
            w_arcpar      TYPE arc_params,
            i_pdf         TYPE TABLE OF tline,
            spoolid       LIKE tsp01-rqident,
            l_no_of_bytes TYPE i,
            l_pdf_spoolid LIKE tsp01-rqident,
            l_jobname     LIKE tbtcjob-jobname,
            l_jobcount    LIKE tbtcjob-jobcount.
       DATA:it_t001 TYPE TABLE OF t001 WITH HEADER LINE.
       START-OF-SELECTION.
         SELECT * FROM t001 INTO TABLE it_t001.
         "Read, determine, change spool print parameters and archive parameters
         CALL FUNCTION 'GET_PRINT_PARAMETERS'
           EXPORTING
             in_archive_parameters  = w_arcpar
             in_parameters          = w_pripar
             layout                 = 'X_65_132'
             line_count             = 65
             line_size              = 132
             no_dialog              = 'X'
           IMPORTING
             out_archive_parameters = w_arcpar
             out_parameters         = w_pripar
             valid                  = g_val.
         IF g_val  NE space AND sy-subrc = 0.
           w_pripar-prrel = space.
           w_pripar-primm = space.
           NEW-PAGE PRINT ON  NEW-SECTION PARAMETERS w_pripar ARCHIVE PARAMETERS w_arcpar NO DIALOG.
         ENDIF.
         LOOP AT it_t001.
           WRITE:/ it_t001.
         ENDLOOP.
         NEW-PAGE PRINT OFF.
         CALL FUNCTION 'ABAP4_COMMIT_WORK'.
         spoolid = sy-spono.
         CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
             src_spoolid   = spoolid
             no_dialog     = ' '
           IMPORTING
             pdf_bytecount = l_no_of_bytes
             pdf_spoolid   = l_pdf_spoolid
             btc_jobname   = l_jobname
             btc_jobcount  = l_jobcount
           TABLES
             pdf           = i_pdf.
         CALL FUNCTION 'GUI_DOWNLOAD'
           EXPORTING
             filename = 'C:\temp\test.pdf'
             filetype = 'BIN'
           TABLES
             data_tab = i_pdf.
    Thanks
    Venkat.

  • Data present in  internal table, now how to open it in PDF format

    Dear Friends,
    my Scenario is..
    I have uploaded a pdf file in my database table through  GUI_UPLOAD. It is uploaded.
    Now when user click on some button then that file should be displayed again in pdf format directly.
    (No download to user PC using GUI_download or something)
    DBtab ZTST_XL Format
    MANDT     MANDT     CLNT     3
    KEYA     CHAR5     CHAR     5
    KEY2     INT4     INT4     10
    LENGTH     INT2     INT2     5
    DATA          LCHR     1000
    I brought that data again in my internal table by 
    SELECT * FROM ZTST_XL
        INTO TABLE DBTAB
        WHERE KEYA = 'TEST'.
      LOOP AT DBTAB.
        ITAB-DATA = DBTAB-DATA.
        APPEND ITAB.
      ENDLOOP.
    Now I need to open this PDF file in normal format as it opens usually rather than downloading it on users PC .
    Any Help regarding this will be very much useful
    Thanks & Regards,
    Sourabh

    >
    Sourabh Jain wrote:
    > Dear Suhas,
    > Sorry for Confusion,
    > Actually I was trying to say that ,, I have already uploaded that pdf file to my database table on click of first button,
    > now on click of second button I have to show/open that uploaded pdf file.
    So you just want to show the PDF file you have uploaded to the DB on click of the 2nd button.
    Now you can use the method CL_GUI_FRONTEND_SERVICES=>EXECUTE for this after the user clicks the 2nd button
    CALL METHOD cl_gui_frontend_services=>execute
          EXPORTING
            DOCUMENT              = lv_document "The filepath you have used for GUI_UPLOAD
          EXCEPTIONS
            cntl_error             = 1
            error_no_gui           = 2
            bad_parameter          = 3
            file_not_found         = 4
            path_not_found         = 5
            file_extension_unknown = 6
            error_execute_failed   = 7
            synchronous_failed     = 8
            not_supported_by_gui   = 9
            OTHERS                 = 10.
    Hope i am clear.
    BR,
    Suhas

  • Send internal table to pdf and then email.

    hi experts.
    i want to send my alv data or any other data like internal table in pdf through email.
    anybody help me out plz.

    Hi Harris,
    You got to use two FMs to achieve this.
    First one to get the contents in to an internal table
    Second one to send an e-mail with the content selected already.
    So, better search SDN to get more info...

  • OTF to PDF - Getting blank PDF Internal table with CONVERT_OTF func module

    All
    i've captured OTF from smartforms and tried converting to PDF through 'CONVERT_OTF_2_PDF' FUNCTIOn module and after emailing to external email id, i found logo is completely disturbed (characters in logo got mixed up)..... later i tried converting with ''CONVERT_OTF' function module, but here i'm getting blank PDF internal table....
    what am i missing in both ?
    my intention is converting otf to pdf and emailing...though there are thousands of similar threads are available , none of them are related to my exact problem, which is logo is getting mixed up or disturbed.... any suggestions ?
    Thanks in advance

    Hi,
    You need to use the function module SX_OBJECT_CONVERT_OTF_PDF to create the PDF from OTF ..
    Here is an example program
    report ZPDFPRNT no standard page heading.
    TABLES: TST05.
    DATA: BEGIN OF ITAB OCCURS 0,
       TLINE(255),
    END OF ITAB.
    DATA: BEGIN OF ITAB2 OCCURS 0,
      TLINE(255),
    END OF ITAB2.
    DATA: BEGIN OF ITAB3 OCCURS 0,
      TLINE(255),
    END OF ITAB3.
    DATA: BEGIN OF OTF_TAB OCCURS 0,
      TLINE(255),
    END OF OTF_TAB.
    DATA: LEN_OUT LIKE SOOD-OBJLEN.
    DATA: LEN_IN LIKE SOOD-OBJLEN.
    DATA: BEGIN OF DATA_SET OCCURS 200,
      DATA_LENGTH(5),
      PRECOL(1),
      DATA_LINE(1000),
    END OF DATA_SET.
    DATA: BEGIN OF OTF_PAGE OCCURS 200.
      INCLUDE STRUCTURE ITCOO.
    DATA: END OF OTF_PAGE,
    OTF_PAGES TYPE P,
    OTF_MAX_PAGES TYPE P VALUE 10.
    DATA: BEGIN OF OTF_CONTROL.
      INCLUDE STRUCTURE ITCPP.
    DATA: END OF OTF_CONTROL,
    FORCE_RAW_OTF VALUE ' ',
    L100_EXCLUDE(4) VALUE 'OTFJ',
    BEGIN OF OTF_PAGE_INDEX OCCURS 20,
      LINE_NUM TYPE P,
    END OF OTF_PAGE_INDEX,
    CUR_OTF_PAGE VALUE 1.
    DATA: DATA_SET_LINECOUNT TYPE P,
    DATA_SET_MAX_LINES TYPE P VALUE 100000,
    DATA_SET_VALID TYPE C VALUE ' ',
    DATA_SET_IS_OTF TYPE C VALUE ' ',
    DATA_SET_LENGTH(5) TYPE C,
    LINE_SPECIAL LIKE DATA_SET-DATA_LINE,
    NEED_LINE_SPECIAL TYPE C,
    DSN_TYPE(8) TYPE C.
    DATA: FCODE(4) TYPE C,
    DATE TYPE D,
    TIME TYPE T,
    RC(10) TYPE C,
    ERRMSG(100) TYPE C,
    PRINTJOB_CREATED(1) TYPE C,
    PRINTJOB_CLEARED(1) TYPE C,
    PRINTJOB_LIST(1) TYPE C,
    DISPLAY_MODE(1) TYPE C,
    LINE_MAX TYPE P VALUE '100000',
    NEW_SCREEN_300(1) TYPE C,
    MULTI_PRINT_300(1) TYPE C,
    PRINT_ALL_300(1) TYPE C,
    PRINT_COUNT_300 TYPE I,
    SHOW_USER_100 TYPE C VALUE ' ',
    ERROR_DISPLAY_LEVEL TYPE C VALUE '9',
    NEXT_ERROR_DISPLAY_LEVEL TYPE C,
    PREV_ERROR_DISPLAY_LEVEL TYPE C,
    START_300(5) TYPE C, END_300(5) TYPE C,
    SEP LIKE SY-VLINE,
    DEFAULT_PRI,
    TSP01_BUF LIKE TSP01,
    TSP01_CURLINE LIKE SY-STARO,
    TSP01_CURCOL LIKE SY-CUCOL,
    TSP01_CURROW LIKE SY-CUROW.
    DATA: BEGIN OF DATA_SET_LINE,
      DATA_LENGTH(5),
      PRECOL(1),
    DATA_LINE(1000),
    END OF DATA_SET_LINE.
    DATA: STATUS LIKE SY-SUBRC.
    DATA: WGF_MESSAGE(80).
    DATA: H_PATH(20) TYPE C.
    DATA: H_MASK(20) TYPE C VALUE ',.pdf ,.pdf. '.
    DATA: FILE_NAME(20).
    DATA: FILENAME LIKE RLGRAP-FILENAME.
    DATA: IMPORT(132).
    PARAMETERS: IDENT(5) TYPE C.
    PERFORM GET_OTF_TAB.
    LOOP AT OTF_PAGE.
       OTF_TAB-TLINE = OTF_PAGE.
       APPEND OTF_TAB.
    ENDLOOP.
    CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
    EXPORTING
      FORMAT_SRC = 'OTF'
      FORMAT_DST = 'PDF'
      DEVTYPE = 'ASCIIPRI'
      LEN_IN = LEN_IN
    IMPORTING
      LEN_OUT = LEN_OUT
    TABLES
      CONTENT_IN = OTF_TAB
      CONTENT_OUT = ITAB2
    EXCEPTIONS
      ERR_CONV_FAILED = 1
      OTHERS = 2.
    PERFORM GET_PATH USING 'PDF_FILE'.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      FILENAME = FILENAME
      FILETYPE = 'BIN'
      BIN_FILESIZE = LEN_OUT
    TABLES
      DATA_TAB = ITAB2
    EXCEPTIONS
      FILE_OPEN_ERROR = 1
      FILE_WRITE_ERROR = 2
      INVALID_FILESIZE = 3
      INVALID_TABLE_WIDTH = 4
      INVALID_TYPE = 5
      NO_BATCH = 6
      UNKNOWN_ERROR = 7
      OTHERS = 8.
    *& Form GET_OTF_TAB
    FORM GET_OTF_TAB.
    DATA: PART(4) VALUE '0001',
    BEGIN OF MSG,
      A(40),
      B(40),
      C(40),
    END OF MSG.
    REFRESH DATA_SET.
    DATA_SET_LINECOUNT = 0.
    DATA_SET_IS_OTF = ' '.
    OTF_PAGES = 0.
    REFRESH OTF_PAGE_INDEX.
    CALL 'RSPOACSD'.
    SELECT * FROM TST05 WHERE DTHREAD = 'X'.
    CALL 'RSPOAOSD'
    ID 'ID' FIELD IDENT
    ID 'TYPE' FIELD TST05-DTYPE
    ID 'RECTYP' FIELD 'VYL----'
    ID 'RC' FIELD RC
    ID 'ERRMSG' FIELD ERRMSG.
    STATUS = SY-SUBRC.
    IF STATUS = 0.
      DSN_TYPE = TST05-DTYPE.
      IF DSN_TYPE(3) = 'OTF'.
        DATA_SET_IS_OTF = 'X'.
      ENDIF.
    ENDIF.
    IF STATUS <> 24. EXIT. ENDIF.
    ENDSELECT.
    DATA_SET_VALID = 'X'.
    DATA_SET_MAX_LINES = ( LINE_MAX * '1.1' ) + 100.
    DO.
    CLEAR: DATA_SET_LINE, DATA_SET_LENGTH.
    CALL 'RSPOARSD'
    ID 'BUFF' FIELD DATA_SET_LINE+5
    ID 'DATALEN' FIELD DATA_SET_LENGTH
    ID 'RC' FIELD RC
    ID 'ERRMSG' FIELD ERRMSG.
    STATUS = SY-SUBRC.
    IF STATUS = 36.
    WHILE STATUS = 36.
    CALL 'RSPOACSD'
    ID 'RC' FIELD RC
    ID 'ERRMSG' FIELD ERRMSG.
    ADD 1 TO PART.
    IF DATA_SET_IS_OTF = ' '.
    CALL 'RSPOAOSD'
    ID 'ID' FIELD IDENT
    ID 'TYPE' FIELD DSN_TYPE
    ID 'PART' FIELD PART
    ID 'RECTYP' FIELD 'VYL----'
    ID 'RC' FIELD RC
    ID 'ERRMSG' FIELD ERRMSG.
    ELSE.
    CALL 'RSPOAOSD'
    ID 'ID' FIELD IDENT
    ID 'PART' FIELD PART
    ID 'TYPE' FIELD DSN_TYPE
    ID 'RECTYP' FIELD 'VYL----'
    ID 'RC' FIELD RC
    ID 'ERRMSG' FIELD ERRMSG.
    ENDIF.
    IF SY-SUBRC NE 0. EXIT. ENDIF.
    CLEAR: DATA_SET_LINE, DATA_SET_LENGTH.
    CALL 'RSPOARSD'
    ID 'BUFF' FIELD DATA_SET_LINE+5
    ID 'DATALEN' FIELD DATA_SET_LENGTH
    ID 'RC' FIELD RC
    ID 'ERRMSG' FIELD ERRMSG.
    STATUS = SY-SUBRC.
    ENDWHILE.
    ENDIF.
    IF STATUS <> 0 AND STATUS <> 40. EXIT. ENDIF.
    DATA_SET = DATA_SET_LINE.
    IF NOT ( DATA_SET_LENGTH IS INITIAL ).
    DATA_SET-DATA_LENGTH = DATA_SET_LENGTH - 1.
    ENDIF.
    APPEND DATA_SET.
    ADD 1 TO DATA_SET_LINECOUNT.
    IF DATA_SET_IS_OTF = ' '.
    IF DATA_SET_LINECOUNT >= DATA_SET_MAX_LINES.
    CLEAR DATA_SET.
    APPEND DATA_SET.
    MOVE '----
    ' TO DATA_SET-DATA_LINE.
    APPEND DATA_SET.
    CLEAR DATA_SET.
    APPEND DATA_SET.
    WRITE: 'Abbruch nach'(029) TO MSG-A.
    WRITE: DATA_SET_MAX_LINES TO MSG-B.
    WRITE: 'Zeilen.'(030) TO MSG-C.
    CONDENSE MSG.
    DATA_SET-DATA_LINE = MSG.
    APPEND DATA_SET.
    EXIT.
    ENDIF.
    ELSE.
    MOVE DATA_SET_LINE-DATA_LINE TO OTF_PAGE.
    APPEND OTF_PAGE.
    IF OTF_PAGE(2) = 'EP'.
      ADD 1 TO OTF_PAGES.
      IF OTF_PAGES >= OTF_MAX_PAGES.
        MESSAGE S229(PO) WITH OTF_MAX_PAGES.
        EXIT.
      ENDIF.
    ELSEIF OTF_PAGE(2) = 'OP'.
      OTF_PAGE_INDEX-LINE_NUM = DATA_SET_LINECOUNT.
      APPEND OTF_PAGE_INDEX.
    ENDIF.
    ENDIF.
    ENDDO.
    IF STATUS <> 0 AND STATUS <> 12.
      CALL 'RSPOACSD'.
      MESSAGE E112(PO) WITH STATUS RC ERRMSG.
    ENDIF.
    CALL 'RSPOACSD'.
    STATUS = SY-SUBRC.
    IF STATUS <> 0.
      MESSAGE E112(PO) WITH STATUS RC ERRMSG.
    ENDIF.
    ENDFORM. " GET_OTF_TAB
    *& Form GET_PATH
    FORM GET_PATH USING P_FILENAME.
    CLEAR: H_PATH, FILE_NAME.
    FILE_NAME = P_FILENAME.
    CALL FUNCTION 'WS_QUERY'
    EXPORTING
    QUERY = 'CD' "// Current Directory
    IMPORTING
    RETURN = H_PATH.
    CONCATENATE FILE_NAME '.pdf' INTO FILE_NAME.
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      DEF_FILENAME = FILE_NAME
      DEF_PATH = H_PATH
      MASK = H_MASK
      MODE = 'O'
    IMPORTING
      FILENAME = FILENAME"dbname
    EXCEPTIONS
      INV_WINSYS = 1
      NO_BATCH = 2
      SELECTION_CANCEL = 3
      SELECTION_ERROR = 4
      OTHERS = 5.
    ENDFORM. " GET_PATH
    Regards
    Sudheer

  • Convert internal table data to pdf format and send mail to Users

    Hi all ,
    I want to convert the data available in internal table to pdf format and then send it to mail .
    Please tell me wht are the fn modules available to convert the data from internal table to pdf and then send it mail .
    regards
    santosh .

    Hi Santosh
    Sending mail with attachment report in Background
    Content Author: Fernando Faian
    I have read the hint about "Sending mail with attachment report".
    It's great, but how can I make this function work in background??
    I had that needed last year too. See attachment a function group with two functions. The second one has that functionality to send email or fax (SAP office) with attachment objects in background job using SO_ATTACHMENT_INSERT function. 
    Pay attention because it’s working with output list from spool converted to pdf. 
    =================================================================================
    z_send_email_fax_global
    FUNCTION-POOL z_gfaian_mail_fax.            "MESSAGE-ID ..
    WORK TABLE AREAS
    TABLES: tsp01.
    INTERNAL TABLES
    DATA: lt_rec_tab LIKE STANDARD TABLE OF soos1 WITH HEADER LINE,
          lt_note_text   LIKE STANDARD TABLE OF soli  WITH HEADER LINE,
          lt_attachments LIKE STANDARD TABLE OF sood5 WITH HEADER LINE.
    DATA: lt_objcont LIKE STANDARD TABLE OF soli WITH HEADER LINE,
          lt_objhead LIKE STANDARD TABLE OF soli WITH HEADER LINE.
    DATA: pdf_format LIKE STANDARD TABLE OF tline WITH HEADER LINE.
    TYPES: BEGIN OF y_files,
           file(60) TYPE c,
           END OF y_files.
    DATA: lt_files TYPE STANDARD TABLE OF y_files WITH HEADER LINE.
    DATA: l_objcont     LIKE soli OCCURS 0 WITH HEADER LINE.
    DATA: l_objhead     LIKE soli OCCURS 0 WITH HEADER LINE.
    STRUCTURES
    DATA: folder_id      LIKE soodk,
          object_id      LIKE soodk,
          link_folder_id LIKE soodk,
          g_document     LIKE sood4,
         g_header_data  LIKE sood2,
          g_folmem_data  LIKE sofm2,
          g_header_data  LIKE sood2,
          g_receive_data LIKE soos6,
          g_ref_document LIKE sood4,
          g_new_parent   LIKE soodk,
          l_folder_id    LIKE sofdk,
          v_email(50).
    DATA: hd_dat  like sood1.
    VARIABLES
    DATA: client  LIKE tst01-dclient,
          name    LIKE tst01-dname,
          objtype LIKE rststype-type,
          type    LIKE rststype-type.
    DATA: numbytes TYPE i,
          arc_idx LIKE toa_dara,
          pdfspoolid LIKE tsp01-rqident,
          jobname LIKE tbtcjob-jobname,
          jobcount LIKE tbtcjob-jobcount,
          is_otf.
    DATA: outbox_flag LIKE sonv-flag VALUE 'X',
          store_flag  LIKE sonv-flag,
          delete_flag LIKE sonv-flag,
          owner       LIKE soud-usrnam,
          on          LIKE sonv-flag VALUE 'X',
          sent_to_all LIKE sonv-flag,
          g_authority LIKE sofa-usracc,
          w_objdes    LIKE sood4-objdes.
    DATA: c_file LIKE rlgrap-filename,
          n_spool(6) TYPE n.
    DATA: cancel.
    DATA: desired_type  LIKE sood-objtp,
          real_type LIKE sood-objtp,
          attach_type LIKE sood-objtp,
          otf LIKE sood-objtp VALUE 'OTF', " SAPscript Ausgabeformat
          ali LIKE sood-objtp VALUE 'ALI'. " ABAP lists
    CONSTANTS
    CONSTANTS: ou_fol LIKE sofh-folrg              VALUE 'O',
               c_objtp    LIKE g_document-objtp    VALUE 'RAW',
               c_file_ext LIKE g_document-file_ext VALUE 'TXT'.
    =================================================================================
    z_send_email_fax2
    FUNCTION z_faian_mail_fax2.
    ""Interface local:
    *"  IMPORTING
    *"     REFERENCE(SRC_SPOOLID) LIKE  TSP01-RQIDENT
    *"     REFERENCE(FAX_MAIL_NUMBER) TYPE  SO_NAME
    *"     REFERENCE(HEADER_MAIL) TYPE  SO_OBJ_DES
    *"     REFERENCE(OBJECT_TYPE) TYPE  SO_ESCAPE
    *"  TABLES
    *"      LT_BODY_EMAIL STRUCTURE  SOLI
    *"  EXCEPTIONS
    *"      ERR_NO_ABAP_SPOOLJOB
    Fist part: Verify if the spool really exists
      SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
      IF sy-subrc NE 0.
        RAISE err_no_abap_spooljob. "doesn't exist
      ELSE.
        client = tsp01-rqclient.
        name   = tsp01-rqo1name.
        CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
             EXPORTING
                  authority     = 'SP01'
                  client        = client
                  name          = name
                  part          = 1
             IMPORTING
                  type          = type
                  objtype       = objtype
             EXCEPTIONS
                  fb_error      = 1
                  fb_rsts_other = 2
                  no_object     = 3
                  no_permission = 4
                  OTHERS        = 5.
        IF objtype(3) = 'OTF'.
          desired_type = otf.
        ELSE.
          desired_type = ali.
        ENDIF.
        CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
             EXPORTING
                  rqident              = src_spoolid
                  desired_type         = desired_type
             IMPORTING
                  real_type            = real_type
             TABLES
                  buffer               = l_objcont
             EXCEPTIONS
                  no_such_job          = 14
                  type_no_match        = 94
                  job_contains_no_data = 54
                  no_permission        = 21
                  can_not_access       = 21
                  read_error           = 54.
        IF sy-subrc EQ 0.
          attach_type = real_type.
        ENDIF.
        CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
             EXPORTING
                  owner     = sy-uname
                  region    = ou_fol
             IMPORTING
                  folder_id = l_folder_id
             EXCEPTIONS
                  OTHERS    = 5.
    fill out informations about the header of the email
        CLEAR: g_document.
        g_document-foltp     = l_folder_id-foltp.
        g_document-folyr     = l_folder_id-folyr.
        g_document-folno     = l_folder_id-folno.
        g_document-objtp     = c_objtp.
        g_document-objdes    = header_mail.
        g_document-file_ext  = c_file_ext.
        g_header_data-objdes    = header_mail.
        CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
             EXPORTING
                  method      = 'SAVE'
                  office_user = sy-uname
             IMPORTING
                  authority   = g_authority
             TABLES
                  objcont     = lt_body_email
                  attachments = lt_attachments
             CHANGING
                  document    = g_document
                  header_data = g_header_data
             EXCEPTIONS
                  OTHERS      = 1.
        folder_id-objtp = l_folder_id-foltp.
        folder_id-objyr = l_folder_id-folyr.
        folder_id-objno = l_folder_id-folno.
        object_id-objtp = c_objtp.
        object_id-objyr = g_document-objyr.
        object_id-objno = g_document-objno.
        link_folder_id-objtp = l_folder_id-foltp.
        link_folder_id-objyr = l_folder_id-folyr.
        link_folder_id-objno = l_folder_id-folno.
        REFRESH lt_rec_tab.
       CLEAR lt_rec_tab.
       lt_rec_tab-sel        = 'X'.
       lt_rec_tab-recesc     = object_type.   "This field for FAX/MAIL
       lt_rec_tab-recnam     = 'U-'.
       lt_rec_tab-deliver    = 'X'.
       lt_rec_tab-not_deli   = 'X'.
       lt_rec_tab-read       = 'X'.
       lt_rec_tab-mailstatus = 'E'.
       lt_rec_tab-adr_name   = fax_mail_number.
       lt_rec_tab-sortfield  = fax_mail_number.
       lt_rec_tab-recextnam  = fax_mail_number.
       lt_rec_tab-sortclass  = '5'.
       APPEND lt_rec_tab.
          lt_rec_tab-recextnam = fax_mail_number.
          lt_rec_tab-recesc = object_type.
          lt_rec_tab-sndart = 'INT'.
          lt_rec_tab-sndpri = 1.
          APPEND lt_rec_tab.
        lt_files-file = c_file.
        APPEND lt_files.
    begin of insertion by faianf01
        hd_dat-objdes = header_mail.
        CALL FUNCTION 'SO_ATTACHMENT_INSERT'
             EXPORTING
                  object_id                  = object_id
                  attach_type                = attach_type
                  object_hd_change           = hd_dat
                  owner                      = sy-uname
             TABLES
                  objcont                    = l_objcont
                  objhead                    = l_objhead
             EXCEPTIONS
                  active_user_not_exist      = 35
                  communication_failure      = 71
                  object_type_not_exist      = 17
                  operation_no_authorization = 21
                  owner_not_exist            = 22
                  parameter_error            = 23
                  substitute_not_active      = 31
                  substitute_not_defined     = 32
                  system_failure             = 72
                  x_error                    = 1000.
        IF sy-subrc > 0.
        ENDIF.
    end of insertion by faianf01
    send email from SAPOFFICE
        CALL FUNCTION 'SO_OBJECT_SEND'
             EXPORTING
                  folder_id                  = folder_id
                  object_id                  = object_id
                  outbox_flag                = outbox_flag
                  link_folder_id             = link_folder_id
                  owner                      = sy-uname
                 check_send_authority       = 'X'
             TABLES
                  receivers                  = lt_rec_tab
                 note_text                  = lt_note_text
             EXCEPTIONS
                  active_user_not_exist      = 35
                  communication_failure      = 71
                  component_not_available    = 1
                  folder_no_authorization    = 5
                  folder_not_exist           = 6
                  forwarder_not_exist        = 8
                  object_no_authorization    = 13
                  object_not_exist           = 14
                  object_not_sent            = 15
                  operation_no_authorization = 21
                  owner_not_exist            = 22
                  parameter_error            = 23
                  substitute_not_active      = 31
                  substitute_not_defined     = 32
                  system_failure             = 72
                  too_much_receivers         = 73
                  user_not_exist             = 35.
      ENDIF.
    ENDFUNCTION.
    =================================================================================
    z_send_email_fax
    FUNCTION ZCBFS_SEND_MAIL.
    ""Interface local:
    *"  IMPORTING
    *"     REFERENCE(SRC_SPOOLID) LIKE  TSP01-RQIDENT
    *"     REFERENCE(HEADER_MAIL) TYPE  SO_OBJ_DES
    *"  TABLES
    *"      LIST_FAX_MAIL_NUMBER STRUCTURE  SOLI
    *"  EXCEPTIONS
    *"      ERR_NO_ABAP_SPOOLJOB
      DATA: vg_achou(1) TYPE n.
    Fist part: Verify if the spool really exists
      vg_achou = 1.
      DO 60 TIMES.
        SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
        IF sy-subrc IS INITIAL.
          CLEAR vg_achou.
          EXIT.
        ELSE.
          WAIT UP TO 1 SECONDS.
        ENDIF.
      ENDDO.
      IF vg_achou = 1.
        RAISE err_no_abap_spooljob. "doesn't exist
      ENDIF.
      client = tsp01-rqclient.
      name   = tsp01-rqo1name.
      CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
           EXPORTING
                authority     = 'SP01'
                client        = client
                name          = name
                part          = 1
           IMPORTING
                type          = type
                objtype       = objtype
           EXCEPTIONS
                fb_error      = 1
                fb_rsts_other = 2
                no_object     = 3
                no_permission = 4
                OTHERS        = 5.
      IF objtype(3) = 'OTF'.
        desired_type = otf.
      ELSE.
        desired_type = ali.
      ENDIF.
      CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
           EXPORTING
                rqident              = src_spoolid
                desired_type         = desired_type
           IMPORTING
                real_type            = real_type
           TABLES
                buffer               = l_objcont
           EXCEPTIONS
                no_such_job          = 14
                type_no_match        = 94
                job_contains_no_data = 54
                no_permission        = 21
                can_not_access       = 21
                read_error           = 54.
      IF sy-subrc EQ 0.
        attach_type = real_type.
      ENDIF.
      CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
           EXPORTING
                owner     = sy-uname
                region    = ou_fol
           IMPORTING
                folder_id = l_folder_id
           EXCEPTIONS
                OTHERS    = 5.
    fill out informations about the header of the email
      CLEAR: g_document.
      g_document-foltp     = l_folder_id-foltp.
      g_document-folyr     = l_folder_id-folyr.
      g_document-folno     = l_folder_id-folno.
      g_document-objtp     = c_objtp.
      g_document-objdes    = header_mail.
      g_document-file_ext  = c_file_ext.
      g_header_data-objdes    = header_mail.
      CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
           EXPORTING
                method      = 'SAVE'
                office_user = sy-uname
           IMPORTING
                authority   = g_authority
           TABLES
                attachments = lt_attachments
           CHANGING
                document    = g_document
                header_data = g_header_data
           EXCEPTIONS
                OTHERS      = 1.
      folder_id-objtp = l_folder_id-foltp.
      folder_id-objyr = l_folder_id-folyr.
      folder_id-objno = l_folder_id-folno.
      object_id-objtp = c_objtp.
      object_id-objyr = g_document-objyr.
      object_id-objno = g_document-objno.
      link_folder_id-objtp = l_folder_id-foltp.
      link_folder_id-objyr = l_folder_id-folyr.
      link_folder_id-objno = l_folder_id-folno.
      REFRESH lt_rec_tab.
      LOOP AT LIST_FAX_MAIL_NUMBER.
        lt_rec_tab-recextnam = LIST_FAX_MAIL_NUMBER-LINE.
        lt_rec_tab-recesc = 'U'.
        lt_rec_tab-sndart = 'INT'.
        lt_rec_tab-sndpri = 1.
        APPEND lt_rec_tab.
      ENDLOOP.
      lt_files-file = c_file.
      APPEND lt_files.
      hd_dat-objdes = header_mail.
      CALL FUNCTION 'SO_ATTACHMENT_INSERT'
           EXPORTING
                object_id                  = object_id
                attach_type                = attach_type
                object_hd_change           = hd_dat
                owner                      = sy-uname
           TABLES
                objcont                    = l_objcont
                objhead                    = l_objhead
           EXCEPTIONS
                active_user_not_exist      = 35
                communication_failure      = 71
                object_type_not_exist      = 17
                operation_no_authorization = 21
                owner_not_exist            = 22
                parameter_error            = 23
                substitute_not_active      = 31
                substitute_not_defined     = 32
                system_failure             = 72
                x_error                    = 1000.
      IF sy-subrc > 0.
      ENDIF.
    send email from SAPOFFICE
      CALL FUNCTION 'SO_OBJECT_SEND'
           EXPORTING
                folder_id                  = folder_id
                object_id                  = object_id
                outbox_flag                = outbox_flag
                link_folder_id             = link_folder_id
                owner                      = sy-uname
           TABLES
                receivers                  = lt_rec_tab
                note_text                  = lt_note_text
           EXCEPTIONS
                active_user_not_exist      = 35
                communication_failure      = 71
                component_not_available    = 1
                folder_no_authorization    = 5
                folder_not_exist           = 6
                forwarder_not_exist        = 8
                object_no_authorization    = 13
                object_not_exist           = 14
                object_not_sent            = 15
                operation_no_authorization = 21
                owner_not_exist            = 22
                parameter_error            = 23
                substitute_not_active      = 31
                substitute_not_defined     = 32
                system_failure             = 72
                too_much_receivers         = 73
                user_not_exist             = 35.
    ENDFUNCTION.
    Regards,
    Sree

  • Steps for: Internal table - convert to PDF - Sotre PDF files on UNIX Server

    Hi Experts,
                      My requirement is to Split an internal table into multiple tables and generate a PDF for each of them.Then I have to place these files on a unix server directory. How can I achieve this?
    This seems like a very high level requirement description .Please let me know if the solution needs some more details.
    Thanks In Advance
    Abhishek
    Edited by: Yatin Vishwas Parab on Oct 23, 2009 1:53 PM

    Hi,
    1) The logic for splitting a internal table into multiple tables should lie with you .
    2) write each of the split internal table to spool and convert them to PDF using the FM 'CONVERT_ABAPSPOOLJOB_2_PDF'. This has been discussed many times and you can find relevant threads by searching.
    3) For storing the PDF in application server, use OPEN DATASET statement in binary mode and transfer the data. Even this has been discussed quite a few times before and you can search for relevant threads
    Vikranth

  • Problem with pdf output of an internal table

    Hi,
    My requirement is to get the internal table out put to be displayed through pdf in a table form.
    Internal table :  
         Matter       Matter Description -
    > Table Head
         0011            Standard            -
    > Table contents
         0022             Clerk
    I want this to be displayed through pdf in same format.
    I searched sdn and tried this way.
    Please help if am wrong anywhere.
    Thanks,
    Sandeep
    Edited by: SandeepReddy on Jun 9, 2010 9:13 AM

    types:begin of ty_mara,
    matnr type matnr,
    end of ty_mara.
    data i_mara type standard table of ty_mara.
    data itab like line of i_mara.
    DATA: v_handle LIKE sy-tabix,
    v_spool_id type RSPOID,
    v_rc TYPE c,
    v_errmessage(100) TYPE c,
    gd_spool_nr type RSPOID,
    gd_bytecount type i,
    v_text(70) TYPE c.
    types ty_pdf type tline.
    data it_pdf_output type standard table of ty_pdf.
    data i_pdf like line of it_pdf_output.
    gd_spool_nr = sy-spono.
    SELECT matnr FROM mara INTO TABLE i_mara.
    CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
    EXPORTING
    dest = 'LP01'
    LIFETIME = '8'
    IMPORTING
    handle = v_handle
    spoolid = gd_spool_nr
    rc = v_rc
    errmessage = v_errmessage.
    LOOP AT i_mara into itab.
    v_text = itab-matnr.
    CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
    EXPORTING
    handle = v_handle
    text = v_text
    IMPORTING
    rc = v_rc
    errmessage = v_errmessage
    EXCEPTIONS
    handle_not_valid = 1
    OTHERS = 2.
    ENDLOOP.
    CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'
    EXPORTING
    handle = v_handle
    IMPORTING
    rc = v_rc
    errmessage = v_errmessage
    EXCEPTIONS
    handle_not_valid = 1
    OTHERS = 2.
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = gd_spool_nr
    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.
    LOOP AT it_pdf_output INTO i_pdf .
    TRANSLATE i_pdf USING ' ~'.
    CONCATENATE OUTPUT i_pdf INTO OUTPUT IN CHARACTER MODE.
    ENDLOOP.
    TRANSLATE OUTPUT USING '~ ' .
      app_type   = 'APPLICATION/PDF;'.
        CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text     = output
          mimetype = 'APPLICATION/PDF;'
        IMPORTING
          buffer   = l_xstring.
    CONCATENATE cl_abap_char_utilities=>byte_order_mark_little
                  l_xstring
             INTO l_xstring IN BYTE MODE.
      CONCATENATE 'attachment; filename=NIM2_matter_Summary_'
                  sy-uzeit
                  '.pdf'
             INTO l_content.
      CALL METHOD cl_bsp_utility=>download
        EXPORTING
          object_s            = l_xstring
          content_type        = app_type
          content_disposition = l_content
          response            = _m_response
          navigation          = _m_navigation
    Edited by: SandeepReddy on Jun 9, 2010 10:30 AM

  • Export Internal Table To E-Mail via attachted html or PDF file

    i have an ALV display report for which the data is in the internal table.
    Can anybody tell me how can i attach the simple  internal table as an attachment to the mail ...
    give me example  code if possible
    Maximum points will be given
    thanks in advance.

    here is the sample code but this code gives you two attachemetns as .xls files you try analyse and try it for PDF
    you have to change in the packed_list parameter that is passed to the FM.
    REPORT ZDOC_AS_EMAIL_3.
    *& Report ZEMAIL_ATTACH *
    *& Example of sending external email via SAPCONNECT *
    TABLES: ekko.
    PARAMETERS: p_email TYPE somlreci1-receiver.
    TYPES: BEGIN OF t_ekpo,
    ebeln TYPE ekpo-ebeln,
    ebelp TYPE ekpo-ebelp,
    aedat TYPE ekpo-aedat,
    matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
    wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
    ebeln(10) TYPE c,
    ebelp(5) TYPE c,
    aedat(8) TYPE c,
    matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
    WITH HEADER LINE.
    DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
    WITH HEADER LINE.
    DATA: l_t_objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    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,
    gd_error TYPE sy-subrc,
    gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
    *Retrieve sample data from table ekpo
    PERFORM data_retrieval.
    *Populate table with detaisl to be entered into .xls file
    PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    *Populate message body text
    perform populate_email_message_body.
    *Send file by email as .xls speadsheet
    PERFORM send_file_as_email_attachment
                        tables it_message
                                it_attach
                            using p_email
        'Example . xls documnet attachment'
                                     'XLS'
                                'filename'
                        changing gd_error
                              gd_reciever.
    *Instructs mail send program for SAPCONNECT to send email(rsconn01)
    PERFORM initiate_mail_execute_program.
    *& Form DATA_RETRIEVAL
    *Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
    SELECT ebeln ebelp aedat matnr
    UP TO 10 ROWS
    FROM ekpo
    INTO TABLE it_ekpo.
    ENDFORM. " DATA_RETRIEVAL
    *& Form BUILD_XLS_DATA_TABLE
    *Build data table for .xls document
    FORM build_xls_data_table.
    *CONSTANTS: con_cret(2) TYPE c VALUE '0D', "OK for non Unicode
    *con_tab(2) TYPE c VALUE '09'. "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    class cl_abap_char_utilities definition load.
    constants:
    con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
    con_cret type c value cl_abap_char_utilities=>CR_LF.
    CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
    INTO it_attach SEPARATED BY con_tab.
    CONCATENATE con_cret it_attach INTO it_attach.
    APPEND it_attach.
    LOOP AT it_ekpo INTO wa_charekpo.
    CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
    wa_charekpo-aedat wa_charekpo-matnr
    INTO it_attach SEPARATED BY con_tab.
    CONCATENATE con_cret it_attach INTO it_attach.
    APPEND it_attach.
    ENDLOOP.
    ENDFORM. " BUILD_XLS_DATA_TABLE
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    *Send email
    FORM send_file_as_email_attachment tables pit_message
                                              pit_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.
    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 = 'REPORT'.
    w_doc_data-obj_descr = ld_mtitle . "mail description
    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[] = pit_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 1st attachment notification
    t_packing_list-transf_bin = 'X'.
    t_packing_list-head_start = 0.
    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.
    **Create 1st attachment notification
    *t_packing_list-transf_bin = 'X'.
    *t_packing_list-head_start = 0.
    *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.
    **Create 2nd attachment notification
    data: x type i.
    DESCRIBE TABLE t_attachment LINES X.
    append lines of it_attach to t_attachment.
    data: start type i,
          end type i,
          cal type i.
    start = X + 1.
    describe table t_attachment lines end.
    cal = end - start.
    t_packing_list-transf_bin = 'X'.
    t_packing_list-head_start = 0.
    t_packing_list-head_num = 1.
    t_packing_list-body_start = start.
    t_packing_list-body_num = end.
    *DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
    t_packing_list-obj_descr = 'Eng Change'. "ld_attdescription.
    t_packing_list-doc_type = ld_format.
    *t_packing_list-obj_name = 'Eng' .
    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
    object_header = l_t_objhead
    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.
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    *Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
    WAIT UP TO 2 SECONDS.
    SUBMIT rsconn01 " WITH mode = 'INT'
    "WITH output = 'X'
    AND RETURN.
    ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
    *& Form POPULATE_EMAIL_MESSAGE_BODY
    *Populate message body text
    form populate_email_message_body.
    REFRESH it_message.
    it_message = 'Please find attached a list test ekpo records'.
    APPEND it_message.
    endform. " POPULATE_EMAIL_MESSAGE_BODY
    Edited by: S@N on Jun 13, 2008 2:06 PM

  • How to convert an internal table to a PDF

    Hello Experts,
    Is there a way that an internal table can be converted into a PDF file?
    The itab is:
    data: i_data(100) type c occurs 0 with header line.
    Thanks.

    Hai,
    first convert ur internal table data to  OTF.by usinf thid Function Module
    data: t_otf LIKE itcoo OCCURS 100 WITH HEADER LINE,
    t_pdf LIKE tline OCCURS 100 WITH HEADER LINE*.
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
       format                      = 'PDF'
      MAX_LINEWIDTH               = 132
      ARCHIVE_INDEX               = ' '
      COPYNUMBER                  = 0
      ASCII_BIDI_VIS2LOG          = ' '
      PDF_DELETE_OTFTAB           = ' '
    IMPORTING
       BIN_FILESIZE                = w_size
      BIN_FILE                    =
      TABLES
        otf                         = t_otf
        lines                       = t_pdf
    EXCEPTIONS
       ERR_MAX_LINEWIDTH           = 1
       ERR_FORMAT                  = 2
       ERR_CONV_NOT_POSSIBLE       = 3
       ERR_BAD_OTF                 = 4
       OTHERS                      = 5
      IF sy-subrc <> 0.
       RAISE error.  " oops
      ENDIF.
    and then use gui_download  function module.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       BIN_FILESIZE                  =  w_size
        filename                      =  'C:\Documents and Settings\adc\Desktop\pdf123.pdf'
       FILETYPE                      = 'BIN'
      APPEND                        = ' '
      WRITE_FIELD_SEPARATOR         = 'X'
      HEADER                        = '00'
      TRUNC_TRAILING_BLANKS         = ' '
      WRITE_LF                      = 'X'
      COL_SELECT                    = 'X'
      COL_SELECT_MASK               = 'XX X XX'
      DAT_MODE                      = ' '
      CONFIRM_OVERWRITE             = ' '
      NO_AUTH_CHECK                 = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      WRITE_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      tables
        data_tab                      =   t_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
       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.
    reward if helpful
    raam

  • Conversion of PDF file data  into ABAP internal table

    Hi all,
    I am unable to convert the binary data into text format by using some function modules and classes .please find tthe function modules names and classes:
    SCMS_BINARY_TO_TEXT,SCMS_BIN_TO_TEXT, CL_ABAP_CONV_IN_CE,CL_ABAP_CONV_OBJ. But these are not working as per my requirement.
    My requirement is we need to upload PDF file (legecy file)which is saved under the PC into SAP and display the same PDF data into the adobe interactive form. For thise i have done coding by using above function modules and classes but i got the unwant on the adobe form i.e display lke "##############$$%%^^&&*((((()))%%%%%%###*^^&&***"
    Thanks,
    Ramana

    I don't understand, the pdf is put into an internal table at
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF
    the table is pdf and all info for the pdf is there already in a table?
    if you continue the source code the only thing is that the table is combined with a file name and makes it happen that you get an actual file.
    or do you want to have the pdf in a single field ?
    or do you want to store the document on a server where the location is stored in an internal table ??
    kind regards
    arthur de smidt

Maybe you are looking for