Spool to Html

Dear all,
I have the following issue.
Correct situation:
- Run a report that generates a ALV or list
- Export the ALV into a HTML file
- The generated HTML file as the correct information
Incorrect situation
- Run a report that generates a ALV or list in background
- Export the spool into a HTML file
- The generated HTML is totally incorrect with collumns missing and other being repeated several times
Can anyone help me on this?
Thank you
Nuno Silva

Hi,
Check this link how to convert HTML from Spool
Spool to HTML Function Module
[Spool to Html|https://www.sdn.sap.com/irj/scn/advancedsearch?query=spooltoHtml&cat=sdn_all]
Edited by: Avinash Kodarapu on Mar 2, 2009 11:03 PM

Similar Messages

  • Email SPOOL as HTML ..

    Hi !!
       We are planning to schedule certain reports in background and then want to read its spool and convert those spool to HTML and send it as aattachment to email .
    I check the forum and the library there are example of submitting report to abap memorya nd then creating html from that memory and email it . But for this i will end up having two programs one the original report program and another program to submit it .I want to avoid taht situation.
    Please mail back with code sasmples .

    check these threads
    print spool to html
    Re: how to send the spool content as a body to email id (ans by max)

  • Error in converting Spool to HTML format.

    Hi Gurus,
    I am reading SPool and converting that into HTML formt. Please do find below code for the same.
    Submit report to convert the spool to HTML format
      SUBMIT rspolst2 EXPORTING LIST TO MEMORY AND RETURN
      WITH rqident = p_spoolno.
      CALL FUNCTION 'LIST_FROM_MEMORY'
        TABLES
          listobject = gt_listobj
        EXCEPTIONS
          not_found  = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Convert the spool to HTML format
      CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
       EXPORTING
       REPORT_NAME         =
         template_name       = 'WEBREPORTING_REPORT'
        TABLES
          html                = p_html_tab
          listobject          = gt_listobj.
    >>>>>>>>>>>>>>>>>>>
    And i send p_html_tab as attachement to email.
    When I opened the attachement, i can view only half page in htm.
    How can i get the full page in htm.

    First convert the spool to internal table by using FM
    RSPO_RETURN_ABAP_SPOOLJOB
    Next from internal table to HTML....
    Link: /people/rammanohar.tiwari/blog/2006/01/29/abap-utility-print-screen-to-html
    or try the following
    Please try the follwoing:
    1. define HTML internal table with ref to type W3HTML
    2. download it as BIN type and give total lenght of the strings as a parameter in the down load.
    See the code extract below:
    describe table html lines entries.
    read table html into w_html index entries.
    size = ( entries - 1 ) * 255 + strlen( w_html ).
    concatenate p_path file into file.
    call function 'WS_DOWNLOAD'
    exporting
    bin_filesize = size
    filename = file
    filetype = 'BIN'
    tables
    data_tab = html

  • Spool to HTML Function Module

    Hi Experts,
                Can anyone help me please.  Is there any FM that can convert spool to HTML?  Just like converting spool to PDF but only I need it in HTML.  I can't use spool to PDF because I'm having problems when it comes to massive pages, but if it's only 5 pages it actually works but not with 100 pages or more.  So please, if anyone can help me with spool to html.  Points will be given and also to those who tried.  Thanks.
    Anna

    Hi again.  Thanks for your reply.  But I'm actually having a problem with the list variable.  My dilemma actually is how I can transfer the jtab grabphical spool to the abaplist.  Please, please help me and  check what went wrong.  I'm actually trying to download the graphical spool to an html format.  Thanks.
    TABLES: TBTCO, TBTCP, TSP01.
    TYPE-POOLS: truxs.
    DATA: BEGIN OF itab OCCURS 0,
            sp_name TYPE tbtco-jobname,
            br_code(1),
            dumon(7),
            sp_numb TYPE TSP01-rqident,
            ofc(7),
          END OF itab.
    DATA: BEGIN OF btab OCCURS 5,
            fld1(24),
            fld2(12),
          END OF btab.
    DATA: htmllines TYPE TABLE OF w3html WITH HEADER LINE,
               w_jtab TYPE TABLE OF ABAPLIST WITH HEADER LINE.
    DATA: BEGIN OF jtab OCCURS 0,
            fld1(11),
            fld2(41),
            fld3(21),
            fld4(11),
            fld5(10),
            fld6(22),
            fld7(72),
          END OF jtab.
    INITIALIZATION.
    START-OF-SELECTION.
      PERFORM download_html.
    *&      Form  download_html
          text
    FORM download_html.
      DATA: lv_file   TYPE string,
            lv_string TYPE string,
            lt_conv   TYPE truxs_t_text_data.
      SORT itab BY sp_name br_code dumon.
      LOOP AT itab.
        CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
          EXPORTING
            rqident = itab-sp_numb "Spool Number
          TABLES
            BUFFER  = btab.
        LOOP AT btab WHERE fld1 = 'BROKER REPORT ID'.
          PERFORM get_month.
          MOVE: btab-fld2+4(1) TO itab-br_code,
                date TO itab-dumon.
          MODIFY itab.
        ENDLOOP.
        Move to jtab for Conversion HTML
          CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
            EXPORTING
              rqident = itab-sp_numb "Spool Number
            TABLES
              BUFFER  = jtab.
    ****SPOOL TO HTML
        CALL FUNCTION 'SAVE_LIST'
          TABLES
                listobject         = jtab
          EXCEPTIONS
                list_index_invalid = 1
                others             = 2.
        CALL FUNCTION 'WWW_LIST_TO_HTML'
         TABLES
           html = htmllines.
        AT NEW sp_name.
          CONCATENATE: p_file itab-sp_name '\' INTO p_file.
        ENDAT.
        AT NEW br_code.
          PERFORM get_brcode.
          CONCATENATE: p_file brc '\' INTO p_file.
        ENDAT.
        AT NEW dumon.
          CONCATENATE: p_file itab-dumon '\' INTO p_file.
        ENDAT.
        CONCATENATE: p_file itab-ofc '.HTML' INTO p_file.
        IF sy-subrc = 0.
          IF p_pres EQ 'X'.
            MOVE p_file TO lv_file.
            CALL FUNCTION 'GUI_DOWNLOAD'
              EXPORTING
                filename = lv_file
                filetype = 'BIN'
              TABLES
                data_tab = it_pdf_output.
            IF sy-subrc <> 0.
              MESSAGE e398(00) WITH 'Error creating file' p_file.
            ELSE.
              MESSAGE i398(00) WITH 'File Created' p_file.
            ENDIF.
          ELSE.
            APPEND LINES OF it_pdf_output TO lt_conv.
            IF lt_conv[] IS NOT INITIAL.
              OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
              IF sy-subrc EQ 0.
                LOOP AT lt_conv INTO lv_string.
                  TRANSFER lv_string TO p_file.
                ENDLOOP.
                CLOSE DATASET p_file.
                IF sy-subrc EQ 0.
                  MESSAGE i398(00) WITH 'File Created' p_file.
                ELSE.
                  MESSAGE e398(00) WITH 'Error closing file' p_file.
                ENDIF.
              ELSE.
                MESSAGE e398(00) WITH 'Error creating file' p_file.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "convert_spool_to_pdf
    Edited by: Anna Bechayda on Apr 23, 2008 10:18 AM

  • Print spool to html

    Hi!
    Would it be possible to convert print spool to html file in ABAP?
    Need your help.
    Thanks,
    Cherrie

    Hi,
    I think that it's possible anyway.
    Use dialog module source 'DISPLAY_OTF' and modify it. The dialog module(SE35) displays the OTF data of a form in abap list format. When you transfer the sapscript form to abap list, use the following functions.
      call function 'SAVE_LIST'
          EXPORTING
               LIST_INDEX = SY-LSIND
           TABLES
                LISTOBJECT = ZABAPLIST
           EXCEPTIONS
                others     = 9.
      call function 'WWW_HTML_FROM_LISTOBJECT'
           TABLES
                HTML       = ZW3HTML
                LISTOBJECT = ZABAPLIST
           EXCEPTIONS
                others     = 9.
      call function 'GUI_DOWNLOAD'
           EXPORTING
                FILENAME = 'C:\myhtml.html'
           TABLES
                DATA_TAB = ZW3HTML
           EXCEPTIONS
                OTHERS   = 9.
    Regards,
    Svetlin

  • FM for conversion of graphical display of spool to html

    Hi abapers,
              Please help.  This is the scenario, what I need is to convert the graphical display of spool to html.  The html output has to be the same with the graphical display of the spool with all the colors, fonts etc without using the shortcut in the system menu.  Please, please, help.  I need to know how.  It's really, really urgent.  Points will be given to the person who can help me.  Thanks.

    Hi,
    First convert the spool to internal table by using FM
    RSPO_RETURN_ABAP_SPOOLJOB
    Next from internal table to HTML....
    Link: /people/rammanohar.tiwari/blog/2006/01/29/abap-utility-print-screen-to-html
    or try the following
    Please try the follwoing:
    1. define HTML internal table with ref to type W3HTML
    2. download it as BIN type and give total lenght of the strings as a parameter in the down load.
    See the code extract below:
    describe table html lines entries.
    read table html into w_html index entries.
    size = ( entries - 1 ) * 255 + strlen( w_html ).
    concatenate p_path file into file.
    call function 'WS_DOWNLOAD'
    exporting
    bin_filesize = size
    filename = file
    filetype = 'BIN'
    tables
    data_tab = html
    Regards,
    Raj.

  • Spooling an HTML file

    Hi,
    I've got two scripts that spool two lists of data in html format.
    --- First sql ---
    set pagesize 1000
    set scan off
    set feedback off
    set markup html on spool on head ' - ' BODY 'bgcolor="WHITE" text="BLUE"' -
    SPOOL report_1.html
    SELECT *
    from TABLE_1;
    spool off;
    exit;
    --- Second sql ---
    set pagesize 1000
    set scan off
    set feedback off
    set markup html on spool on head ' - ' BODY 'bgcolor="SILVER" text="BLACK"' -
    SPOOL report_2.html
    SELECT *
    from TABLE_2;
    spool off;
    exit;
    As you can see the background and text colors of the two scripts are different (white/blue and silver/black) but if I try to concat the two html by using the CAT function on UNIX Server where Oracle is installed (cat report_1.html report_2.html > report.html), I get a new html file where the two spools have got the colors of the first spool that is white/blue I'd like to get a new script whit the two lists of data in different colors.
    Can you help me?
    Thanks!
    Edited by: Mark1970 on 23-mar-2010 2.04
    Edited by: Mark1970 on 23-mar-2010 2.05

    Thanks everyone, wonderful.
    if i want to clear all set commands which i had executed in this session , what should i do?
    i dont want to do a verify on feedback on etc.. ( i may not be knowing what all such commands i had executed previously , moreover i would have done cl scr in sql )

  • How to covert Spool to HTML and then send it via email

    Hi
    I have a report that runs in the background and then converts the ALV report to PDF and emails it as attachment. I need it to convert in HTML instead of PDF.
    Here is my code...
    *  CALL_ALV
    form call_alv.
      perform build_field_catalog using field_tab[].
      perform build_eventtab      using events[].
      perform comment_build       using header_alv[].
      perform build_sorttab       using gt_sort[].
      perform build_layout.
    * Call ABAP List Viewer
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = v_repid
          i_callback_user_command = 'ALV_USER_COMMAND'
          i_structure_name        = 'REC'
          it_fieldcat             = field_tab[]
          it_special_groups       = gt_sp_group[]
          it_sort                 = gt_sort[]
          i_save                  = v_save
          is_variant              = v_variant
          it_events               = events[]
          is_layout               = gd_layout
        tables
          t_outtab                 = REC
        exceptions
          program_error            = 1
          others                   = 2.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
        PERFORM convert_spool_to_pdf.   
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
      IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
    endform.                    "call_alv
    *       FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
    *       FORM get_job_details                                          *
    FORM get_job_details.
    * Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
    *       FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    * Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
    *       FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    *  perform send_email using p_email2.
    ENDFORM.
    *       FORM send_email                                               *
    *  -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    * Default subject matter
      gd_subject         = p_Sub.
      gd_attachment_desc = p_attNm.
    *  CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
    *  it_mess_bod        = 'Message Body text, line 1'.
      it_mess_bod        = P_line1.
      APPEND it_mess_bod.
    *  it_mess_bod        = 'Message Body text, line 2...'.
      it_mess_bod        = P_line2.
      APPEND it_mess_bod.
    * If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    * Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          gd_subject
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
    *       FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    * Fill the document data.
      w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    * Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    * Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    * Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    * Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    * Populate zerror return code
      ld_error = sy-subrc.
    * Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    Please tell me what's the code for convert_spool_to_HTML. and do i need to do anything on the PERFORM process_email. ..
    I always reward points. Thanks

    I think that if you can get the list back from the spool in regular format, you can then use the WWW_HTML_FROM_LISTOBJECT function module  to convert to HTML.   HEre is a sample program where I am submitting the program and getting the list back from memory. 
    * This program works in the background,
    report zrich_0003 .
    data: maildata like sodocchgi1.
    data: mailtxt like solisti1 occurs 10 with header line.
    data: mailrec like somlrec90 occurs 0 with header line.
    data: list type table of abaplist with header line.
    data: ascilines(1024) type c occurs 0 with header line.
    data: htmllines type table of w3html with header line.
    parameters: p_check.
    start-of-selection.
      submit zrich_0004 exporting list to memory and return.
      call function 'LIST_FROM_MEMORY'
           tables
                listobject = list
           exceptions
                not_found  = 1
                others     = 2.
      call function 'LIST_TO_ASCI'
           tables
                listobject         = list
                listasci           = ascilines
           exceptions
                empty_list         = 1
                list_index_invalid = 2
                others             = 3.
      call function 'WWW_HTML_FROM_LISTOBJECT'
           tables
                html       = htmllines
                listobject = list.
      clear: maildata, mailtxt, mailrec.
      refresh: mailtxt, mailrec.
      maildata-obj_name = 'TEST'.
      maildata-obj_descr = 'Test Subject'.
      loop at htmllines.
        mailtxt = htmllines.
        append mailtxt.
      endloop.
      mailrec-receiver = '[email protected]'.
      mailrec-rec_type = 'U'.
      append mailrec.
      call function 'SO_NEW_DOCUMENT_SEND_API1'
           exporting
                document_data              = maildata
                document_type              = 'HTM'
                put_in_outbox              = 'X'
           tables
                object_header              = mailtxt
                object_content             = mailtxt
                receivers                  = mailrec
           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.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
      commit work.
      wait up to 2 seconds.
      submit rsconn01 with mode = 'INT'
                   with output = 'X'
                              and return.
    So this works fine, but you have one more step, you need to get the LISTOBJECT from SPOOL.  See if you can do it using the functino module RSPO_RETURN_ABAP_SPOOLJOB or RSPO_RETURN_ABAP_SPOOLJOB_RAW.
    REgards,
    RIch Heilman

  • Need to send my spool in HTML format as Email attachment

    Hi All,
        Can anyone let me know how to send a HTML attachment in a mail.
    I have a ALV Report, when i execute, my report should pick the ALV Report output from spool, and should send a mail with spool output as HTML attachment.
    Please explain me how i need to do the above.
    Regards
    Nanda

    Hi Nanda,
    You can use 2 reports for this.
    In one report just display the ALV..
    and in the second report submit this first report  to memory and get it html format and then send it as an email.
    Just check this code (instead of alv...this is a normal report that is sent as HTML attachment)
    *--Tables
    TABLES: VBRK.
                     TYPES DECLARATION                                   *
    TYPES: BEGIN OF TY_VBRK,
            KUNAG TYPE KUNAG," Payer Id
           END OF TY_VBRK,
    *-- customer details
           BEGIN OF TY_KNA1,
            KUNNR TYPE KUNNR," Customer Id
            NAME1 TYPE NAME1," Customer Name
            ADRNR TYPE ADRNR," Address No
           END OF TY_KNA1,
    *-- Mailing details
           BEGIN OF TY_ADDR,
            ADDRNUMBER TYPE AD_ADDRNUM, " Address No
            MAIL_ID TYPE AD_SMTPADR,    " Email Address
           END OF TY_ADDR,
    *-- Log details
           BEGIN OF TY_MSG,
            STR1 TYPE AD_SMTPADR, " Email Address
            STR2 TYPE KUNNR,      " Payer Id
            STR3 TYPE NAME1,      " Payer Name
            STR4 TYPE D,          " Date
            STR5 TYPE T,          " Time
           END OF TY_MSG.
                 I N T E R N A L  T A B L E S                            *
    DATA: RECEPIENTS TYPE TABLE OF AD_SMTPADR, "table for email id's
          LISTOBJECT TYPE TABLE OF ABAPLIST,   "table with displayed list
          HTML TYPE TABLE OF W3HTML,           "html container
          RETURN TYPE TABLE_OF_STRINGS,        "message table
          IT_VBRK TYPE TABLE OF TY_VBRK,       "Billing Details
          IT_KNA1 TYPE TABLE OF TY_KNA1,       "Customer Details
          IT_ADDR TYPE TABLE OF TY_ADDR,       "Mail id
          IT_MSG TYPE TABLE OF TY_MSG.         "Log Details
    *-- Structure Declarations
    DATA: WA_REC TYPE AD_SMTPADR,
          WA_KNA1 TYPE TY_KNA1,
          WA_ADDR TYPE TY_ADDR,
          WA_MSG TYPE TY_MSG.
          Declarations for Sending mail                                  *
    *-- To Create link and add recepients address
    DATA: SEND_REQUEST TYPE REF TO CL_BCS.
    *-- To Create HTML document
    DATA: DOCUMENT TYPE REF TO CL_DOCUMENT_BCS.
    *-- To Create Sender Id
    DATA: SENDER_ID TYPE REF TO IF_SENDER_BCS.
    *-- To Create recepient address
    DATA: RECIPIENT TYPE REF TO IF_RECIPIENT_BCS.
    *-- To Handle Exceptions
    DATA: BCS_EXCEPTION TYPE REF TO CX_BCS.
    *-- To check if the mail is sent to all recepients
    DATA: SENT_TO_ALL TYPE OS_BOOLEAN.
    DATA: CONLENGTHS TYPE SO_OBJ_LEN . "To calculate length of the HTML file
                  V A R I A B L E S                                      *
    DATA: REPORT TYPE PROGRAMM,    "Report name
          SENDER TYPE AD_SMTPADR,  "Sender Address
          SUBJECT TYPE SO_OBJ_DES. "Subject
    DATA: BCS_MESSAGE TYPE STRING ."String to store exceptions
    DATA: V_KUNAG TYPE KUNAG.      "Payer Id
    DATA: V_MAIL TYPE AD_SMTPADR,  "Mail Address
          V_DATE TYPE ZZBCDATE.    "To Validate Entered Date
                 S E L C T I O N - S C R E E N                           *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_ZZBCDA FOR VBRK-ZZBCDAT. "Billing Complete Date
    PARAMETERS:     P_MAILFT TYPE AD_SMTPADR,  "Mail id
                    P_MAILSC TYPE AD_SMTPADR.  "Mail id
    SELECTION-SCREEN END OF BLOCK B1.
                      At Selection Screen                                *
    AT SELECTION-SCREEN.
    *-- Validate the dates entered
      SELECT ZZBCDAT UP TO 1 ROWS
              FROM VBRK
              INTO V_DATE
              WHERE ZZBCDAT IN S_ZZBCDA.
      ENDSELECT.
      IF SY-SUBRC <> 0.
        MESSAGE E002 WITH 'Dates Not Found In The Given Range'(002).
      ENDIF.
                 S T A R T - O F - S E L E C T I O N                     *
      CONCATENATE SY-UNAME '@YAHOO.COM'(003) INTO SENDER.
    *-- Populating the Subject Line
      MOVE 'Invoice Due Date Details'(004) TO SUBJECT.
    *-- Selecting the Payer Details Based on Input Dates
      SELECT KUNAG
              FROM VBRK
              INTO TABLE IT_VBRK
                   WHERE ZZBCDAT IN S_ZZBCDA.
    *-- Selecting the Address Number from Customer Master
      SELECT KUNNR
             NAME1
             ADRNR
              FROM KNA1
              INTO TABLE IT_KNA1
                   FOR ALL ENTRIES IN IT_VBRK
                   WHERE KUNNR = IT_VBRK-KUNAG.
    *-- Selecting the Mail Id's
      SELECT ADDRNUMBER
             SMTP_ADDR
              FROM ADR6
              INTO TABLE IT_ADDR
                   FOR ALL ENTRIES IN IT_KNA1
                   WHERE ADDRNUMBER = IT_KNA1-ADRNR.
    *-- Getting all the selected mail Id's
      RECEPIENTS = IT_ADDR[].
      MOVE (your first report name) TO REPORT.
      IF NOT RECEPIENTS[] IS INITIAL .
        LOOP AT IT_KNA1 INTO WA_KNA1.
          AT NEW KUNNR.
            READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_KNA1-KUNNR
                                                              BINARY SEARCH.
            REFRESH RECEPIENTS.
    *-- Populating the Recepients Mail Id's for the Particular Kunnr
            LOOP AT IT_ADDR INTO WA_ADDR WHERE ADDRNUMBER = WA_KNA1-ADRNR.
              IF NOT WA_ADDR IS INITIAL.
                TRANSLATE WA_ADDR-MAIL_ID TO UPPER CASE.
                APPEND WA_ADDR-MAIL_ID TO RECEPIENTS.
              ENDIF.
            ENDLOOP.
    *-- Appending the mail id's from the input fields when not initial
            IF NOT P_MAILFT IS INITIAL.
              TRANSLATE P_MAILFT TO UPPER CASE.
              APPEND P_MAILFT TO RECEPIENTS.
            ENDIF.
            IF NOT P_MAILSC IS INITIAL.
              TRANSLATE P_MAILSC TO UPPER CASE.
              APPEND P_MAILSC TO RECEPIENTS.
            ENDIF.
    *-- Sending the Kunnr while Submitting the Report
            V_KUNAG = WA_KNA1-KUNNR.
            TRANSLATE REPORT TO UPPER CASE .
    *--Submitting the Report Exporting the List to Memory
            SUBMIT (REPORT) WITH S_ZZBCDA IN S_ZZBCDA
                            WITH P_KUNAG = V_KUNAG
                             EXPORTING LIST TO MEMORY AND RETURN.
            CLEAR: LISTOBJECT , HTML .
            REFRESH : LISTOBJECT, HTML .
    *-- Calling the Fn Module to get the list from the Memory
            CALL FUNCTION 'LIST_FROM_MEMORY'
              TABLES
                LISTOBJECT = LISTOBJECT.
    *-- Calling Fn Module to get the List in HTML Format
            CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
              EXPORTING
                REPORT_NAME = REPORT
              TABLES
                HTML        = HTML
                LISTOBJECT  = LISTOBJECT.
    *-- Getting the Size of the Html Document
            DATA: V_LINES TYPE I.
            DESCRIBE TABLE HTML LINES V_LINES.
            CLEAR CONLENGTHS .
            CONLENGTHS = V_LINES * 255.
            TRY.
                CLEAR SEND_REQUEST .
                SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
                CLEAR DOCUMENT .
    *-- Creating the Document
                DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
                I_TYPE = 'HTM'
                I_TEXT = HTML
                I_LENGTH = CONLENGTHS
                I_SUBJECT = SUBJECT ).
    *-- add document to send request
                CALL METHOD SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
                CLEAR SENDER_ID .
    *-- Creating the internet address for the sender id.
          SENDER_ID = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( SENDER ).
                CALL METHOD SEND_REQUEST->SET_SENDER
                  EXPORTING
                    I_SENDER = SENDER_ID.
                CLEAR WA_REC .
    *-- Creating the Recepients address
                LOOP AT RECEPIENTS INTO WA_REC .
                  CLEAR RECIPIENT .
                  RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
                  WA_REC ).
    add recipient with its respective attributes to send request
                  CALL METHOD SEND_REQUEST->ADD_RECIPIENT
                    EXPORTING
                      I_RECIPIENT = RECIPIENT
                      I_EXPRESS   = 'X'.
                ENDLOOP .
                CALL METHOD SEND_REQUEST->SET_STATUS_ATTRIBUTES
                  EXPORTING
                    I_REQUESTED_STATUS = 'E'
                    I_STATUS_MAIL      = 'E'.
                CALL METHOD SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
    *-- Sending the Document
                CALL METHOD SEND_REQUEST->SEND(
                EXPORTING
                I_WITH_ERROR_SCREEN = 'X'
                RECEIVING
                RESULT = SENT_TO_ALL ).
                IF SENT_TO_ALL = 'X'.
    *-- Getting the details to display the Job Log
                  LOOP AT RECEPIENTS INTO V_MAIL.
                    WA_MSG-STR1 = V_MAIL.
                    WA_MSG-STR2 = WA_KNA1-KUNNR.
                    WA_MSG-STR3 = WA_KNA1-NAME1.
                    WA_MSG-STR4 = SY-DATUM.
                    WA_MSG-STR5 = SY-UZEIT.
                    APPEND WA_MSG TO IT_MSG.
                  ENDLOOP.
                ELSE.
                  APPEND 'Mail not sent'(005)  TO RETURN.
                ENDIF.
                COMMIT WORK.
              CATCH CX_BCS INTO BCS_EXCEPTION.
                BCS_MESSAGE = BCS_EXCEPTION->GET_TEXT( ).
                APPEND BCS_MESSAGE TO RETURN .
                EXIT.
            ENDTRY.
          ENDAT.
        ENDLOOP.
      ELSE .
        APPEND 'Specify email address for sending'(006) TO RETURN .
      ENDIF .
                     E N D - O F - S E L E C T I O N                     *
    END-OF-SELECTION.
    *-- Displaying the Job Log
      FORMAT COLOR 1 INTENSIFIED ON.
      WRITE:/        SY-ULINE(121),
                (40) 'Mail Sent to'(007),
                     SY-VLINE,
                (12) 'Payer Id'(008),
                     SY-VLINE,
                (35) 'Payer Name'(009),
                     SY-VLINE,
                (10) 'Sent Date'(010),
                     SY-VLINE,
                (10) 'Sent Time'(011),
                     SY-VLINE,
                     SY-ULINE(121).
      LOOP AT IT_MSG INTO WA_MSG.
        FORMAT COLOR 2 INTENSIFIED ON.
        WRITE:/         SY-ULINE(121),
                   (40) WA_MSG-STR1,
                        SY-VLINE,
                   (12) WA_MSG-STR2,
                        SY-VLINE,
                   (35) WA_MSG-STR3,
                        SY-VLINE,
                   (10) WA_MSG-STR4  DD/MM/YYYY,
                        SY-VLINE,
                   (10) WA_MSG-STR5  USING EDIT MASK '__:__:__',
                        SY-VLINE,
                        SY-ULINE(121).
      ENDLOOP.

  • Spool to HTML using an FM

    Hi Experts,
                  Please help me.  I need an HTML function module that will convert the graphical display of a spool into an HTML format.  Please help me how I can go about it step by step.  tHanks.

    Hello Anna
    Basically your report executed as batch job needs to exectue an external OS command (i.e. a FTP put or mput command).
    The details for executing the FTP command depend on your OS. For a customer whose SAP system was running on a Windows server the batch job created a small FTP script which was then executed by the external OS command (FTP command of Windows server) using fm SXPG_COMMAND_EXECUTE.
    Regards
      Uwe

  • Get HTML spool and save it as html on a server directory (in batch)

    Hi all,
    I wrote a program which permits to get a spool an send it per mail as attachment or save it as file in a directory.
    It musst be available to start the program in batch mode.
    I've no problem to get the spool (type HTML) and send it via mail with the HTML file as attachment.
    But by getting the spool and saving it in a directory insteed sending it via mail, I've a corrupted file. Does anybody know how to solve the problem ?
    I did following :
    get the spool :
    CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
         EXPORTING
           rqident              = iv_spool
         IMPORTING
           real_type            = lv_real_type
         TABLES
           buffer               = lt_soli
    * convert the file :
      lt_solix = cl_bcs_convert=>soli_to_solix( lt_soli ).
    *Transfert the file:
        OPEN DATASET lv_dataset FOR OUTPUT IN LEGACY BINARY MODE.
       LOOP AT lt_solix INTO ls_solix.
         TRANSFER ls_solix TO lv_dataset.
       ENDLOOP.
       CLOSE DATASET lv_dataset.
    Some other informations :
    - I do not want a spool in text mode (RAW). I want to get the HTML file.
    - I allready tried to do an open dataset in text mode -> didn't work.
    thank in advance for any advice.
    Fred

    i'm sorry, i'm pretty dumb and missed the change into solix table.
    try give a look here
    Spool to HTML Function Module
    ABAP Utility : Print-Screen to HTML

  • How to spool the output of mod pl/sql ?

    I am trying to generate a HTML (will be static after I generate) web page from Oracle PL/SQL package. Moment I execute the package/procedure call, it should generate a HTML file and we will be publishing the file over the web.
    create or replace procedure display_hello
    IS
    begin
    htp.htmlOpen;
    htp.print('Hello World');
    htp.htmlClose;
    end display_hello;
    If I execute the above procedure using PL/SQL Developer, I am able to see the output in the neat HTML fashion. I would like to spool the HTML file used to display that and store it in a file so that i can publish it.
    Any thoughts ?

    vaibhav468 wrote:
    Because we dont want to spoil the performance. Assume our data is not going to change frequently. Say its going to change only once in three days. I dont want people to query the data from the database each time when they open the page. I would like them to just use the static content which i have generated. But the moment the data in my tables are going to get changed, I would run a process and regenerate the page. Not a bad idea ?You can use page caching in mod_psql - have not used it myself, but recall discussions on comp.databases.oracle.server some years ago.
    APEX also sports a cache feature - this is also worthwhile investigating.
    What is a horrible idea though IMO, is to try and roll your own caching - but having PL/SQL code writing physical files to disk for the web server to serve up and at other times creating and streaming content dynamically from PL/SQL code.
    You also need to ask yourself about the actual benefits you will get from caching - and whether that is worthwhile the saving in resources.
    PL/SQL and SQL can be very fast.. with minimal overheads. And this is typically the code that you want to deploy for a web server (as web users expect fast response - a web page should be generated in around 2 secs). In which case it does not matter whether PL/SQL dynamically creates the web page or whether it is provided from a cache - where there is also the overheads of cache logic to consider.

  • Table structure and constraints in HTML table

    This script creates a html file (Structure.html) that contains structure of a specific table.
    When the following script is executed in sql * plus, it asks for the table name for which
    structure information is needed. after entering the table name, it writes the table structure
    into structure.html file.
    SET LINESIZE 150
    SET PAGESIZE 150
    SET FEEDBACK OFF
    SET VERIFY OFF
    COLUMN "COLUMN NAME" FORMAT A50
    COLUMN "DATA TYPE" FORMAT A15
    COLUMN "IS NULL" FORMAT A15
    COLUMN CONSTRAINTS FORMAT A15
    PROMPT Enter table name:
    ACCEPT TABNAME
    SET MARK HTML ON
    SPOOL STRUCTURE.html
    PROMPT &TABNAME
    -- Query ---
    SELECT TRIM(A.COLUMN_NAME) AS "COLUMN NAME",
    TRIM(DATA_TYPE||'('||DECODE(A.DATA_LENGTH,22,A.DATA_PRECISION||','||A.DATA_SCALE,
    A.DATA_LENGTH) || ')') AS "DATA TYPE",
    TRIM(DECODE(A.NULLABLE,'Y',' ','NOT NULL')) AS "IS NULL",
    TRIM(DECODE(C.CONSTRAINT_TYPE,'P','PRIMARY KEY','R','FOREIGN KEY('||D.TABLE_NAME||')','U','UNIQUE', 'C','CHECK')) AS CONSTRAINTS,
    TRIM(C.CONSTRAINT_NAME) AS "CONSTRAINT NAME",
    C.SEARCH_CONDITION AS "CHECK CONDITION",
    A.DATA_DEFAULT AS "DEFAULT VALUE"
    FROM USER_TAB_COLS A,
    USER_CONS_COLUMNS B,
    USER_CONSTRAINTS C,
    USER_CONS_COLUMNS D
    WHERE
    A.TABLE_NAME = '&TABNAME' AND
    A.TABLE_NAME = B.TABLE_NAME(+) AND
    A.COLUMN_NAME = B.COLUMN_NAME(+) AND
    B.CONSTRAINT_NAME = C.CONSTRAINT_NAME(+) AND
    C.R_CONSTRAINT_NAME = D.CONSTRAINT_NAME(+);
    SPOOL OFF
    SET MARK HTML OFF

    Hi,
    For Head Count you can use 0HR_PA_0 datasource and the other Employee details like start date and end date you can get them from employee master data and FTE can be calculated from the Emloyee Master Data and Head count data.
    Hope this helps...
    Thanks,

  • Tablespace usage report generated with html tags instead of text

    Hi ,
    We have a unix shell script scheduled to find tablespace usage and sends the report to our mail id.
    For the past few weeks(no changes idone in the script) the report is coming with html tags instead of text as below.
    </head>
    <body>
    <p>
    <table border='1' width='90%' align='center' summary='Script output'>
    <tr>
    <th scope="col">
    TABLESPACE_NAME
    </th>
    <th scope="col">
    CUR_USE_MB
    </th>
    <th scope="col">
    CUR_SZ_MB
    </th>
    <th scope="col">
    CUR_PRCT_FULL
    </th>
    <th scope="col">
    FREE_SPACE_MB
    </th>
    <th scope="col">
    MAX_SZ_MB
    </th>
    <th scope="col">
    OVERALL_PRCT_FULL
    </th>
    </tr>
    <tr>
    <td>
    SYSTEM
    </td>
    <td align="right">
    268
    </td>
    <td align="right">
    500
    </td>
    <td align="right">
    54
    </td>
    Is this any settings issue or anything to be modified in the script.Could you please reply..
    Regards,
    Bharath.
    Edited by: 870384 on Jul 6, 2011 1:17 AM

    Hi Sven W,
    Please find the sql below that is generating the tablespace usage report. In the staring of the script markup is set to ON and at the end it is set to OFF.Do you suggest any changes to this..?
    SET ECHO OFF
    SET PAGES 999
    SET MARKUP HTML ON SPOOL ON
    col tablespace_name format a15 trunc
    col cur_use_mb for 999999999
    col cur_sz_mb for 999999999
    col free_space_mb for 999999999
    col max_sz_mb for 999999999
    compute sum of cur_use_mb on report
    compute sum of cur_sz_mb on report
    compute sum of free_space_mb on report
    compute sum of max_sz_mb on report
    break on report
    spool tablespace.html
    select tablespace_name,
    round(sum(total_mb)-sum(free_mb),2) cur_use_mb,
    round(sum(total_mb),2) cur_sz_mb,
    round((sum(total_mb)-sum(free_mb))/sum(total_mb)*100) cur_prct_full,
    round(sum(max_mb) - (sum(total_mb)-sum(free_mb)),2) free_space_mb,
    round(sum(max_mb),2) max_sz_mb,
    round((sum(total_mb)-sum(free_mb))/sum(max_mb)*100) overall_prct_full
    from (select tablespace_name,sum(bytes)/1024/1024 free_mb,0 total_mb,0 max_mb from DBA_FREE_SPACE group by tablespace_name
    union select tablespace_name,0 current_mb,sum(bytes)/1024/1024 total_mb,sum(decode(maxbytes, 0, bytes, maxbytes))/1024/1024 max_mb
    from DBA_DATA_FILES group by tablespace_name) a group by tablespace_name;
    select owner,segment_name,segment_type,bytes/(1024*1024) size_m
    from dba_segments
    where tablespace_name = 'SYSTEM' and segment_name='FGA_LOG$' order by size_m desc;
    spool off;
    SET MARKUP HTML OFF SPOOL OFF

  • HTML File generating  -Problem

    Hi Guys,
    I would like to generate html file the below procedure . Any help would be appreciated . Please help me
    declare
    type empdtlrec is record (empno number(4),
    ename varchar2(20),
    deptno number(2));
    empdtl empdtlrec;
    begin
    execute immediate 'select empno, ename, deptno ' ||'from emp where empno=(select max(deptno) from emp)'
    into empdtl;
    dbms_output.put_line('empno ' || empdtl.empno );
    dbms_output.put_line('ename ' || empdtl.ename );
    dbms_output.put_line('deptno ' ||empdtl.deptno );
    end;
    Regards,
    Orabalu

    Hello Orabalu,
    To generate an html output you can try following sql (save it as emp.sql) and modify to your needs table and column name and run it thru sqlplus session. Hope this helps
    set echo off;
    SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON -
    HEAD "<TITLE>Employee Report</TITLE> -
    <STYLE type='text/css'> -
    <!-- BODY {background: #FFFFC6} --> -
    </STYLE>" -
    BODY "TEXT='#FF00Ff'" -
    TABLE "WIDTH='50%' BORDER='5'"
    COLUMN EMPID HEADING 'Employee ID' ENTMAP OFF
    COLUMN FNAME HEADING 'Employee Name'
    COLUMN LNAME HEADING 'Department No' ENTMAP OFF
    SPOOL report.html
    SELECT empno, ename, deptno
    FROM emp
    WHERE empno = (SELECT MAX (deptno)
                   FROM emp);
    SPOOL OFF;Regards
    Edited by: OrionNet on Jan 17, 2009 10:07 PM

Maybe you are looking for