How to convert report list to an excel

HI all,
i have a requriment that i want to convert list which has been displayed
into excel format
please help me

Kiron, hi
  If it is a classical ABAP list (i.e. constructed using the WRITE keyword) then once the list is displayed, use the system drop down menu, then the list sub-menu, then the save sub-menu, then select the option 'Local file'. You will have radiobutton options representing the file formats to save to, one of which is spreadsheet.
Good luck.

Similar Messages

  • Convert report from SAP to Excel

    Hi All,
    How to convert report from SAP to Excel.Here now taking default text(.txt) format.But we want defualt taking (.xls) format only.
    Regards
    Usha

    hi usha
    u can even export the text in txt format and later right click and open with excel , u wont be able to directly import it into excel as it is not giving u any option to upload in excel directly
    Regards,
    Manish

  • How to convert report into alvgrid please hepl

    how to convert report into alvgrid please hepl

    BALVSD01 check this program u will know r see below code
    sample prog
    REPORT  ZMAT11                                  .
    TYPE-POOLS : slis.
    TABLES : mkpf,
             mseg,
             t001w,
             t001l.
    TYPES : BEGIN OF ty_t001w,
              werks TYPE t001w-werks,
              name1 TYPE t001w-name1,
            END OF ty_t001w,
            BEGIN OF ty_makt,
              matnr TYPE makt-matnr,
              maktx TYPE makt-maktx,
            END OF ty_makt,
            BEGIN OF ty_t001l,
              lgort TYPE t001l-lgort,
              lgobe TYPE t001l-lgobe,
            END OF ty_t001l.
    DATA :  BEGIN OF it_mat OCCURS 0,
            mblnr LIKE mseg-mblnr,
            zeile LIKE mseg-zeile,
            mjahr LIKE mseg-mjahr,
            bldat LIKE mkpf-bldat,
            budat LIKE mkpf-budat,
            bwart LIKE mseg-bwart,
            matnr LIKE mseg-matnr,
            maktx LIKE makt-maktx,
            erfmg LIKE mseg-erfmg,
            erfme LIKE mseg-erfme,
            werks LIKE mseg-werks,
            name1 LIKE t001w-name1,
            lgort LIKE mseg-lgort,
            lgobe LIKE t001l-lgobe,
            umwrk LIKE mseg-umwrk,
            name2 LIKE t001w-name1,
            umlgo LIKE mseg-umlgo,
            lgobe1 LIKE t001l-lgobe,
            END OF it_mat.
    DATA : it_t001w TYPE TABLE OF ty_t001w
                     WITH HEADER LINE,
           it_makt TYPE TABLE OF ty_makt
                   WITH HEADER LINE,
           it_t001l TYPE TABLE OF ty_t001l
                    WITH HEADER LINE.
    DATA : ls_layout TYPE slis_layout_alv,
           it_fcat TYPE slis_t_fieldcat_alv ,
           wa_fcat TYPE slis_fieldcat_alv,
           lh TYPE slis_t_listheader,
           ls TYPE slis_listheader,
           it_events TYPE slis_t_event  ,
           ls_event TYPE slis_alv_event ,
           w_var TYPE i.
    DATA : l_date(10).
    DATA : l_date1(20),
           ztabix LIKE sy-tabix.
    DATA : l_repid LIKE trdir-name.
    l_repid = 'ZMAT11'.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_werks FOR mseg-werks,
                     s_lgort FOR mseg-lgort,
                     s_umwrk FOR mseg-umwrk,
                     s_umlgo FOR mseg-umlgo,
                     s_bwart FOR mseg-bwart,
                     s_budat FOR mkpf-budat,
                     s_mjahr FOR mkpf-mjahr.
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN.
      SELECT SINGLE * FROM t001w INTO t001w
                              WHERE werks IN s_werks.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Supplying Plant'.
      ENDIF.
      SELECT SINGLE * FROM t001w INTO t001w
                              WHERE werks IN s_umwrk.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Receiving Plant'.
      ENDIF.
      SELECT SINGLE * FROM t001l INTO t001l
                              WHERE lgort IN s_lgort.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Supplying St.Loc'.
      ENDIF.
      SELECT SINGLE * FROM t001l INTO t001l
                              WHERE lgort IN s_umlgo.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Receiving St.Loc'.
      ENDIF.
    START-OF-SELECTION.
      ls-typ = 'H'.
      ls-info = 'Material Document List'.
      APPEND ls TO lh.
      ls-typ = 'S'.
      WRITE: sy-datum TO l_date USING EDIT MASK '__/__/____'.
      CONCATENATE 'DATE :' l_date INTO l_date1 SEPARATED BY space.
      ls-info = l_date1.
      APPEND ls TO lh.
      PERFORM field_cat.
      PERFORM f001_get_data.
    END-OF-SELECTION.
      IF it_mat[] IS INITIAL.
        MESSAGE i000(8i) WITH 'No data Found'(m01).
        EXIT.
      ENDIF.
      PERFORM process_data.
      PERFORM display_data.
    *&      Form  f001_get_data
          text
    -->  p1        text
    <--  p2        text
    FORM f001_get_data .
      SELECT amblnr azeile amjahr abwart a~matnr
               aerfmg aerfme awerks algort aumwrk aumlgo
               b~budat
               b~bldat INTO CORRESPONDING FIELDS OF TABLE it_mat
                       FROM mseg AS a
                 INNER JOIN mkpf AS b
                    ON amblnr = bmblnr
                   AND amjahr = bmjahr
                 CLIENT SPECIFIED
              WHERE a~mandt EQ sy-mandt
                AND a~werks IN s_werks
                AND a~lgort IN s_lgort
                AND a~umwrk IN s_umwrk
                AND a~umlgo IN s_umlgo
                AND a~bwart IN s_bwart
                AND b~budat IN s_budat
                AND b~mjahr IN s_mjahr.
      IF sy-subrc = 0.
        SELECT matnr maktx INTO TABLE it_makt FROM makt
        CLIENT SPECIFIED
        FOR ALL ENTRIES IN it_mat
        WHERE mandt EQ sy-mandt
          AND matnr = it_mat-matnr.
      ENDIF.
      SELECT werks name1 INTO TABLE it_t001w FROM t001w
      CLIENT SPECIFIED
      WHERE mandt EQ sy-mandt.
      IF sy-subrc <> 0.
        MESSAGE i000(8i) WITH 'No Plant Found'(m02).
      ENDIF.
      SELECT lgort lgobe INTO TABLE it_t001l FROM t001l
      CLIENT SPECIFIED
      WHERE mandt EQ sy-mandt.
      IF sy-subrc <> 0.
        MESSAGE i000(8i) WITH 'No Storage Location Found'(m03).
      ENDIF.
    ENDFORM.                    " f001_get_data
    *&      Form  field_cat
          text
    -->  p1        text
    <--  p2        text
    FORM field_cat .
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'MBLNR'.
      wa_fcat-key = 'X'.
      wa_fcat-hotspot = 'X'.
      wa_fcat-ref_fieldname = 'MBLNR'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Material Doc'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'ZEILE'.
      wa_fcat-ref_fieldname = 'ZEILE'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Item No'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'MJAHR'.
      wa_fcat-ref_fieldname = 'MJAHR'.
      wa_fcat-ref_tabname = 'MSEG'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'BWART'.
      wa_fcat-ref_fieldname = 'BWART'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Mvmt Type'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'BLDAT'.
      wa_fcat-ref_fieldname = 'BLDAT'.
      wa_fcat-ref_tabname = 'MKPF'.
      wa_fcat-seltext_m = 'Document Date'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'BUDAT'.
      wa_fcat-ref_fieldname = 'BUDAT'.
      wa_fcat-ref_tabname = 'MKPF'.
      wa_fcat-seltext_m = 'Posting Date'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-ref_fieldname = 'MATNR'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Material No'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-ref_fieldname = 'MAKTX'.
      wa_fcat-ref_tabname = 'MAKT'.
      wa_fcat-seltext_m = 'Material Description'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'ERFMG'.
      wa_fcat-ref_fieldname = 'ERFMG'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Quantity'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'ERFME'.
      wa_fcat-ref_fieldname = 'ERFME'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Uom'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Supplying Plant'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'NAME1'.
      wa_fcat-seltext_m = 'S.Plnt Desc.'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'LGORT'.
      wa_fcat-seltext_m = 'Supplying St.Loc'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'LGOBE'.
      wa_fcat-seltext_m = 'Su.St.Loc Desc.'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'UMWRK'.
      wa_fcat-seltext_m = 'Receiving Plant'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'NAME2'.
      wa_fcat-seltext_m = 'R.Plnt Desc.'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'UMLGO'.
      wa_fcat-seltext_m = 'Receiving St.Loc'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'LGOBE1'.
      wa_fcat-seltext_m = 'Re.St.Loc Desc.'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
    ENDFORM.                    " field_cat
    *&      Form  process_data
          text
    -->  p1        text
    <--  p2        text
    FORM process_data .
      LOOP AT it_mat.
        ztabix = sy-tabix.
        READ TABLE it_makt WITH KEY matnr = it_mat-matnr.
        IF sy-subrc = 0.
          it_mat-maktx = it_makt-maktx.
        ENDIF.
        IF it_mat-bwart+2(1) = '2'.
          it_mat-erfmg = - ( it_mat-erfmg ).
        ENDIF.
        READ TABLE it_t001w WITH KEY werks = it_mat-werks.
        IF sy-subrc = 0.
          it_mat-name1 = it_t001w-name1.
        ENDIF.
        READ TABLE it_t001w WITH KEY werks = it_mat-umwrk.
        IF sy-subrc = 0.
          it_mat-name2 = it_t001w-name1.
        ENDIF.
        READ TABLE it_t001l WITH KEY lgort = it_mat-lgort.
        IF sy-subrc = 0.
          it_mat-lgobe = it_t001l-lgobe.
        ENDIF.
        READ TABLE it_t001l WITH KEY lgort = it_mat-umlgo.
        IF sy-subrc = 0.
          it_mat-lgobe1 = it_t001l-lgobe.
        ENDIF.
        MODIFY it_mat INDEX ztabix .
      ENDLOOP.
    ENDFORM.                    " process_data
    *&      Form  display_data
          text
    -->  p1        text
    <--  p2        text
    FORM display_data .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
              I_INTERFACE_CHECK                 = ' '
              I_BYPASSING_BUFFER                = ' '
              I_BUFFER_ACTIVE                   = ' '
               i_callback_program                = l_repid
              I_CALLBACK_PF_STATUS_SET          = ' '
               i_callback_user_command           = 'LINE'
               i_callback_top_of_page            = 'TOP'
              I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
              I_CALLBACK_HTML_END_OF_LIST       = ' '
              I_STRUCTURE_NAME                  =
              I_BACKGROUND_ID                   = ' '
              I_GRID_TITLE                      =
              I_GRID_SETTINGS                   =
              IS_LAYOUT                         =
               it_fieldcat                       = it_fcat
              IT_EXCLUDING                      =
              IT_SPECIAL_GROUPS                 =
              IT_SORT                           =
              IT_FILTER                         =
              IS_SEL_HIDE                       =
              I_DEFAULT                         = 'X'
              I_SAVE                            = ' '
              IS_VARIANT                        =
              it_events                         =
              IT_EVENT_EXIT                     =
              IS_PRINT                          =
              IS_REPREP_ID                      =
              I_SCREEN_START_COLUMN             = 0
              I_SCREEN_START_LINE               = 0
              I_SCREEN_END_COLUMN               = 0
              I_SCREEN_END_LINE                 = 0
              IT_ALV_GRAPHICS                   =
              IT_HYPERLINK                      =
              IT_ADD_FIELDCAT                   =
              IT_EXCEPT_QINFO                   =
              I_HTML_HEIGHT_TOP                 =
              I_HTML_HEIGHT_END                 =
            IMPORTING
              E_EXIT_CAUSED_BY_CALLER           =
              ES_EXIT_CAUSED_BY_USER            =
              TABLES
                t_outtab                          = it_mat
            EXCEPTIONS
              PROGRAM_ERROR                     = 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.
    ENDFORM.                    " display_data
    *&      Form  TOP
          text
    FORM top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = lh
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP

  • How to convert a csv file into excel report?

    Hello,
    I have a csv file, can any body help me how to convert it into an excel report.
    thanks in advance
    vakvarma

    Search this board for "read CVS" and "write Excel". both are very common questions, you should be able to find answers very quickly.
    Hints: String.split(), Apache POI

  • How to convert Report Builder output to .XLS

    Dear All,
    Let me please know how to convert the Report Builder output to Excel Format.
    As there are having the facility to convert the output in .PDF or .HTML format but i want to convert that into Excel Sheet......
    Please Guide me in this regards
    Thanks in advance
    Regards,
    Vishal......

    What version of reports are you running?
    If it's Reports 10g then have you looked at the help under the topic "About spreadsheet output"?

  • How to convert a list of string of time (HH:MM:SS)to a numeric list for plotting

    my question is: How to transform a list of characters of values of time that have format HH:MMS to a list or adjustment of numerical values, to be able to use them in a code of LabVIEW?
    The numeric data are going to be used to plot them in a graph XY and to manipulate them.

    If it's 24-hour format than a Scan From String function with %d:%d:%d as the format string will give you hours, minutes, seconds as numerics. You could then convert to seconds as shown in the attachment.
    Attachments:
    time_string_to_seconds.jpg ‏9 KB

  • AcrobatX1 Trial How to Convert part of PDF to Excel

    I was trying to convert part of a PDF to Excel sheet so I downloaded Acrobat x1,but found out to my wasted time that the trial version will not do so! I contacted Microsoft support & spoke to a lady and she tried to help but assured me that it will not do this.
    Today I get an advertisement from Adobe's Project Manager showing me just how to convert to Excel!,yet when I try again the trial version still will not convert part of my PDF to Excel!
    Has anyone got any advise how I can convert part of this PDF to Excel?
    Thanks for your help

    If you only want to convert certain pages, use Extract Pages to make a new document containing only the pages you want. Then Save As Excel. Don't expect miracles, Acrobat has to use guesswork to estimate where your grid is.

  • How to convert internal table data into excel format?

    Hi all,
    I want to convert internal table data in excel format and then
    send it as email attachment in workflow.
    Please tell me how do i perform this.
    Regards,
    Arpita.

    Hi Arpita,
    Try this sample code::
    Send mail
    maildata-obj_name = 'TEST'.
    maildata-obj_descr = 'Test Subject'.
    loop at htmllines.
    mailtxt = htmllines.
    append mailtxt.
    endloop.
    mailrec-receiver = 'your receiver mail id'.
    mailrec-rec_type = 'U'.
    append mailrec.
    call function 'SO_NEW_DOCUMENT_SEND_API1'
    exporting
    document_data = maildata
    document_type = 'EXL'
    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.
    Hope it will help you.
    Regards,
    NIkita

  • How to convert report to PDF format

    Hi,
    Please let me know the procedure to convert reports into PDF format.
    Thanks in Advance
    Irfan Hussain

    Refer these links
    http://www.sap-img.com/bc037.htm
    http://www.members.tripod.com/abap4/Save_Report_Output_to_a_PDF_File.html
    <b>CONVERT_ABAPSPOOLJOB_2_PDF</b> FM convert abap spool output to PDF

  • How to convert alv list into excel file?

    Hi Experts,
            i have created one report for Due Date Analysis.
    Now My output is displaying in ALV list. But I need to convert the data which in alv list into Excel File. then only i have to send the Excel File to the Customer Thro Email.
         So i need the Function Module to Convert the Data into Excel File.
    Thanks,
    Neptune.M

    Hi,
      U can use function module gui_download.
      CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
        BIN_FILESIZE       =
          filename           = 'C:\Transportaionlane.XLS'
          filetype                       = 'DAT'
        WRITE_FIELD_SEPARATOR           = ' '
        HEADER                          = '00'
        TABLES
          ata_tab                       = t_trans_lane_dis[]
           OTHERS                          = 22
    if u want with header then pass the header.
    regards
    Ahasan

  • How to Convert Report into Excel Sheet when Sending Mail.

    Dear Friends,
    i want to send mail to HOD of Product with an Excel Sheet .
    i want to send Pending Issue details to HOD in Excel Sheet attachment .
    here i have pending issue report now i need to send it in Excel Sheet attachment .
    i have table where i have manage Product ID and HOD OF PRODUCT.
    CREATE TABLE  "MAP_USER_PRODUCT_DTL"
       (     "ID" NUMBER NOT NULL ENABLE,
         "PRODUCT_ID"NUMBER,
         "USER_ID" VARCHAR2(5) NOT NULL ENABLE,
         "HOD_PROD" VARCHAR2(100)========================================Value is Y OR N IF HOD then Y else N
         CONSTRAINT "MAP_USER_PRODUCT_DTL_PK" PRIMARY KEY ("ID") ENABLE
    /i have one more table where all complete issue detail insert.
    CREATE TABLE  "CRM_ISSUE_PROBLEM"
       (     "ID" NUMBER,
         "SUBJECT" VARCHAR2(255) NOT NULL ENABLE,
         "CLIENT_ID" NUMBER,
         "ASSIGNED_TO_ID" VARCHAR2(100),
         "ASSIGNED_ON" DATE,
         "DESCRIPTION" VARCHAR2(4000),
         "PRODUCT_ID" NUMBER NOT NULL ENABLE,
         "STATUS_ID" NUMBER NOT NULL ENABLE,
          CONSTRAINT "CRM_ISSUE_PROBLEM_PK" PRIMARY KEY ("ID") ENABLE
    Here STATUS_ID is Like Pending ISsue,Open Issue and Close Issue .i want to send mail to HOD with Pending Issue Report convert into Excel Sheet and send to HOD?
    How can i do this.
    Thanks
    Edited by: Vedant on Oct 12, 2011 12:36 AM
    Edited by: Vedant on Oct 12, 2011 2:22 AM

    Hello Vedant,
    Would it suffice if you send a CSV file?
    If yes, then see following code.. run the code under APEX > Home > SQL Workshop > SQL Commands
    DECLARE
            ln_id NUMBER;
            lc_clob CLOB;
         lb_blob BLOB;
         li_in PLS_INTEGER := 1;
         li_out PLS_INTEGER := 1;
         li_lang PLS_INTEGER := 0;
         li_warning PLS_INTEGER := 0;
         lv_mail_rcpts VARCHAR2(2000) := '[email protected]';
         lv_mail_from VARCHAR2(100) := '[email protected]';     
           lv_clmn_separator VARCHAR2(1) := ',';
    BEGIN
         -- Build file content as CLOB
      -- Replace with your query
         FOR i IN (select object_id A, object_name B, object_type C, status D, temporary E, generated F, secondary G,namespace H from user_objects where rownum < 10)               
         LOOP
        IF lc_clob IS NULL THEN
          lc_clob := i.A||lv_clmn_separator||i.B||lv_clmn_separator||i.C||lv_clmn_separator||i.D||lv_clmn_separator||i.E||lv_clmn_separator||i.F||lv_clmn_separator||i.G||lv_clmn_separator||i.H;
        ELSE
          lc_clob := lc_clob||CHR(10)||i.A||lv_clmn_separator||i.B||lv_clmn_separator||i.C||lv_clmn_separator||i.D||lv_clmn_separator||i.E||lv_clmn_separator||i.F||lv_clmn_separator||i.G||lv_clmn_separator||i.H;
        END IF;
         END LOOP; 
         -- Convert CLOB to BLOB
         DBMS_LOB.CREATETEMPORARY(lb_blob,TRUE);
         DBMS_LOB.convertToBlob(lb_blob,lc_clob,DBMS_LOB.LOBMAXSIZE,li_in,li_out,DBMS_LOB.DEFAULT_CSID,li_lang,li_warning);
         -- Send mail
         ln_id:= APEX_MAIL.SEND(
           p_to        => lv_mail_rcpts,
                 p_from      => lv_mail_from,
                 p_subj      => 'Subject Goes here',
                 p_body      => 'Body goes here'
           -- add CSV file as attachment
         APEX_MAIL.ADD_ATTACHMENT
           p_mail_id   => ln_id,
           p_attachment => lb_blob,
           p_filename   => 'filename.csv',
           p_mime_type  => 'application/csv'
      -- push mail queue
      APEX_MAIL.PUSH_QUEUE;
         -- empty temporary space
         DBMS_LOB.FREETEMPORARY ( lob_loc =>  lb_blob);       
         COMMIT;
    END;Regards,
    Hari

  • Regarding Downloading of Report[List] output into Excel Sheet

    Hi All,
    Hi i have written one Classical report. I got the output Correctly.
    Now i want to download that data into Excel Sheet in excatly the way it displayed in List[Report] output.
    I had followed the path <b>System->List->Save->LocalFile->Spread Sheet</b> and tried to download the same.
    Though it is downloaded it has not come in exact format.
    Now what i want is to add a button above that report & write a program in that to download that data into Excel Sheet.
    Can anybody tell me how can solve this issue. If i follow above procedure will the data[List Output] be downloaded into exact format into excel.
    If anybody knows other way please sujjest.
    Thanks in advance.
    Thanks & Regards,
    Prasad.

    Hi Prasad,
    I have done a program which downloads the output in the excel sheet in the correct format.
    Just check the program. The code given in bold is what you have to use.
    REPORT zexp MESSAGE-ID f4  LINE-SIZE 195.
        Tables Used    ***********************************
    TABLES : bseg, bkpf, bsak, lfa1, payr .
    Declaring Internal Tables  **************************
    DATA :
    Internal table to hold header data  *************
    BEGIN OF header OCCURS 0,
          ext_date(10) TYPE c,
          delimit(1)   TYPE c,
          ext_time(8)  TYPE c,
    END OF header,
    Internal table to hold detail info  **************
    BEGIN OF i_data OCCURS 0,
        belnr LIKE bsak-belnr,
        gjahr LIKE bsak-gjahr,
        bukrs LIKE bsak-bukrs,
        bldat LIKE bsak-bldat,
        xblnr LIKE bsak-xblnr,
        blart LIKE bsak-blart,
        augdt LIKE bsak-augdt,
        augbl LIKE bsak-augbl,
        wrbtr LIKE bsak-wrbtr,
        shkzg LIKE bsak-shkzg,
        lifnr LIKE bsak-lifnr,
        name1 LIKE lfa1-name1,
        chect LIKE payr-chect,
        status(1) TYPE c,
    END OF i_data,
    Internal table to to collect  *****************
    BEGIN OF i_data1 OCCURS 0,
         belnr LIKE bsak-belnr,
         gjahr LIKE bsak-gjahr,
         bukrs LIKE bsak-bukrs,
         bldat LIKE bsak-bldat,
         xblnr LIKE bsak-xblnr,
         blart LIKE bsak-blart,
         augdt LIKE bsak-augdt,
         augbl LIKE bsak-augbl,
         wrbtr LIKE bsak-wrbtr,
       shkzg LIKE bsak-shkzg,
         lifnr LIKE bsak-lifnr,
         name1 LIKE lfa1-name1,
         sortl LIKE lfa1-sortl,
         chect LIKE payr-chect,
         status(1) TYPE c,
    END OF i_data1,
    String variables for formatting file data *************
        fidoc_year   TYPE string,
        comp_code    TYPE string,
        check_numbr  TYPE string,
        vendor       TYPE string,
        inv_date     TYPE string,
        inv_nbr      TYPE string,
        paid_dat     TYPE string,
        inv_amt      TYPE string,
        status       TYPE string,
        ref_doc      TYPE string,
    ************Internal table to store the file contents **************
    BEGIN OF i_final_file OCCURS 0,
        record(300) TYPE c,
    END OF i_final_file,
    Internal table to store the list of allowed document types ****
      BEGIN OF i_doctype OCCURS 0,
             blart LIKE bsak-blart,
      END OF i_doctype,
    Internal table to hold vendor information ************
      BEGIN OF i_lfa1 OCCURS 0,
         lifnr LIKE lfa1-lifnr,
         name1 LIKE lfa1-name1,
         sortl LIKE lfa1-sortl,
      END OF i_lfa1,
    Internal table to hold check information *************
      BEGIN OF i_payr OCCURS 0,
         chect LIKE payr-chect,
         vblnr LIKE payr-vblnr,
         gjahr LIKE payr-gjahr,
         zbukr LIKE payr-zbukr,
      END OF i_payr.
      Data declarations  **************************
    DATA : ws_stblg     TYPE bkpf-stblg,
           todate       TYPE bsak-augdt,
           fromdate     TYPE bsak-augdt,
           w_day        LIKE dtresr-weekday,
           day          LIKE scal-indicator,
           d            TYPE n,
           e_date       LIKE sy-datum,
           e_time       LIKE sy-uzeit,
           dd(2)        TYPE c,
           mm(2)        TYPE c,
           yy(4)        TYPE c,
           hh(2)        TYPE c,
           min(2)       TYPE c,
           sec(2)       TYPE c.
    DATA : wa_filepath(50)    TYPE c,
           wa_filename(50)    TYPE c,
           wa_c_filename(100) TYPE c,
           arch_path(50)      TYPE c.
    <b>* Data for downloading to list
    DATA : list LIKE TABLE OF abaplist WITH HEADER LINE.
    DATA : BEGIN OF list_asc OCCURS 0,
    msg(300) TYPE c,
    END OF list_asc.
    DATA: BEGIN OF i_invoiceheader OCCURS 0,
    name(30) TYPE c,
    END OF i_invoiceheader.
    RANGES dates FOR bkpf-budat.</b>
      Selection Screen  ************************
    SELECTION-SCREEN SKIP 2.
    SELECT-OPTIONS:
             s_bukrs     FOR  bkpf-bukrs ,
             s_blart     FOR  bkpf-blart ,
             s_augdt     FOR  bsak-augdt. " memory id todat TO fromdat.
    PARAMETERS :submit  AS CHECKBOX DEFAULT ' '  .
    <b>* Download list to file.
    AT USER-COMMAND.
      CASE sy-ucomm.
        WHEN 'LIST'.
          PERFORM download.
        WHEN 'BACK'.
          EXIT.
      ENDCASE.</b>
    <b>----
          FORM download                                                 *
    FORM download.
    if s_augdt is initial.
    dates-sign = 'I'.
    dates-option = 'BT'.
    dates-low = '20050901'.
    dates-high = '20050920'.
    APPEND dates.
    else.
      dates = s_augdt.
      append dates.
    endif.
    /* Submit the same program .
      SUBMIT zexp WITH s_augdt IN dates
       EXPORTING LIST TO MEMORY
       AND RETURN.
      CALL FUNCTION 'LIST_FROM_MEMORY'
           TABLES
                listobject = list
           EXCEPTIONS
                not_found  = 1.
      CALL FUNCTION 'LIST_TO_ASCI'
    EXPORTING
    LIST_INDEX = -1 "LIST_INDEX SY-LSIND.
      TABLES
      listasci = list_asc
      listobject = list.
      PERFORM download_file.
    ENDFORM.
          FORM download_file                                            *
    FORM download_file.
      DATA fname TYPE rlgrap-filename VALUE 'c:\audit_report.xls'.
      DATA ftype TYPE rlgrap-filetype VALUE 'DAT'.
      DATA numeric_data(10) TYPE c VALUE '0123456789'.
    *Table structure should match with list output.
      DATA : BEGIN OF i_data1 OCCURS 0,
           belnr(12) TYPE c,
           gjahr(6) TYPE c,
           bukrs(8) TYPE c,
           chect(13) TYPE c,
           lifnr(12) TYPE c,
           name1(37) TYPE c,
           bldat(14) TYPE c,
           xblnr(18) TYPE c,
           augdt(14) TYPE c,
           wrbtr(17) TYPE c,
           status(4) TYPE c,
           augbl(18) TYPE c,
           sortl(17) TYPE c,
       END OF i_data1.
    Header record of the excel sheet.
      PERFORM fill_header.
      LOOP AT list_asc.
    Reads lines starting from the first record in the report. All informatory statements in the report are not read.
        IF list_asc+1(10) CO numeric_data.
          i_data1 = list_asc .
          APPEND i_data1.
        ENDIF.
      ENDLOOP.
    Call the download function.
    CALL FUNCTION 'DOWNLOAD'
           EXPORTING
                filename = fname
                filetype = ftype
           TABLES
                data_tab = i_data1
                FIELDNAMES = i_invoiceheader.
    ENDFORM.
          FORM fill_header                                              *
    FORM fill_header.
      i_invoiceheader-name = 'Doc Number'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Fsc Year'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Cmp Code'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Check No'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Vendor No'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Entered by'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Doc Date'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Ref Doc No'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Clearing Date'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Amount'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Status'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Clearing Doc No'.
      APPEND i_invoiceheader.
      i_invoiceheader-name = 'Sort field'.
      APPEND i_invoiceheader.
    ENDFORM.                    " fill_header</b>
       Initialization   *************************
    INITIALIZATION.
    To initialize the date parameter on the selection screen.
    The date by default ranges from previous Monday to Sunday.
      todate = sy-datum.
      CALL FUNCTION 'DATE_COMPUTE_DAY'
           EXPORTING
                date = todate
           IMPORTING
                day  = day.
      d = day.
      if d < 4.
        todate = sy-datum - d - 4 .
      else.
        todate = sy-datum - d + 3 .
      endif.
      fromdate = todate - 6.
      MOVE: 'BT'       TO s_augdt-option,
            fromdate   TO s_augdt-low,
            todate     TO s_augdt-high.
      APPEND s_augdt.
    Start of Selection  **************************
    START-OF-SELECTION.
    Checking the validity of the inputted dates ****************
      IF s_augdt-low > sy-datum OR s_augdt-high > sy-datum.
        MESSAGE i999 WITH 'You cannot input future date'.
        EXIT.
      ENDIF.
      IF NOT s_bukrs IS INITIAL.
    MESSAGE i999 WITH 'Program will run with input parameters in screen!!'.
      ENDIF.
    Initialize the header data ***********************
      e_time = sy-uzeit.
      MOVE e_time+0(2) TO hh.
      MOVE e_time+2(2) TO min.
      MOVE e_time+4(2) TO sec.
      CONCATENATE hh min sec INTO header-ext_time SEPARATED BY ':'.
      e_date = sy-datum.
      MOVE e_date+0(4) TO yy.
      MOVE e_date+4(2) TO mm.
      MOVE e_date+6(2) TO dd.
      CONCATENATE mm dd yy INTO header-ext_date SEPARATED BY '/'.
      header-delimit = '~'.
      APPEND header.
    List allowed document types **********************
      PERFORM fill_doc_types.
    **To select the documents within the range of week or as inputted **
      IF s_augdt IS INITIAL.
        MOVE: 'I' TO s_augdt-sign,
              'BT'       TO s_augdt-option,
              fromdate   TO s_augdt-low,
              todate     TO s_augdt-high.
        APPEND s_augdt.
      ENDIF.
    Selecting the records from the database ****************
      IF s_bukrs IS INITIAL AND s_blart IS INITIAL.
      Select all documents of company code 1000, *********
      4200 and 8000, and allowed document types  *********
        SELECT belnr gjahr augdt augbl bukrs
            blart bldat xblnr lifnr wrbtr shkzg
            FROM bsak INTO CORRESPONDING FIELDS OF TABLE i_data
            FOR ALL ENTRIES IN i_doctype
            WHERE blart EQ i_doctype-blart
            AND augdt IN s_augdt
            AND ( bukrs = '1000' OR bukrs ='4200'  OR
                ( bukrs = '8000' AND blart NE 'ZP' ) ).
       loop at i_data.
    Exclude reversed documents
          select single stblg into ws_stblg
                 from   bkpf
                 where  bukrs = i_data-bukrs
                   and  gjahr = i_data-gjahr
                   and  belnr = i_data-belnr.
          if not ws_stblg is initial.
             delete i_data.
          endif.
       endloop.
      ELSEIF s_blart IS INITIAL.
      Select all documents of allowed document types ******
           and inputted company code           ************
        SELECT belnr gjahr augdt augbl bukrs
           blart bldat xblnr lifnr wrbtr shkzg
           FROM bsak INTO CORRESPONDING FIELDS OF TABLE i_data
           FOR ALL ENTRIES IN i_doctype
           WHERE blart EQ i_doctype-blart
             AND augdt IN s_augdt
             AND bukrs IN s_bukrs .
        LOOP AT i_data.
    Exclude documents of type ZP
    for company code 8000.
          IF i_data-bukrs = '8000' AND i_data-blart = 'ZP'.
            DELETE i_data.
            continue.
          ENDIF.
      Exclude reversed documents
          select single stblg into ws_stblg
                 from   bkpf
                 where  bukrs = i_data-bukrs
                   and  gjahr = i_data-gjahr
                   and  belnr = i_data-belnr.
          if not ws_stblg is initial.
             delete i_data.
             continue.
          endif.
        ENDLOOP.
        READ TABLE i_data INDEX 1.
        IF sy-subrc NE 0.
          MESSAGE i999 WITH 'No records have been selected'.
          EXIT.
        ENDIF.
      ELSE.
      Select the documents matching the company codes  *****
    and document types inputted in the selection screen ****
        SELECT belnr gjahr augdt augbl bukrs bldat xblnr
           blart lifnr  wrbtr shkzg
           FROM bsak INTO CORRESPONDING FIELDS OF TABLE i_data
           WHERE bukrs IN s_bukrs AND blart IN s_blart
             AND augdt IN s_augdt.
        SORT i_data BY blart.
        LOOP AT i_data.
      Filtering the records selected
      based on the document type
          READ TABLE i_doctype WITH KEY blart = i_data-blart.
          IF sy-subrc NE 0.
            DELETE i_data.
            continue.
          ENDIF.
      Exclude documents of type ZP
      for company code 8000.
          IF i_data-bukrs = '8000' AND i_data-blart = 'ZP'.
            DELETE i_data.
            continue.
          ENDIF.
      Exclude reversed documents.
          select single stblg into ws_stblg
                 from   bkpf
                 where  bukrs = i_data-bukrs
                   and  gjahr = i_data-gjahr
                   and  belnr = i_data-belnr.
          if not ws_stblg is initial.
             delete i_data.
             continue.
          endif.
        ENDLOOP.
        READ TABLE i_data INDEX 1.
        IF sy-subrc NE 0.
          MESSAGE i999 WITH 'No records have been selected'.
          EXIT.
        ENDIF.
      ENDIF.
      IF sy-subrc NE 0.
        MESSAGE i999 WITH 'No records have been selected'.
        EXIT.
      ENDIF.
    credit/debit identification ***********************
      LOOP AT i_data.
        IF i_data-shkzg EQ 'H'.
          i_data-wrbtr = i_data-wrbtr * 1.
        ELSEIF i_data-shkzg EQ 'S'.
          i_data-wrbtr = i_data-wrbtr * -1.
        ENDIF.
        MODIFY i_data.
      ENDLOOP.
    for summarizing ******************************
      LOOP AT i_data.
        MOVE-CORRESPONDING  i_data TO i_data1.
        COLLECT i_data1.
      ENDLOOP.
    Vendor informations and Check Informations *****************
      SELECT lifnr name1 sortl
             FROM lfa1
             APPENDING CORRESPONDING FIELDS OF TABLE i_lfa1
             FOR ALL ENTRIES IN i_data1
             WHERE lifnr = i_data1-lifnr.
      SELECT chect vblnr gjahr zbukr FROM payr APPENDING CORRESPONDING
                                FIELDS OF TABLE i_payr FOR ALL ENTRIES
                                IN  i_data1   WHERE vblnr = i_data1-augbl
                                AND gjahr = i_data1-augdt(4)
                                AND zbukr = i_data1-bukrs.
      SORT i_data1 BY augbl gjahr bukrs lifnr.
      SORT i_payr  BY vblnr gjahr zbukr.
      SORT i_lfa1  BY lifnr.
      LOOP AT i_data1.
        READ TABLE i_payr WITH KEY vblnr = i_data1-augbl
                                   gjahr = i_data1-gjahr
                                   zbukr = i_data1-bukrs.
        IF sy-subrc EQ 0.
          i_data1-chect = i_payr-chect.
        ENDIF.
        READ TABLE i_lfa1 WITH KEY lifnr = i_data1-lifnr.
        IF sy-subrc EQ 0.
          i_data1-name1 = i_lfa1-name1.
          i_data1-sortl = i_lfa1-sortl.
        ENDIF.
        i_data1-status = 'X'.
        MODIFY i_data1.
      ENDLOOP.
    **The records are sorted by clearing date, check number and doc type**
      SORT i_data1 BY augdt chect blart.
    **********The header record is outputted on the screen****************
      PERFORM write_header.
    ********Data is moved to internal table in the file format *************
      PERFORM move_data.
    Line items are outputted on the screen *********************
      PERFORM write_output.
    *&                   Form  write_header                             &*
    *&        This outputs the header information to screen             &*
    FORM write_header.
      SKIP.
       SET PF-STATUS 'LIST'.
    Outputting the header information *********************
      WRITE : / 'Extraction Date : ' , header-ext_date.
      WRITE : / 'Extraction Time : ' , header-ext_time.
      FORMAT COLOR 1." INTENSIFIED.
      SKIP.
      ULINE AT 0(190) NO-GAP.
    Outputting line level information **********************
      WRITE:/  sy-vline NO-GAP,
            (10) 'DOC NUMBER',
              sy-vline NO-GAP,
             (4) 'F-YR',
               sy-vline NO-GAP,
             (6) 'C-CODE',
              sy-vline NO-GAP,
             (10) 'CHECK NUM',
              sy-vline NO-GAP,
             (10) 'VENDOR NUM',
              sy-vline NO-GAP,
             (35) 'VENDOR NAME',
               sy-vline NO-GAP,
             (12) 'INVOICE DATE',
              sy-vline NO-GAP,
             (16) 'INVOICE NUMBER',
              sy-vline NO-GAP,
             (12) 'PAID DATE',
               sy-vline NO-GAP,
             (15) 'INVOICE AMOUNT',
              sy-vline NO-GAP,
             (2) 'SC',
              sy-vline NO-GAP,
             (16) 'REFERENCE FI DOC',
               sy-vline NO-GAP,
             (15) 'SORT FIELD',
               sy-vline NO-GAP.
      ULINE AT 0(190) NO-GAP.
    ENDFORM.                    " write_header
    *&                      FORM  MOVE_DATA                             &*
    *&    Formats data in internal table as is required in the file     &*
    FORM move_data.
      LOOP AT i_data1.
    Document number and fiscal year should be separted by '|' *****
        CONCATENATE i_data1-belnr i_data1-gjahr INTO fidoc_year
                    SEPARATED BY '|'.
        MOVE i_data1-bukrs TO comp_code.
        MOVE i_data1-chect TO check_numbr.
    Vendor number and vendor name should be separted by '|' *****
        CONCATENATE i_data1-lifnr i_data1-name1 INTO vendor
          SEPARATED BY '|'.
        SHIFT vendor LEFT DELETING LEADING '0'.
        SHIFT vendor RIGHT DELETING TRAILING space.
    Date fields converted to MM/DD/YYYY format ****************
        MOVE i_data1-bldat+0(4) TO yy.
        MOVE i_data1-bldat+4(2) TO mm.
        MOVE i_data1-bldat+6(2) TO dd.
        CONCATENATE mm dd yy INTO inv_date SEPARATED BY '/'.
        MOVE i_data1-xblnr TO inv_nbr.
        SHIFT inv_nbr RIGHT DELETING TRAILING space.
        MOVE i_data1-augdt+0(4) TO yy.
        MOVE i_data1-augdt+4(2) TO mm.
        MOVE i_data1-augdt+6(2) TO dd.
        CONCATENATE mm dd yy INTO paid_dat SEPARATED BY '/'.
        MOVE i_data1-wrbtr TO inv_amt.
        CONDENSE inv_amt.
       SHIFT inv_amt RIGHT DELETING TRAILING space.
        MOVE i_data1-status TO status.
        MOVE i_data1-augbl TO ref_doc.
        CONCATENATE fidoc_year
                    comp_code
                    check_numbr
                    vendor
                    inv_date
                    inv_nbr
                    paid_dat
                    inv_amt
                    status
                    ref_doc
           INTO i_final_file-record SEPARATED BY '~'.
        APPEND i_final_file.
      ENDLOOP.
    ENDFORM.                    " MOVE_DATA
    *&                      Form  write_output                          &*
    *&                  Outputs all data to screen                      &*
    FORM write_output.
      LOOP AT i_data1.
        FORMAT COLOR 2 INTENSIFIED.
    Outputting line level information *******************
        WRITE :  /  sy-vline NO-GAP,
                 (10) i_data1-belnr,
                   sy-vline NO-GAP,
                (4) i_data1-gjahr,
                   sy-vline NO-GAP,
                 (6) i_data1-bukrs,
                   sy-vline NO-GAP,
                (10) i_data1-chect,
                  sy-vline NO-GAP,
                  (10) i_data1-lifnr,
                 sy-vline NO-GAP,
                 (35) i_data1-name1,
                   sy-vline NO-GAP,
                 (12) i_data1-bldat MM/DD/YYYY,
                   sy-vline NO-GAP,
                 (16)  i_data1-xblnr,
                   sy-vline NO-GAP,
                 (12) i_data1-augdt MM/DD/YYYY,
                   sy-vline NO-GAP,
                 (15) i_data1-wrbtr,
                   sy-vline NO-GAP,
                 (2) i_data1-status,
                   sy-vline NO-GAP,
                 (16) i_data1-augbl,
                   sy-vline NO-GAP,
                 (15) i_data1-sortl,
                 sy-vline NO-GAP.
      ENDLOOP.
      ULINE AT 0(190) NO-GAP.
    ENDFORM.                    " write_output
    In the program, I am downloading only the list.. The description of report outputted in the beginning of the report is not downloaded to excel.
    What has to be taken into consideration is that, the structure of the table i_data1 which contains the data to be downloaded to the table.
    I hope that this will help you.
    Regards,
    Susmitha

  • How to convert Report Model to Report Designer DataSet

    To all,
    I have a two part question. One is I am experiencing the error at the end of this question when migrating SQL Server 2005 SSRS Native Reports, the report uses a Report Model, to SQL Server 2008 SSRS Native. I bring the Report and Report Model to SQL Server 2008 SSRS and get the error at the end of the question below. Background and the 2nd question are below.
    I have a bunch of Report Builder based Reports. I need to convert them to VS BIDS based Report Designer Reports with Shared Datasources and MDX based DataSets.
    How can I grab the MDX from the Report Builder Report Model so I can put it into the Report Designer DataSet Query Definition?
    What is the easiest way to make this migration between these Report development environments.
    I am able to open the Report.RDL file in VS BIDS and can see the entire UI layer. The DataSet I see here is the one that is related to the error at the end of the question. The RD/DataSet holds:
    <SemanticQuery xmlns="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rb="http://schemas.microsoft.com/sqlserver/2004/11/reportbuilder" xmlns:qd="http://schemas.microsoft.com/sqlserver/2004/11/semanticquerydesign">
      <Hierarchies>
        <Hierarchy>
          <BaseEntity>
            <!--Fact Messages-->
            <EntityID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Entity_MeasureGroup_DW_Text_Fact_Messages</EntityID>
          </BaseEntity>
          <Groupings>
            <Grouping Name="Date">
              <Expression Name="Date">
                <Path>
                  <RolePathItem>
                    <!--Dim Date-->
                    <RoleID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Role_MeasureGroupDimension_Entity_MeasureGroup_DW_Text_Fact_Messages_Entity_Dimension_Dim_Date_Entity_Dimension_DW_Text_Dim_Date</RoleID>
                  </RolePathItem>
                </Path>
                <AttributeRef>
                  <!--Full Date-->
                  <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Hierarchy_Dim_Date.Full_Date</AttributeID>
                </AttributeRef>
              </Expression>
            </Grouping>
            <Grouping Name="Hour">
              <Expression Name="Hour">
                <Path>
                  <RolePathItem>
                    <!--Dim Time-->
                    <RoleID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Role_MeasureGroupDimension_Entity_MeasureGroup_DW_Text_Fact_Messages_Entity_Dimension_Dim_Time_Entity_Dimension_DW_Text_Dim_Time</RoleID>
                  </RolePathItem>
                </Path>
                <AttributeRef>
                  <!--Hour24-->
                  <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Hierarchy_Dim_Time.Hour24</AttributeID>
                </AttributeRef>
              </Expression>
            </Grouping>
            <Grouping Name="Year">
              <Expression Name="Year">
                <Path>
                  <RolePathItem>
                    <!--Dim Date-->
                    <RoleID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Role_MeasureGroupDimension_Entity_MeasureGroup_DW_Text_Fact_Messages_Entity_Dimension_Dim_Date_Entity_Dimension_DW_Text_Dim_Date</RoleID>
                  </RolePathItem>
                </Path>
                <AttributeRef>
                  <!--Year-->
                  <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Hierarchy_Dim_Date.Year</AttributeID>
                </AttributeRef>
              </Expression>
            </Grouping>
          </Groupings>
          <Filter>
            <Expression Name="expr1">
              <Function>
                <FunctionName>And</FunctionName>
                <Arguments>
                  <Expression>
                    <Function>
                      <FunctionName>And</FunctionName>
                      <Arguments>
                        <Expression>
                          <Function>
                            <FunctionName>GreaterThanOrEquals</FunctionName>
                            <Arguments>
                              <Expression>
                                <Path>
                                  <RolePathItem>
                                    <!--Dim Date-->
                                    <RoleID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Role_MeasureGroupDimension_Entity_MeasureGroup_DW_Text_Fact_Messages_Entity_Dimension_Dim_Date_Entity_Dimension_DW_Text_Dim_Date</RoleID>
                                  </RolePathItem>
                                </Path>
                                <AttributeRef>
                                  <!--Date-->
                                  <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Hierarchy_Dim_Date.Date</AttributeID>
                                </AttributeRef>
                              </Expression>
                              <Expression>
                                <Function>
                                  <FunctionName>DateAdd</FunctionName>
                                  <Arguments>
                                    <Expression>
                                      <Literal>
                                        <DataType>String</DataType>
                                        <Value>Day</Value>
                                      </Literal>
                                    </Expression>
                                    <Expression>
                                      <Function>
                                        <FunctionName>Negate</FunctionName>
                                        <Arguments>
                                          <Expression>
                                            <ParameterRef>
                                              <ParameterName>Date  in last  (n)  days</ParameterName>
                                            </ParameterRef>
                                          </Expression>
                                        </Arguments>
                                      </Function>
                                    </Expression>
                                    <Expression>
                                      <Function>
                                        <FunctionName>Today</FunctionName>
                                      </Function>
                                    </Expression>
                                  </Arguments>
                                </Function>
                              </Expression>
                            </Arguments>
                          </Function>
                        </Expression>
                        <Expression>
                          <Function>
                            <FunctionName>LessThan</FunctionName>
                            <Arguments>
                              <Expression>
                                <Path>
                                  <RolePathItem>
                                    <!--Dim Date-->
                                    <RoleID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Role_MeasureGroupDimension_Entity_MeasureGroup_DW_Text_Fact_Messages_Entity_Dimension_Dim_Date_Entity_Dimension_DW_Text_Dim_Date</RoleID>
                                  </RolePathItem>
                                </Path>
                                <AttributeRef>
                                  <!--Date-->
                                  <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Hierarchy_Dim_Date.Date</AttributeID>
                                </AttributeRef>
                              </Expression>
                              <Expression>
                                <Function>
                                  <FunctionName>Today</FunctionName>
                                </Function>
                              </Expression>
                            </Arguments>
                          </Function>
                        </Expression>
                      </Arguments>
                    </Function>
                    <CustomProperties>
                      <CustomProperty Name="qd:FilterCondition" />
                    </CustomProperties>
                  </Expression>
                  <Expression>
                    <Function>
                      <FunctionName>Equals</FunctionName>
                      <Arguments>
                        <Expression>
                          <Path>
                            <RolePathItem>
                              <!--Dim Volume-->
                              <RoleID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Role_MeasureGroupDimension_Entity_MeasureGroup_DW_Text_Fact_Messages_Entity_Dimension_Dim_Volume_Entity_Dimension_DW_Text_Dim_Volume</RoleID>
                            </RolePathItem>
                          </Path>
                          <AttributeRef>
                            <!--Description-->
                            <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Hierarchy_Dim_Volume.Description</AttributeID>
                          </AttributeRef>
                        </Expression>
                        <Expression>
                          <Literal>
                            <DataType>String</DataType>
                            <Value>Volume</Value>
                          </Literal>
                        </Expression>
                      </Arguments>
                    </Function>
                    <CustomProperties>
                      <CustomProperty Name="qd:FilterCondition" />
                    </CustomProperties>
                  </Expression>
                </Arguments>
              </Function>
              <CustomProperties>
                <CustomProperty Name="qd:Filter" />
                <CustomProperty Name="qd:ContextEntityID">
                  <Value xsi:type="xsd:string">http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling:Entity_MeasureGroup_DW_Text_Fact_Messages</Value>
                </CustomProperty>
                <CustomProperty Name="qd:AutoChangeBaseEntity" />
                <CustomProperty Name="qd:Design">
                  <Value xsi:type="xsd:string">expr2</Value>
                </CustomProperty>
              </CustomProperties>
            </Expression>
          </Filter>
        </Hierarchy>
      </Hierarchies>
      <MeasureGroups>
        <MeasureGroup>
          <BaseEntity>
            <!--Fact Messages-->
            <EntityID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Entity_MeasureGroup_DW_Text_Fact_Messages</EntityID>
          </BaseEntity>
          <Measures>
            <Expression Name="Volume">
              <AttributeRef>
                <!--Volume-->
                <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Measure_DW_Text_Volume</AttributeID>
              </AttributeRef>
            </Expression>
            <Expression Name="Auto %">
              <AttributeRef>
                <!--Automated_Pct-->
                <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Measure_DW_Text_Automated_Pct</AttributeID>
              </AttributeRef>
            </Expression>
            <Expression Name="Send Now %">
              <AttributeRef>
                <!--Send_Now_Pct-->
                <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Measure_DW_Text_Send_Now_Pct</AttributeID>
              </AttributeRef>
            </Expression>
            <Expression Name="Use %">
              <AttributeRef>
                <!--Use_Pct-->
                <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Measure_DW_Text_Use_Pct</AttributeID>
              </AttributeRef>
            </Expression>
            <Expression Name="Stock Ans %">
              <AttributeRef>
                <!--StockAns_Pct-->
                <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Measure_DW_Text_StockAns_Pct</AttributeID>
              </AttributeRef>
            </Expression>
            <Expression Name="Charged">
              <AttributeRef>
                <!--Charged_Pct-->
                <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Measure_DW_Text_Charged_Pct</AttributeID>
              </AttributeRef>
            </Expression>
            <Expression Name="Billed">
              <AttributeRef>
                <!--Billed_Pct-->
                <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Measure_DW_Text_Billed_Pct</AttributeID>
              </AttributeRef>
            </Expression>
            <Expression Name="Avg TTA (s)">
              <AttributeRef>
                <!--Avg_TT_Answer-->
                <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Measure_DW_Text_Avg_TT_Answer</AttributeID>
              </AttributeRef>
            </Expression>
            <Expression Name="Avg TTC (s)">
              <AttributeRef>
                <!--Avg_Time_To_Customer-->
                <AttributeID xmlns:np="http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling">np:Attribute_Measure_DW_Text_Avg_Time_To_Customer</AttributeID>
              </AttributeRef>
            </Expression>
          </Measures>
          <SubtotalSets>
            <SubtotalSet>
              <SubtotalGroupings>
                <GroupingName>Year</GroupingName>
              </SubtotalGroupings>
              <SubtotalMeasures>
                <MeasureName>Volume</MeasureName>
                <MeasureName>Auto %</MeasureName>
                <MeasureName>Send Now %</MeasureName>
                <MeasureName>Use %</MeasureName>
                <MeasureName>Stock Ans %</MeasureName>
                <MeasureName>Charged</MeasureName>
                <MeasureName>Billed</MeasureName>
                <MeasureName>Avg TTA (s)</MeasureName>
                <MeasureName>Avg TTC (s)</MeasureName>
              </SubtotalMeasures>
            </SubtotalSet>
            <SubtotalSet>
              <SubtotalGroupings>
                <GroupingName>Date</GroupingName>
                <GroupingName>Year</GroupingName>
              </SubtotalGroupings>
              <SubtotalMeasures>
                <MeasureName>Volume</MeasureName>
                <MeasureName>Auto %</MeasureName>
                <MeasureName>Send Now %</MeasureName>
                <MeasureName>Use %</MeasureName>
                <MeasureName>Stock Ans %</MeasureName>
                <MeasureName>Charged</MeasureName>
                <MeasureName>Billed</MeasureName>
                <MeasureName>Avg TTA (s)</MeasureName>
                <MeasureName>Avg TTC (s)</MeasureName>
              </SubtotalMeasures>
            </SubtotalSet>
          </SubtotalSets>
        </MeasureGroup>
      </MeasureGroups>
      <Parameters>
        <Parameter Name="Date  in last  (n)  days">
          <DataType>Integer</DataType>
          <Expression>
            <Literal>
              <DataType>Integer</DataType>
              <Value>14</Value>
            </Literal>
          </Expression>
        </Parameter>
      </Parameters>
      <CustomProperties>
        <CustomProperty Name="qd:PerspectiveID">
          <Value xsi:type="xsd:string">http://schemas.microsoft.com/sqlserver/2004/10/semanticmodeling/udmmodeling:Perspective_Cube_DW_Text</Value>
        </CustomProperty>
      </CustomProperties>
    </SemanticQuery>
    I have created a Shared Datasource that points the the correct Analysis Services cubes that the original Report Model pointed at.
    However, I get this error when running the report:
    An error occurred during client rendering.
    An error has occurred during report processing.
    Semantic query compilation failed: e EmptySemanticQuery The SemanticQuery does not contain any Groupings or MeasureGroups. SemanticQuery must contain at least one of these elements. (SemanticQuery '').

    Actually the error above is from running the report on SSRS 2008 Native. Does anyone know why I get this error and how it may be resolved.
    Then I try to bring the report into BIDS RD and create a SDS and DataSet. The Semantic Query above is from the RD DataSet Query window.
    I get the following error when running the report in BIDS RD:
    An error occured during local processing.
    An error has occured during report processing.
    Query execution failed for dataset 'dataSet'.
    The SemanticQuery element at line 7, column 351 (namespace http://schema.microsoft.com/sqlserver/2004/10semanticmodeling) cannot appear under Envelope/Body/Execute/Command.
    So I have two errors with two scenarios. I'd like to know how to resolve one of them.
    I'd also like to know how to get the MDX from the RB/RM report so I can put it into the VS BIDS Version and get that to work properly.
    Thanks,
    Eric

  • How to convert report to pdf format  after that I want to send on mail

    Hi
    Guru
    What is my requirement . I want put push button on output list of a normal report. When user click on mail push button, mail should go to customer mail id according to customer  no i gave input  for customer no in selection screen.
    For this I need what is function module (Code) for convert a report to pdf format and whats function module for send mail to customer.
    Plz help me out
    thanks
    Durgesh

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

  • How can create report in Spread sheet (Excel sheet)?

    Hi All.
    I need to prepare report in excel.How can prepare? please help me.
    Thanks.
    Jay

    HI,
    use the function module
    gui_download
    so that the whole itab records will be shown in excel sheet.
    reward points if helpful.
    regards,
    venkatesh

Maybe you are looking for

  • A/c Determination for special stock

    Dear Only we are receiving the QUANTITY but no financial document we nee it only material qty are enter check the path 1:First we create sales order 2:Transaction code MB1C with M/T 501 (E) we received the stock (ONLY MATERIAL QTY NO FINANCIAL DOCUME

  • How to create ABAP Proxy for SSL secured ABAP Service

    Hi guys, I try to set up transport security for my ABAP web service. The service should be called via a ABAP Proxy. These are my steps to create the ABAP web service: 1. Create function module (se80) 2. Create web service (web service definition) (se

  • The brightness on my 4th generation ipod nano is broken how can I fix this?

    The brightness on my ipod nano 4th generation is broken. I have it set on high, but it is very faint. Is there a procedure I can do or pay someone else to do to get it fixed?

  • Urgent,   Restricting Sales org & Distribution Channel

    I'm having two users and one is from US and other MEXICO If user from US LOG'S into SAP ,He should only his Sales org(US01) & Distribution Channel(001) & Mexico User log ,then he should be able to see only his Sales org(ME01). My Question is there a

  • Pre-Execution phase is beginning running for more than an hour

    Hi guys, I am trying to pull data from MSSQL Server 2000 (has over 400 Million rows of data) into MSSQL 2012 using SSIS (using the SQL Command Access Mode).  For over an hour I started running the package, it was just showing Pre-Exectuing Phase is B