To download alv output to two excel sheets because of large data

Hi all,
I want to download alv output to excel sheet,I know how to do,but the no of record is very large and can not be accomodated in one sheet.
can anyone please tell how to download it into two sheets or some other way.
I want excel format only.
Regards,
sudha

hi sudha yadav,
right now i am working on the same issue.
what right i am doing is that,
i want to download an internal table it is containing more than 2 lakhs records but excel can accomidate 60000 records, so
before call gui download i am sending first 60000 records into another internal table with same time, by using append statemen and indexs,
that new internal table i am downloading
again i am repeating the same thing by using sy-tabix,
finally i am creating more than one excel file
by using oops concepts we can also create in one excel file no of work sheets
but its lengthy process so i am right now creating no of excel files only
if it is useful , pls rewards points to this answer

Similar Messages

  • Download colored ALV output in to EXCEL sheet

    Hi ,
    I want to download colored ALV output to Excel sheet with color.
    one of the field in ALV is with 4 colors depending on condition.
    i am unable to download the color using download option(that field is comming with out color).
    Please help me by providing the solution.
    Thanks in advance.
    Regards
    sarath

    Hi Srini,
    thanks for the reply.
    i am using standard download function only.
    if i use download->local file->HTML Format only the font is appearing in colors.in case of spread sheet no color comming.
    but my requirement is to download into excel and  background also with color(green...) font in black like that.
    (exactly appearing in the ALV)
    Thanks
    sarath

  • Weird problem when downloading the output to an excel sheet

    Hi to all,
          when i download the list, output by an alv grid, i observe a weird problem..in the excel sheet the last digit (10th digit) of the first col. which is delivery no., is getting truncated...0001802563 is getting downloaded as 000180256..couldn't understand why...when i use conversion_exit fm, the values are not getting truncated and downloading correctly...curious to know what's gone wrong in this funcationality? thanks all
    cheers,
    Shankar. M.

    actually the problem is in the field catalog.if u can send me the code, i shall bug fix it for u.

  • Download alv output to an excel file

    Dear experts,
                    I am using oops alv if i click file download button if i select anything except <b>spread sheet</b> it gives a short dump . Downloaded values are correct i want to know how to save it as a local file also to resolve for other options.
    regards,
    balaji

    Hi Balaji,
    Refer this link (Very helpful): http://www.****************/Tutorials/ALV/ColoredOutput/Program.htm
    Multi-colored output of ALV in EXCEL
    There would be many situations where we need to highlight some of the records in bold or different color depending on some value. In this document, we showcase how this can be achieved. Look at the screenshot of an excel sheet with different colors and bold in some cells.
    Following is a demo program in achieving the same:
    Report ZMULTICOLOR_TEST 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
          h_c type ole2_object.            " color
    DATA: FILENAME LIKE RLGRAP-FILENAME.
    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.
    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 200 'Carrier id'(001).
      perform fill_cell using 1 2 1 200 'Connection id'(002).
      perform fill_cell using 1 3 1 200 'City from'(003).
      perform fill_cell using 1 4 1 200 'City to'(004).
      perform fill_cell using 1 5 1 200 'Dep. Time'(005).
      loop at it_spfli.
    copy flights to active EXCEL sheet
        h = sy-tabix + 1.
        if it_spfli-carrid cs 'AA'.
          perform fill_cell using h 1 0 000255000 it_spfli-carrid.
        elseif it_spfli-carrid cs 'AZ'.
          perform fill_cell using h 1 0 168000000 it_spfli-carrid.
        elseif it_spfli-carrid cs 'JL'.
          perform fill_cell using h 1 0 168168000 it_spfli-carrid.
        elseif it_spfli-carrid cs 'LH'.
          perform fill_cell using h 1 0 111111111 it_spfli-carrid.
        elseif it_spfli-carrid cs 'SQ'.
          perform fill_cell using h 1 0 100100100 it_spfli-carrid.
        else.
          perform fill_cell using h 1 0 000145000 it_spfli-carrid.
        endif.
        if it_spfli-connid lt 400.
          perform fill_cell using h 2 0 255000255 it_spfli-connid.
        elseif it_spfli-connid lt 800.
          perform fill_cell using h 2 0 077099088 it_spfli-connid.
        else.
          perform fill_cell using h 2 0 246156138 it_spfli-connid.
        endif.
        if it_spfli-cityfrom cp 'S*'.
          perform fill_cell using h 3 0 155155155 it_spfli-cityfrom.
        elseif it_spfli-cityfrom cp 'N*'.
          perform fill_cell using h 3 0 189111222 it_spfli-cityfrom.
        else.
          perform fill_cell using h 3 0 111230222 it_spfli-cityfrom.
        endif.
        if it_spfli-cityto cp 'S*'.
          perform fill_cell using h 4 0 200200200 it_spfli-cityto.
        elseif it_spfli-cityto cp 'N*'.
          perform fill_cell using h 4 0 000111222 it_spfli-cityto.
        else.
          perform fill_cell using h 4 0 130230230 it_spfli-cityto.
        endif.
        if it_spfli-deptime lt '020000'.
          perform fill_cell using h 5 0 145145145 it_spfli-deptime.
        elseif it_spfli-deptime lt '120000' .
          perform fill_cell using h 5 0 015215205 it_spfli-deptime.
        elseif it_spfli-deptime lt '180000' .
          perform fill_cell using h 5 0 000215205 it_spfli-deptime.
        else.
          perform fill_cell using h 5 0 115115105 it_spfli-deptime.
        endif.
      endloop.
    EXCEL FILENAME
      CONCATENATE SY-REPID '_' SY-DATUM6(2) '_' SY-DATUM4(2) '_'
                  SY-DATUM(4) '_' SY-UZEIT '.XLS' INTO FILENAME.
      CALL METHOD OF H_MAP 'SAVEAS' EXPORTING #1 = FILENAME.
      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 col 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.
      set property of h_f 'Color' = col.
      perform err_hdl.
    endform.                    "FILL_CELL
    *&      Form  ERR_HDL
          outputs OLE error if any                                       *
    -->  p1        text
    <--  p2        text
    form err_hdl.
      if sy-subrc <> 0.
        write: / 'OLE-Automation Error:'(010), sy-subrc.
        stop.
      endif.
    endform.                    " ERR_HDL
    Good Luck and thanks
    AK

  • How to Download ALV Output LOGO to Excel ?

    Hi
    I have Used the LOGO in ALV Output. Iam getting the LOGO through REUSE_ALV_GRID_DISPLAY. If i download the Data to Excel file, the LOGO is not coming. How to solve this problem.
    Thanks & Regards,
    N.L.

    Hi,
    I had a sample code wich will insert LOGO from PRESENTATION server into excel / word.
    TYPE-POOLS ole2.
    DATA:
    o_word           TYPE ole2_object,
      excel           TYPE ole2_object,
      o_documents     TYPE ole2_object,
      o_actdoc        TYPE ole2_object,
      o_inlineshapes  TYPE ole2_object,
      o_logo          TYPE ole2_object,
      WORKBOOK        TYPE ole2_object.
    *CREATE OBJECT o_word 'Word.Application'.
    CREATE OBJECT EXCEL 'Excel.Application'.
    *FREE OBJECT EXCEL.
    *SET PROPERTY OF o_word 'Visible' = '1'.
    SET PROPERTY OF excel 'Visible' = '1'.
    *GET PROPERTY OF o_word 'Documents' = o_documents.
    GET PROPERTY OF excel 'Documents' = o_documents.
    CALL METHOD OF o_documents 'Add'   = o_actdoc.
    CALL METHOD OF EXCEL 'WORKBOOKS' = WORKBOOK.
    GET PROPERTY OF o_actdoc 'InlineShapes' = o_inlineshapes.
    CALL METHOD OF o_inlineshapes 'AddPicture' = o_logo
      EXPORTING
      #1 = 'C:\Temp\OTHERS\Scrap\COMPANY_LOGO.BMP'
      #2 = 0
      #3 = 1.
    WRITE: / 'Test'.
    Let us see if some one will come out with good idea/Example.
    Thanks.

  • 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

  • Download ALV output to excel with formatting

    Hi All,
    i want to download ALV output to excel sheet and the uneditable fields in ALV oputput should be locked (uneditable) in excel also.
    Can you please tell me approach to achieve this functionality?
    Thanks in advance.

    Thanks Vamsi. Your Suggestion was helpful.
    I have used excel integration and used SET PROPERTY OF (COLUMN) 'LOCKED' = 1.
    For more details refer below mentioned link.
    http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B(Password%2Bprotected)%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in (http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B%28Password%2Bprotected%29%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in

  • Problem in downloading ALV output in excel

    Dear Abapers,
                           I am facing a problem while downloading alv output in spreadsheet. Report headers and data headings are coming in excle but contents are missing instead of that No Data is displaying on excel sheet. I have debug that and observed the deep structure name T_OUTTAB using by the FM ALV_DATA_EXPORT is empty, It should contain the contents of my output data.
    Below I am giving my code. 
    ***********************************************declaration****************
          BEGIN OF d_file_out,
            index           TYPE i,                      "Index no
            msg             TYPE string,              "Message
            msgtyp(1)       TYPE c,                 "Message type
           END OF d_file_out,
    DATA:t_file_out       TYPE TABLE OF d_file_out.
    DATA:wa_file_out          TYPE d_file_out.
    Display Error Logs
    PERFORM display_logs USING text-006.
    FORM display_logs USING p_text TYPE string.
      CONSTANTS:  c_count    TYPE char5 VALUE 'INDEX',
                  c_mestyp   TYPE char6 VALUE 'MSG',
                  c_message  TYPE char7 VALUE 'MSGTYP'.
    *Field catalog
      PERFORM: z_field_catalog USING c_count   text-010,  "Record number
               z_field_catalog USING c_mestyp  text-011,  "Message type
               z_field_catalog USING c_message text-012.  "Message
    *Top of page event
      PERFORM z_event USING t_events.
    wa_layout-colwidth_optimize = c_x.
    ALV grid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
         i_buffer_active          = 'X'
           i_callback_program = sy-repid
         is_layout          = wa_layout
         I_STRUCTURE_NAME   = wa_file_out
          it_fieldcat        = t_field
          it_events          = t_events
        TABLES
          t_outtab           = t_file_out
        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.
    ***********************************Fieldcatalog**********************************************
    FORM z_field_catalog USING p_field TYPE any
                                                p_name  TYPE any.
      wa_field-fieldname = p_field.
      wa_field-seltext_l = p_name.
      IF p_field = 'INDEX'.
        wa_field-outputlen = '14'.
        wa_field-col_pos = 1.
      ELSEIF p_field = 'MSG'.
        wa_field-outputlen = '120'.
        wa_field-col_pos = 2.
      ELSEIF p_field = 'MSGTYP'.
        wa_field-outputlen = '08'.
        wa_field-col_pos = 3.
      ENDIF.
      APPEND wa_field TO t_field.
      CLEAR wa_field.
    ENDFORM. 
    Here I have given my code, which contain the building of field catalog and Calling ALV Grid. I have already checked the excel micros settings. Other programs are working fine on my system and downloading in excel is also working.
    Hope to get reply soon.
    Regards,
    Himanshu

    Hi ,
    use this to down load to xcel
    v_file = lv_file.
      DATA:  BEGIN OF s_head OCCURS 0,
             head(40) TYPE c ,
             END OF s_head.
      s_head-head = text-015."'Sales price'.   * for header
      APPEND s_head.
      s_head-head = text-016."'Purchase price'.   * for header
      APPEND s_head.
      s_head-head = text-017."'Listing Procedure'.   * for header
      APPEND s_head.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_file
         filetype                        = 'ASC'
         write_field_separator           = '#'
        TABLES
          data_tab                        = it_output1[]
          fieldnames                      = s_head[]
       EXCEPTIONS
         file_write_error                = 1
         no_batch                        = 2
         gui_refuse_filetransfer         = 3
         invalid_type                    = 4
         no_authority                    = 5
         unknown_error                   = 6
         header_not_allowed              = 7
         separator_not_allowed           = 8
         filesize_not_allowed            = 9
         header_too_long                 = 10
         dp_error_create                 = 11
         dp_error_send                   = 12
         dp_error_write                  = 13
         unknown_dp_error                = 14
         access_denied                   = 15
         dp_out_of_memory                = 16
         disk_full                       = 17
         dp_timeout                      = 18
         file_not_found                  = 19
         dataprovider_exception          = 20
         control_flush_error             = 21
         OTHERS                          = 22
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • Output transport to excel sheet

    Dear Friends,
    One problem facing in SD report.
    Report contain 61 column in ALV.
    At runtime it will fetch 30000 to 32000 rows.
    When i convert this report into excel format.
    It will store data in excel sheet with one line blank between
    two record.
    Means, If i have 30000 records then it will store 60000
    rows in excel sheet.
    It will leave one blank line after every record.
    Now problem is, if i have more then 32500  then it will not feet into excel sheet, because capacity of excel is 65000 rows.
    So, please provide me some solution.
    Regards,
    Nilay

    Hi Nilay,
    If it is Zreport then u can make the changes to the code. Delete all the blank rows from internal table that is being downloaded.
    If it is standard report then u can copy to Zreport and make the above change.
    Even in this case also at max u can download 65k+ records.
    If it is more than that then u have to split ur itab into multiple itabs and then By using OLE concepts u can download to multiple sheets of same excel.
    Thanks,
    Vinod.

  • Output to an excel sheet

    Hi all,
    How do we send the 1)script output 2)ALV report output to an excel sheet
    please expedite
    thanks

    Hi arun,
    Check the below example, to download the ALV report output to an excel sheet.
    REPORT Z_CONCEPTALV .
    TABLES: KNA1,VBAK.
    DATA: ITAB TYPE TABLE OF VBAK,
          CONTAINER TYPE SCRFNAME VALUE 'ALVCONTROL',
          CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          GRID TYPE REF TO CL_GUI_ALV_GRID,
          L_CONTAINER TYPE SCRFNAME VALUE 'LOGO',
          I_PARENT TYPE REF TO CL_GUI_CONTAINER,
          L_CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          TREE TYPE REF TO CL_GUI_ALV_TREE_SIMPLE,
          LT_LIST_COMMENTARY TYPE SLIS_T_LISTHEADER,
          L_LOGO TYPE SDYDO_VALUE.
    DATA: OK_CODE(4).
    CALL SCREEN 1100.
    *&      Module  STATUS_1100  OUTPUT
          text
    MODULE STATUS_1100 OUTPUT.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    CASE OK_CODE.
    WHEN 'DISP'.
    SELECT * FROM VBAK INTO TABLE ITAB WHERE KUNNR = KNA1-KUNNR.
    IF CUST IS INITIAL.
    CREATE OBJECT CUST EXPORTING CONTAINER_NAME = CONTAINER.
    CREATE OBJECT GRID EXPORTING I_PARENT = CUST.
    CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING I_STRUCTURE_NAME
    = 'VBAK' CHANGING IT_OUTTAB = ITAB.
    ENDIF.
    IF L_CUST IS INITIAL.
    CREATE OBJECT L_CUST EXPORTING CONTAINER_NAME = L_CONTAINER.
    CREATE OBJECT TREE EXPORTING I_PARENT = L_CUST.
    PERFORM BUILD_COMMENT USING LT_LIST_COMMENTARY.
    CALL METHOD TREE->CREATE_REPORT_HEADER EXPORTING IT_LIST_COMMENTARY =
    LT_LIST_COMMENTARY I_LOGO = L_LOGO.
    ENDIF.
    WHEN 'DOWN'.
    PERFORM F_DOWNLOAD_TO_EXCEL.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    ENDCASE.
    ENDMODULE.                 " STATUS_1100  OUTPUT
    FORM BUILD_COMMENT USING LT_LIST_COMMENTARY.
    L_LOGO = 'ENJOYSAP_LOGO'.
    ENDFORM.
    FORM F_DOWNLOAD_TO_EXCEL.
    CALL FUNCTION 'DOWNLOAD'
    EXPORTING
      BIN_FILESIZE                  = ' '
      CODEPAGE                      = ' '
       FILENAME                       = ' '
       FILETYPE                       = 'DAT'
      ITEM                          = ' '
      MODE                          = ' '
      WK1_N_FORMAT                  = ' '
      WK1_N_SIZE                    = ' '
      WK1_T_FORMAT                  = ' '
      WK1_T_SIZE                    = ' '
      FILEMASK_MASK                 = ' '
      FILEMASK_TEXT                 = ' '
      FILETYPE_NO_CHANGE            = ' '
      FILEMASK_ALL                  = ' '
      FILETYPE_NO_SHOW              = ' '
      SILENT                        = 'S'
      COL_SELECT                    = ' '
      COL_SELECTMASK                = ' '
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      ACT_FILENAME                  =
      ACT_FILETYPE                  =
      FILESIZE                      =
      CANCEL                        =
      TABLES
        DATA_TAB                      = ITAB
      FIELDNAMES                    =
    EXCEPTIONS
      INVALID_FILESIZE              = 1
      INVALID_TABLE_WIDTH           = 2
      INVALID_TYPE                  = 3
      NO_BATCH                      = 4
      UNKNOWN_ERROR                 = 5
      GUI_REFUSE_FILETRANSFER       = 6
      CUSTOMER_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.
    ENDFORM.

  • Download specific output fields to excel

    Hi All,
    We have a report program that downloads an excel file having about 60 output fields. The program has no ALV output.
    Everytime we do not require these 60 fields to be shown in output excel. we need specific output fields in excel and those specific fields could be dynamic.
    Is there any way to download specific output fields in excel as we do in ALV variant.
    In alv,  we can achieve this through a layout variant in selection screen and download the alv output in excel. But we dont require alv to download excel from there.
    Thanks,
    Srilakshmi.

    Hi
    Something like this:
    DATA: BEGIN OF t_layout OCCURS 0,
            mark      TYPE c,
            fieldname LIKE dd03l-fieldname,
          END  OF t_layout.
    TYPE-POOLS slis.
    DATA: gt_fieldcat TYPE  slis_t_fieldcat_alv WITH HEADER LINE.
    DATA: lt_report TYPE sy-repid.
    DO 60 TIMES.
      t_layout-fieldname = 'Field'.
      MOVE sy-index TO t_layout-fieldname+6.
      APPEND t_layout.
    ENDDO.
    lt_report = sy-repid.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
        i_program_name     = lt_report
        i_internal_tabname = 'T_LAYOUT'
        i_inclname         = lt_report
      CHANGING
        ct_fieldcat        = gt_fieldcat[].
    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
      EXPORTING
        i_title              = 'Field List'
        i_zebra              = 'X'
        i_checkbox_fieldname = 'MARK'
        i_tabname            = 'T_LAYOUT'
        it_fieldcat          = gt_fieldcat[]
      TABLES
        t_outtab             = t_layout.
    LOOP AT t_layout WHERE mark = 'X'.
      WRITE: / t_layout-fieldname.
    ENDLOOP.
    Max

  • 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

  • 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

  • Procedure/sample code to download alv output in HTM format & mail to user.

    Hello Experts,
    I've a requirement to run the Alv report at background. But i need to download the alv output in HTM fomat because it has subtotal values & look wise downloaded HTM format will be same as that of ALV output. Then send the attachment through mail to users. I'm not intersted in  downloading  internal table dierctly to HTM format.
    Will the code for alv display & downloading in HTM format & forwarding via email  is all done in one single  program or in 2 differnt programs . pls guide me on this.
    I'm using FM REUSE_ALV_GRID_DISPLAY to display output with subtotals.
    Pls anyone there suggest me the steps to download ALV output in HTM format & the forward the same  to user ID through Lotus notes.
    Regards
    Devika.S

    Hi,
    This can be achieved without coding .
    Fore ground Scenario:
    1. Downloading as HTM . In foreground you can do this by using Export---> Local file
    option in ALV grid.
    Background Scenario:
    2. In background while sending mail , You have to achieve the same through customisation settings as wexplained below.
    In SM36 -- > Spool List Recipient, give the reciepient id and click on copy. Now when the Background job will be finished,
    the reciepient mentioned above will recieve the mail , but in ALI format.
    To convert the same to HTM format, you need to do customisation changes in SCOT
    goto SCOT>Expant the node INT>Double click on Email-->Beside Internet we have SET tab , click on that -->
    select the radio button " all formats except the following ">In the near by box type ALI>then click on the tick Mark.
    Then go to SCOT>Settings>Conversion Rules-->there
    create a new row with, Format->ALI , To Format->HTM , Ranking 1, FM -> SX_OBJECT_CONVERT_ALI_HTM.
    Now when the mail will be sent, it will not go in ALI, but in HTM format.
    Hope this helps you out.

  • Reg. ALV output transported into Excel

    Dear All,
                   when i transported my ALV report output to excel file , amount column is suppressed from decimal places .
    i.e. in excel file ,  decimal values of amount column is not shown in some amounts.
    Please provide some inputs
    Thanks & Regards
    shailesh

    Hi ,
    Check this [LINK|ALV List output to Excel file; for  ALV output transported into Excel.
    hope it will help you .
    Regards,
    Saravana.S

Maybe you are looking for

  • Automatic equipment creation at the time of GR of material - Subcontracting

    Dear Experts , I have created a non valuated material . I have created a serial number profile in which the setting is that the equipment is created automatically at the time of GR. I have attached the above serial number profile to the above materia

  • Please help with UIPickerView didSelectRow logic.

    Hello all, Im still a noob so forgive me if these are way off base. My app is coming along thanks to the help of Ray and others in this forum so thanks for that! I have a Q&A type app with 3 separate question formats, ie... Multiple Choice, True and

  • Aperture 3.5 Full Screen mode really buggy

    Let's try this again.... I'm looking for anyone else having this problems to see if they have found a work around. I have been having several intermittent problems with Aperture 3.5 in full screen mode with Mavericks. Most of the time, it's ok. But n

  • IPod playback position skips ahead after pause

    I listen to books and podcasts on my Nano. If I unplug the earbuds and then resume playback later on the position is about 15 seconds ahead of where I left off. Not good when listening to the mentioned audio files. Any suggestions on how to eliminate

  • Can my podcast be longer than an hour?

    I have been stringing together several mp3 files, on one track, to compose a podcast that contains all the different segments. Everything was going well until I hit the hour marker. There is a little purple triangle at the top of my timeline and the