ALV grid to protected Excel sheet

Hi ABAP gurus,
I Have developed an ALV report using OO concept and from the application toolbar i am able to change  the GRID output to Excel output using View -> Excel inplace. Belows are my requirement now.
1. I need to change the standard template with my template for this particular ALV report or Transaction. PLease provide me  with steps details to do it.
2. The Excel sheet should be in protected  mode and user should be able to only take print out from the excel sheet without modifying any columns .
If there is no standard way  we can add an additional  appliaction menu and  code it to download  the ALV output into an  Excel sheet and display it .  However again the User should not be able to modify the sheet. please provide me with sample code to do it.
PLease suggest  solution for this . Point will be awarded for all valuable answers.
Please it is very urgent for me ...
Thanks in advance.
Iftekhar Alam

Hi ABAP gurus,
I Have developed an ALV report using OO concept and from the application toolbar i am able to change  the GRID output to Excel output using View -> Excel inplace. Belows are my requirement now.
1. I need to change the standard template with my template for this particular ALV report or Transaction. PLease provide me  with steps details to do it.
2. The Excel sheet should be in protected  mode and user should be able to only take print out from the excel sheet without modifying any columns .
If there is no standard way  we can add an additional  appliaction menu and  code it to download  the ALV output into an  Excel sheet and display it .  However again the User should not be able to modify the sheet. please provide me with sample code to do it.
PLease suggest  solution for this . Point will be awarded for all valuable answers.
Please it is very urgent for me ...
Thanks in advance.
Iftekhar Alam

Similar Messages

  • Exporting ALV Grid output to Excel sheet

    Hi All,
           How can i export the output displayed using Grid to an Excel sheet. I tried with default option from list->export->excel sheet/local file but i am not getting complete data and the data which i am getting also notin proper format. Please help me in this regard.
    Best Regards,
    Sunil

    Check out the ALV grid toolbar for export options.
    Regards
    Raja

  • Leading Zeros Missing - When exporting data from ALV grid display to Excel

    Hi,
    Am exporting the data from ALV GRID DISPLAY to Excel sheet using standard toolbar icon 'Local file'
    the leading zeros displayed in the ALV output is missing in the EXCEL sheet.
    (eg)  in ALV o/p - 0029. 
            in Excel - Only 29 is appearing.
    As per the requiement i have to show the leading zeros in excel also.
    Pls help on this issue.
    Thanks in advance..

    Hi ,
      Please set the property  :
      wa_fieldcat-lzero = 'X' .
    when you are creating field catalog for display alv data .
    your prob will solved .
    Regards ,
    Nilesh Jain

  • Has anyone tried to export an ALV Tree to an excel sheet?

    Hi "gurus",
    I've been looking for a way of exporting a printed report in an ALV tree to an Excel sheet.
    Has someone done this before?
    NOTE: I am studying the Office Integration, which I believe it can be a way of making SAP generates it via ABAP objects.
    Thanks and Regards,
    Daniel Carvalho
    Edited by: Daniel Carvalho on Feb 28, 2008 11:40 PM

    (Add a Button function in the ON Toolbar such as EXCEL and set event handlers).
    METHOD on_user_command.
       break-point 2.
      CASE e_ucomm.
         WHEN 'EXIT'.
            LEAVE PROGRAM.
         WHEN 'EXCEL'.
          CALL METHOD me->download_to_excel.
         WHEN 'SAVE'.
         WHEN 'PROC'.
          CALL METHOD me->process.
         WHEN 'REFR'.
          CALL METHOD me->refresh.
      ENDCASE.
    endmethod.
    METHOD on_toolbar.
    CLEAR ls_toolbar.
        MOVE  0 TO ls_toolbar-butn_TYPE.
      MOVE 'EXCEL' TO ls_toolbar-function.
      MOVE  SPACE TO ls_toolbar-disabled.
      MOVE  icon_xxl TO ls_toolbar-icon.
      MOVE 'Excel' TO ls_toolbar-quickinfo.
      MOVE  'EXCEL' TO ls_toolbar-text.
      APPEND ls_toolbar TO e_object->mt_toolbar.
    endmethod.
      METHOD  download_to_excel.
    field-symbols:
        <fs0> TYPE standard table,
        <fs1> TYPE standard table.
      assign g_outtab1->* to <fs0>.
      assign g_fldcat1->* to <fs1>.
    break-point 5.
      CALL FUNCTION  'LVC_TRANSFER_TO_KKBLO'
        EXPORTING
          it_fieldcat_lvc   = <fs1>
    *     is_layout_lvc     = m_cl_variant->ms_layout
           is_tech_complete  = ' '
        IMPORTING
          es_layout_kkblo   = ls_layout
          et_fieldcat_kkblo = lt_fieldcat.
       LOOP AT lt_fieldcat INTO lt_fieldcat_wa.
        CLEAR lt_fieldcat_wa-tech_complete.
        IF lt_fieldcat_wa-tabname IS initial.
           lt_fieldcat_wa-tabname = '1'.
           MODIFY lt_fieldcat FROM lt_fieldcat_wa.
        ENDIF.
        l_tabname = lt_fieldcat_wa-tabname.
       ENDLOOP.
    CALL FUNCTION 'ALV_XXL_CALL'
        EXPORTING
          i_tabname           = l_tabname
          is_layout           = ls_layout
          it_fieldcat         = lt_fieldcat
          i_title             = sy-title
        TABLES
          it_outtab           = <fs0>
        EXCEPTIONS
          fatal_error         = 1
          no_display_possible = 2
          others              = 3.
      IF  sy-subrc <> 0.
         message id sy-msgid TYPE 'S' number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    ENDMETHOD.
    Your original table that goes to the grid is parameter g_outtab1
    the field catalog is g_fldcat1.
    These need to be converted to kkblo format to use the XXL function module.
    The advantage of this method is that you get an EXCEL spreadsheet interactively.
    (Of course the standard export function will still work).
    Cheers
    Jimbo

  • ALV grid export to Excel 2003-f.01

    Hi all,
    I have an issue with ALV grid export to excel 2003 ,when i tried to download with the option as local file > xls file ,the report downloads with page breaks which the user does not want , each break comeswith header .
    With the option of list>export>xml sheet - the report downloads with out page break but with no header information like the name of the report and reporting period .The tcode is f.01 and the system is ECC6.
    Can any one suggest  how to download the report with tiltle of the report with no page break ?
    Thanks
    ske

    Hi
    What happens if you use the export/local file option - does that help at all or can you change the layout? Haven't got access to your release to check.
    Cheers
    David
    Edited by: David Berry on Oct 28, 2010 9:38 PM

  • Download the ALV Report output into excel sheet or notepad

    Hi,
    how to downlaod the alv report out into excel sheet or notepad in a proper manner. program contain large number records....
    Thanks in advance!!!!
    Regards,
    kranthi.

    Hi
    Download a report to excel with format (border, color cell, etc) 
    Try this program...it may help you to change the font ..etc.
    Code:
    REPORT ZSIRI NO STANDARD PAGE HEADING.
    this report demonstrates how to send some ABAP data to an
    EXCEL sheet using OLE automation.
    INCLUDE OLE2INCL.
    handles for OLE objects
    DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
          H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
          H_MAP TYPE OLE2_OBJECT,          " workbook
          H_ZL TYPE OLE2_OBJECT,           " cell
          H_F TYPE OLE2_OBJECT.            " font
    TABLES: SPFLI.
    DATA  H TYPE I.
    table of flights
    DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
    *&   Event START-OF-SELECTION
    START-OF-SELECTION.
    read flights
      SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
    display header
      ULINE (61).
      WRITE: /     SY-VLINE NO-GAP,
              (3)  'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (4)  'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (8)  'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
      ULINE /(61).
    display flights
      LOOP AT IT_SPFLI.
      WRITE: / SY-VLINE NO-GAP,
               IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
      ENDLOOP.
      ULINE /(61).
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-007
           EXCEPTIONS
                OTHERS     = 1.
    start Excel
      CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
    PERFORM ERR_HDL.
      SET PROPERTY OF H_EXCEL  'Visible' = 1.
    CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
    PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-008
           EXCEPTIONS
                OTHERS     = 1.
    get list of workbooks, initially empty
      CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP.
      PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - start
    CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP  EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    tell user what is going on
      SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - end
    disconnect from Excel
         CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING  #1 = 'C:\SKV.XLS'.
      FREE OBJECT H_EXCEL.
      PERFORM ERR_HDL.
          FORM FILL_CELL                                                *
          sets cell at coordinates i,j to value val boldtype bold       *
    FORM FILL_CELL USING I J BOLD VAL.
      CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_ZL 'Value' = VAL .
      PERFORM ERR_HDL.
      GET PROPERTY OF H_ZL 'Font' = H_F.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_F 'Bold' = BOLD .
      PERFORM ERR_HDL.
    ENDFORM.
    *&      Form  ERR_HDL
          outputs OLE error if any                                       *
    -->  p1        text
    <--  p2        text
    FORM ERR_HDL.
    IF SY-SUBRC <> 0.
      WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
      STOP.
    ENDIF.
    ENDFORM.                    " ERR_HDL
    Please note that this example maybe slow at filling the excel table
    (perhaps four fields per second on a 900 MHz machine - almost 30 seconds
    for a short example).
    To get the data on properties and methods - there is a bit of smoke and mirrors
    going on here; they are EXCEL properties and methods, not sap ones - so you need
    to look at excel help to determine how a particular function is structured. then
    build the block in sap, as shown in the example.
    If you only want to transfer the data to Excel like when you transfer the data from
    ALV to Excel simply use the Function Modules:
    XXL_SIMPLE_API
    If you want more modifications when you transfer it to Excel use:
    XXL_FULL_API

  • Problem when dowloading the ALV report output to Excel Sheet.

    Hi ,
    I am dowloading the ALV report output to Excel Sheet.
    There is field Condition Unit(KOMP-KMEIN) in the output of the ALV, this has values PC and CSE , but when I download to Excel Sheet, CSE is appearing as CSE ,but PC is appearing as ******.
    Can you please help me in knowing the reson for this.
    Regards,
    Madhu.

    hi
    refer to following link
    http://www.****************/Tutorials/ALV/ColorSALV/Demo.htm
    http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
    Cheers
    Snehi
    Edited by: snehi chouhan on Jul 11, 2008 12:42 PM

  • ALV colouring download to excel sheet

    Hi Experts ,
    I have a requirement in which I have coloured the cells of the ALV display , in order to highlight them.
    I have made use of 'REUSE_ALV_GRID_DISPLAY' FM for displaying ALV.
    When I  download this output to an excel sheet , the colour filled in various cells disappears.
    Can someone let me know that , is it possible to retain this colour of the cell even after ALV download to an excel sheet?
    Thanks in Advance !!!

    Hi retwika
    I had searched on this previously and found out the following code,for download a report to excel with format (border, color cell, etc) 
    REPORT ZSIRI NO STANDARD PAGE HEADING.
    * this report demonstrates how to send some ABAP data to an
    * EXCEL sheet using OLE automation.
    INCLUDE OLE2INCL.
    * handles for OLE objects
    DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
          H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
          H_MAP TYPE OLE2_OBJECT,          " workbook
          H_ZL TYPE OLE2_OBJECT,           " cell
          H_F TYPE OLE2_OBJECT.            " font
    TABLES: SPFLI.
    DATA  H TYPE I.
    * table of flights
    DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
    *&   Event START-OF-SELECTION
    START-OF-SELECTION.
    * read flights
      SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
    * display header
      ULINE (61).
      WRITE: /     SY-VLINE NO-GAP,
              (3)  'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (4)  'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (8)  'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
      ULINE /(61).
    * display flights
      LOOP AT IT_SPFLI.
      WRITE: / SY-VLINE NO-GAP,
               IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
      ENDLOOP.
      ULINE /(61).
    * tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
    *           PERCENTAGE = 0
               TEXT       = TEXT-007
           EXCEPTIONS
                OTHERS     = 1.
    * start Excel
      CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
    *  PERFORM ERR_HDL.
      SET PROPERTY OF H_EXCEL  'Visible' = 1.
    *  CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
    *  PERFORM ERR_HDL.
    * tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
    *           PERCENTAGE = 0
               TEXT       = TEXT-008
           EXCEPTIONS
                OTHERS     = 1.
    * get list of workbooks, initially empty
      CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      PERFORM ERR_HDL.
    * add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP.
      PERFORM ERR_HDL.
    * tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
    *           PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    * output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    * copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    * changes by Kishore  - start
    *  CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    * add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP  EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    * tell user what is going on
      SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
    *           PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    * output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    * copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    * changes by Kishore  - end
    * disconnect from Excel
    *      CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING  #1 = 'C:\SKV.XLS'.
      FREE OBJECT H_EXCEL.
      PERFORM ERR_HDL.
    *       FORM FILL_CELL                                                *
    *       sets cell at coordinates i,j to value val boldtype bold       *
    FORM FILL_CELL USING I J BOLD VAL.
      CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_ZL 'Value' = VAL .
      PERFORM ERR_HDL.
      GET PROPERTY OF H_ZL 'Font' = H_F.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_F 'Bold' = BOLD .
      PERFORM ERR_HDL.
    ENDFORM.
    *&      Form  ERR_HDL
    *       outputs OLE error if any                                       *
    *  -->  p1        text
    *  <--  p2        text
    FORM ERR_HDL.
    IF SY-SUBRC <> 0.
      WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
      STOP.
    ENDIF.
    ENDFORM.                    " ERR_HDL
    Look out the changes
    Revert if any prblem
    Thanks and Regards
    Srikanth.P

  • Hi iam getting the alv grid data in excel format but iam facing one problem

    hi iam getting the alv grid data in excel format but iam facing one problem ,
    i.e., i want it read only  but iam getting it in edit mode i use layout default in excel iam getting in xl directly but in edit mode but i need it in read only mode
    what i have to do for that  and bdy knows reply me i need it urgently.

    there's always edit-mode if you choose excel-inplace - but noone can modify/rewrite the data
    A.

  • Need to send ALV Report as an Excel sheet via Email

    Well , I need to Email an ALV Report as an Excel Sheet using my program. What do I need to do and how?
    Answers will be rewarded with points.
    Thanks

    Hi Manu,
    You can copy and paste the following codes and try to execute..
    Hope this will help you..
    note: dont forget to change 'SAPUSER' to your SAP user id.
    REPORT  yhn_test8                               .
    TYPE-POOLS: slis, slist, truxs.
    DATA t5         LIKE t005t OCCURS 0 WITH HEADER LINE.
    DATA fcat       TYPE slis_t_fieldcat_alv.
    DATA listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.
    DATA stack      TYPE slist_listlevel_stack WITH HEADER LINE.
    DATA ttxt       LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    PARAMETER p_alv   RADIOBUTTON GROUP a.
    PARAMETER p_excel RADIOBUTTON GROUP a.
    START-OF-SELECTION.
      SELECT * INTO TABLE t5
               FROM t005t
              WHERE spras = sy-langu.
      CLEAR : fcat, fcat[].
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'T005T'
        CHANGING
          ct_fieldcat            = fcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF p_alv = 'X'.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            it_fieldcat   = fcat
          TABLES
            t_outtab      = t5
          EXCEPTIONS
            program_error = 1
            OTHERS        = 2.
        IF sy-subrc <> 0.
        ENDIF.
      ELSEIF p_excel = 'X'.
        CALL FUNCTION 'LIST_FREE_MEMORY'.
        SUBMIT yhn_test8 EXPORTING LIST TO MEMORY AND RETURN.
        CALL FUNCTION 'LIST_FROM_MEMORY'
          TABLES
            listobject = listobject
          EXCEPTIONS
            not_found  = 1
            OTHERS     = 2.
        IF sy-subrc = 0.
        Generate LIST for excel file
          CALL FUNCTION 'LIST_TO_TXT'
            TABLES
              listtxt            = ttxt
              listobject         = listobject
            EXCEPTIONS
              empty_list         = 1
              list_index_invalid = 2
              OTHERS             = 3.
          IF sy-subrc = 0.
            LOOP AT ttxt.
              REPLACE ALL OCCURRENCES OF '|' IN ttxt-line
                      WITH cl_abap_char_utilities=>horizontal_tab.
              MODIFY ttxt.
            ENDLOOP.
            PERFORM send_email.
          ENDIF.
        ENDIF.
      ENDIF.
    *&      Form  send_email
    FORM send_email .
      DATA docs LIKE docs OCCURS 0 WITH HEADER LINE.
      DATA excelsize TYPE i.
      DATA excel LIKE solisti1   OCCURS 0 WITH HEADER LINE.
      DATA doc LIKE sodocchgi1.
      DATA excelln TYPE i.
      DATA int_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
      DATA int_objhead LIKE solisti1   OCCURS 2 WITH HEADER LINE.
      DATA int_objtext LIKE solisti1   OCCURS 0 WITH HEADER LINE.
      DATA int_reclist LIKE somlreci1  OCCURS 1 WITH HEADER LINE.
      DATA bodyln LIKE sy-tabix.
      DATA output_data TYPE ssfcrescl.
      excel[] = ttxt[].
    excel table sizes
      DESCRIBE TABLE excel LINES excelln.
    Body Email
      int_objtext-line = 'Test Body'.
      APPEND int_objtext.
      DESCRIBE TABLE int_objtext LINES bodyln.
      READ     TABLE int_objtext INDEX bodyln.
      CLEAR doc.
      doc-doc_size   = ( bodyln - 1 ) * 255 + STRLEN( int_objtext ).
      doc-obj_name   = ' '.
      doc-sensitivty = 'P'.
      doc-proc_syst  = sy-sysid.
      doc-proc_clint = sy-mandt.
      CLEAR: int_objpack, int_objpack[].
      int_objpack-transf_bin = ' '.
      int_objpack-head_start = 1.
      int_objpack-head_num   = 0.
      int_objpack-body_start = 1.
      int_objpack-body_num   = bodyln.
      int_objpack-doc_type   = 'RAW'.
      int_objpack-obj_descr  = 'Test'.
      APPEND int_objpack.
      CLEAR: int_objhead, int_objhead[].
      int_objhead            = 'Attachment'.
      APPEND int_objhead.
      int_objpack-transf_bin = 'X'.
      int_objpack-head_start = 1.
      int_objpack-head_num   = 0.
      int_objpack-body_start = 1.
      int_objpack-body_num   = excelln.
      int_objpack-doc_size   = excelsize.
      int_objpack-doc_type   = 'XLS'.
      int_objpack-obj_name   = 'excel'.
      int_objpack-obj_descr  = 'test.xls'. "File name
      APPEND int_objpack.
      Set Receiver
      int_reclist-receiver   = 'SAPUSER'.
      int_reclist-rec_type   = 'B'.
      int_reclist-notif_del  = 'X'.
      int_reclist-notif_read = 'X'.
      int_reclist-notif_ndel = 'X'.
      int_reclist-express    = 'X'.
      APPEND int_reclist.
      doc-obj_descr = 'Report in Excel'.
      Sending Email
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = doc
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = int_objpack
          object_header              = int_objhead
          contents_bin               = excel
          contents_txt               = int_objtext   "Body
          receivers                  = int_reclist
        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.
    ENDFORM.                    " send_email

  • How to  send ALV output data into Excel sheet format via Mail to the user?

    Hi friends,
    I have a doubt ie,
    How to  send ALV output data into Excel sheet format via Mail to the user?
    regards
    Moosa

    Hi,
    Provide the output internal table to the objbin in the below FM
    Send Message
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                document_data              = i_docdata
                put_in_outbox              = c_x
           TABLES
                packing_list               = i_objpack
                object_header              = i_objhead
                contents_bin               = i_objbin
                contents_txt               = i_objtxt
                receivers                  = i_reclist
    and specify the document type
      i_objpack-doc_type   = 'XLS'.
    and try.
    Regards,
    Nandha

  • Passwort protected Excel sheet

    Is there any hack to open a passwort protected excel sheet?
    Numbers reports that the excel file is encrypted.

    Hello
    As the OP asked upon Numbers, I assumed that he wasn't owning XL.
    At this time I didn't find a XL unlocker app running under MacOS.
    So it will continue to be unable to import it
    Yvan KOENIG (from FRANCE samedi 19 janvier 2008 11:09:34)

  • Password Protected Excel Sheet

    Hi all,
    Please specify how to save Password Protected Excel Sheet using SAP.
    Thanks and Regards,
    Surya.

    Please, just check this forum reply:
    Make excel sheet password protected through ABAP codeu0085
    Check FM:MS_excel_download_*
    Arjun..
    Pl. reward points

  • How to write to a password protected excel sheet using ActiveX?

    Hi all,
    I would like to write to a protected Excel sheet. I protect the sheet just in case the data is not wrongly programmatically saved to other cells. These cells contained formulas.
    Please help.
    Thanks,
    keng

    Hi Randy,
    Thank you for looking into my problem.
    I have looked into the Workbook.open property node. There is "password" on the property node. Please see attached diagrams.
    Is is the right way to do it?
    Please advise further.
    For your information, the Excel workbook and sheet 1 are password protected.
    Thanks,
    keng
    Attachments:
    Password_Excel.jpg ‏37 KB
    Password_Sheet.jpg ‏23 KB

  • Save ALV grid to local excel-file in background

    Hi,
    i want to save a alv grid to an excel-file on a local fileshare using an background job..
    Does anybody know how this works?
    Thanks ahead

    DATA: file TYPE string VALUE `flights.dat`,
          wa   TYPE spfli.
    FIELD-SYMBOLS TYPE x.
    OPEN DATASET file FOR OUTPUT IN BINARY MODE.
    SELECT *
           FROM spfli
           INTO wa.
      ASSIGN wa TO CASTING.
      TRANSFER TO file.
    ENDSELECT.
    CLOSE DATASET file.
    <b>The binary data from database table SPFLI is transferred to a binary file flights.dat</b>

Maybe you are looking for

  • Prepared Statement with "INTERVAL ? DAY" clause

    Hi, I am having problems when using a INTERVAL ? DAY clause in a preparedStatement in Oracle 8i with the classes12.zip jdbc driver. The code following code: String sql1 = "select from my_table where created_ts > SYSDATE - INTERVAL '10' DAY"; String s

  • Travel Management Tables - PTRV_SREC  & PRTV_ROT_AWKEY

    Hi SAP'ers, We have a situation where we want to see the full receipt history of our expense postings for travel.  Unfortunately PTRV_SREC only shows "final" history and not what may have happened to the receipt from the beginning.  Here's the scenar

  • Removing text frames from rdf export format

    After a report has been exported in rdf format, can anyone tell me if there is a way to remove the text frames from the document, so that the formating is retained but by using word's tabs etc. Our client needs to manually add sections to the documen

  • Problems with Ant when using JDK1.4

    Hi, I am currently trying to convince JDeveloper (9.0.3.10.35) to use jdk1.4 for building and executing my project. Now, using the IDE for building and execution everything seems to work fine after switching to the new J2SE Version in the project set

  • How can I open my .cwk files on my new iMac OS 10.8?

    How can I open my .cwk files on my new iMac OS 10.8?