<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ALV in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232252#M480384</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mani ,&lt;/P&gt;&lt;P&gt;                 After displaying in the records in ALV maintain a  Button in Appilcation Toolbar , for Excel write a Subroutine for that there are  below some function modules which can display in Excel sheet &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;YOu can use the GUI_DOWNLOAD function module.&lt;/P&gt;&lt;P&gt;Once you have the data in the internal table, you can either display it as a report or download it to the excel sheet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you only want to transfer the data to Excel like when you transfer the data from&lt;/P&gt;&lt;P&gt;ALV to Excel simply use the Function Modules:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XXL_SIMPLE_API&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want more modifications when you transfer it to Excel use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XXL_FULL_API&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Often we face situations where we need to download internal table contents onto an Excel sheet. We are familiar with the function module WS_DOWNLOAD. Though this function module downloads the contents onto the Excel sheet, there cannot be any column headings or we cannot differentiate the primary keys just by seeing the Excel sheet.&lt;/P&gt;&lt;P&gt;For this purpose, we can use the function module XXL_FULL_API. The Excel sheet which is generated by this function module contains the column headings and the key columns are highlighted with a different color. Other options that are available with this function module are we can swap two columns or supress a field from displaying on the Excel sheet. The simple code for the usage of this function module is given below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Program code : Run this code&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------" /&gt;&lt;P&gt;REPORT Excel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES:&lt;/P&gt;&lt;P&gt;sflight.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;header data................................&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA :&lt;/P&gt;&lt;P&gt;header1 LIKE gxxlt_p-text VALUE 'Suresh',&lt;/P&gt;&lt;P&gt;header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for holding the SFLIGHT data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_sflight OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE sflight.&lt;/P&gt;&lt;P&gt;DATA END OF t_sflight.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for holding the horizontal key.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_hkey OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_h.&lt;/P&gt;&lt;P&gt;DATA END OF t_hkey .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for holding the vertical key.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_vkey OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_v.&lt;/P&gt;&lt;P&gt;DATA END OF t_vkey .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for holding the online text....&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_online OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_o.&lt;/P&gt;&lt;P&gt;DATA END OF t_online.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table to hold print text.............&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_print OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_p.&lt;/P&gt;&lt;P&gt;DATA END OF t_print.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table to hold SEMA data..............&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_sema OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_s.&lt;/P&gt;&lt;P&gt;DATA END OF t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Retreiving data from sflight.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT * FROM sflight&lt;/P&gt;&lt;P&gt;INTO TABLE t_sflight.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Text which will be displayed online is declared here....&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;t_online-line_no = '1'.&lt;/P&gt;&lt;P&gt;t_online-info_name = 'Created by'.&lt;/P&gt;&lt;P&gt;t_online-info_value = 'KOTHUR SREEKANTH REDDY'.&lt;/P&gt;&lt;P&gt;APPEND t_online.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Text which will be printed out..........................&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;t_print-hf = 'H'.&lt;/P&gt;&lt;P&gt;t_print-lcr = 'L'.&lt;/P&gt;&lt;P&gt;t_print-line_no = '1'.&lt;/P&gt;&lt;P&gt;t_print-text = 'This is the header'.&lt;/P&gt;&lt;P&gt;APPEND t_print.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_print-hf = 'F'.&lt;/P&gt;&lt;P&gt;t_print-lcr = 'C'.&lt;/P&gt;&lt;P&gt;t_print-line_no = '1'.&lt;/P&gt;&lt;P&gt;t_print-text = 'This is the footer'.&lt;/P&gt;&lt;P&gt;APPEND t_print.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Defining the vertical key columns.......&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;t_vkey-col_no = '1'.&lt;/P&gt;&lt;P&gt;t_vkey-col_name = 'MANDT'.&lt;/P&gt;&lt;P&gt;APPEND t_vkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_vkey-col_no = '2'.&lt;/P&gt;&lt;P&gt;t_vkey-col_name = 'CARRID'.&lt;/P&gt;&lt;P&gt;APPEND t_vkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_vkey-col_no = '3'.&lt;/P&gt;&lt;P&gt;t_vkey-col_name = 'CONNID'.&lt;/P&gt;&lt;P&gt;APPEND t_vkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_vkey-col_no = '4'.&lt;/P&gt;&lt;P&gt;t_vkey-col_name = 'FLDATE'.&lt;/P&gt;&lt;P&gt;APPEND t_vkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Header text for the data columns................&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-row_no = '1'.&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 1.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'PRICE'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 2.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'CURRENCY'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 3.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'PLANETYPE'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 4.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'SEATSMAX'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 5.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'SEATSOCC'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 6.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'PAYMENTSUM'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;populating the SEMA data..........................&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;t_sema-col_no = 1.&lt;/P&gt;&lt;P&gt;t_sema-col_typ = 'STR'.&lt;/P&gt;&lt;P&gt;t_sema-col_ops = 'DFT'.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 2.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 3.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 4.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 5.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 6.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 7.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 8.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 9.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 10.&lt;/P&gt;&lt;P&gt;t_sema-col_typ = 'NUM'.&lt;/P&gt;&lt;P&gt;t_sema-col_ops = 'ADD'.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'XXL_FULL_API'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;DATA_ENDING_AT = 54&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;DATA_STARTING_AT = 5&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;filename = 'TESTFILE'&lt;/P&gt;&lt;P&gt;header_1 = header1&lt;/P&gt;&lt;P&gt;header_2 = header2&lt;/P&gt;&lt;P&gt;no_dialog = 'X'&lt;/P&gt;&lt;P&gt;no_start = ' '&lt;/P&gt;&lt;P&gt;n_att_cols = 6&lt;/P&gt;&lt;P&gt;n_hrz_keys = 1&lt;/P&gt;&lt;P&gt;n_vrt_keys = 4&lt;/P&gt;&lt;P&gt;sema_type = 'X'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;SO_TITLE = ' '&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;data = t_sflight&lt;/P&gt;&lt;P&gt;hkey = t_hkey&lt;/P&gt;&lt;P&gt;online_text = t_online&lt;/P&gt;&lt;P&gt;print_text = t_print&lt;/P&gt;&lt;P&gt;sema = t_sema&lt;/P&gt;&lt;P&gt;vkey = t_vkey&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;cancelled_by_user = 1&lt;/P&gt;&lt;P&gt;data_too_big = 2&lt;/P&gt;&lt;P&gt;dim_mismatch_data = 3&lt;/P&gt;&lt;P&gt;dim_mismatch_sema = 4&lt;/P&gt;&lt;P&gt;dim_mismatch_vkey = 5&lt;/P&gt;&lt;P&gt;error_in_hkey = 6&lt;/P&gt;&lt;P&gt;error_in_sema = 7&lt;/P&gt;&lt;P&gt;file_open_error = 8&lt;/P&gt;&lt;P&gt;file_write_error = 9&lt;/P&gt;&lt;P&gt;inv_data_range = 10&lt;/P&gt;&lt;P&gt;inv_winsys = 11&lt;/P&gt;&lt;P&gt;inv_xxl = 12&lt;/P&gt;&lt;P&gt;OTHERS = 13&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/P&gt;&lt;P&gt;WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regsrds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;navjot&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use this method to download the contents of an internal table to an excel file.&lt;/P&gt;&lt;P&gt;It is a static method of the class cl_gui_frontend_services. So you dont need an instance to call it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just make sure the file name has an extension .xls&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call method cl_gui_frontend_services=&amp;gt;gui_download&lt;/P&gt;&lt;P&gt;exporting&lt;/P&gt;&lt;P&gt;filename = gv_file_name&lt;/P&gt;&lt;P&gt;filetype = lv_file_type&lt;/P&gt;&lt;P&gt;confirm_overwrite = space&lt;/P&gt;&lt;P&gt;changing&lt;/P&gt;&lt;P&gt;data_tab = &amp;lt;fs_download&amp;gt;&lt;/P&gt;&lt;P&gt;exceptions&lt;/P&gt;&lt;P&gt;file_write_error = 1&lt;/P&gt;&lt;P&gt;no_batch = 2&lt;/P&gt;&lt;P&gt;gui_refuse_filetransfer = 3&lt;/P&gt;&lt;P&gt;invalid_type = 4&lt;/P&gt;&lt;P&gt;no_authority = 5&lt;/P&gt;&lt;P&gt;unknown_error = 6&lt;/P&gt;&lt;P&gt;header_not_allowed = 7&lt;/P&gt;&lt;P&gt;separator_not_allowed = 8&lt;/P&gt;&lt;P&gt;filesize_not_allowed = 9&lt;/P&gt;&lt;P&gt;header_too_long = 10&lt;/P&gt;&lt;P&gt;dp_error_create = 11&lt;/P&gt;&lt;P&gt;dp_error_send = 12&lt;/P&gt;&lt;P&gt;dp_error_write = 13&lt;/P&gt;&lt;P&gt;unknown_dp_error = 14&lt;/P&gt;&lt;P&gt;access_denied = 15&lt;/P&gt;&lt;P&gt;dp_out_of_memory = 16&lt;/P&gt;&lt;P&gt;disk_full = 17&lt;/P&gt;&lt;P&gt;dp_timeout = 18&lt;/P&gt;&lt;P&gt;file_not_found = 19&lt;/P&gt;&lt;P&gt;dataprovider_exception = 20&lt;/P&gt;&lt;P&gt;control_flush_error = 21&lt;/P&gt;&lt;P&gt;not_supported_by_gui = 22&lt;/P&gt;&lt;P&gt;error_no_gui = 23&lt;/P&gt;&lt;P&gt;others = 24.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Bhaskar Rao.M&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 May 2007 03:51:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-07T03:51:34Z</dc:date>
    <item>
      <title>ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232250#M480382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Friends&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We need to display 150 fields in ALV &amp;amp; Export all the fields into excel. We know that it's not possible using ALV Grid. To achieve the same using ALV Container (Class &amp;amp; Objects).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please Tel Me&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Advance thanks&lt;/P&gt;&lt;P&gt;ManiR&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 03:27:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232250#M480382</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T03:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232251#M480383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This sample program using container would help you.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Create a container in SE51-&amp;gt;layout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: GI_SFLIGHT TYPE STANDARD TABLE OF SFLIGHT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: OK_CODE LIKE SY-UCOMM,&lt;/P&gt;&lt;P&gt;      G_WA_SFLIGHT LIKE SFLIGHT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Declare reference variables to the ALV grid and the container&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;  GO_GRID             TYPE REF TO CL_GUI_ALV_GRID,&lt;/P&gt;&lt;P&gt;  GO_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;  CALL SCREEN '100'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  STATUS_0100  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE STATUS_0100 OUTPUT.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; SET PF-STATUS 'xxxxxxxx'.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; SET TITLEBAR 'xxx'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  IF GO_CUSTOM_CONTAINER IS INITIAL.&lt;/P&gt;&lt;P&gt;    CREATE OBJECT GO_CUSTOM_CONTAINER&lt;/P&gt;&lt;P&gt;      EXPORTING CONTAINER_NAME = 'ALV_CONTAINER'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CREATE OBJECT GO_GRID&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;P&gt;        I_PARENT = GO_CUSTOM_CONTAINER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    PERFORM LOAD_DATA_INTO_GRID.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDMODULE.                 " STATUS_0100  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  load_data_into_grid&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM LOAD_DATA_INTO_GRID .&lt;/P&gt;&lt;P&gt;  DATA:&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  For parameter IS_VARIANT&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      L_LAYOUT TYPE DISVARIANT,&lt;/P&gt;&lt;P&gt;  GS_LAYOUT TYPE LVC_S_LAYO.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Load data into the grid and display them&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  L_LAYOUT-REPORT = SY-REPID.&lt;/P&gt;&lt;P&gt;  GS_LAYOUT-GRID_TITLE = 'ZAMIT_FLIGHTS'.&lt;/P&gt;&lt;P&gt;  GS_LAYOUT-SEL_MODE = 'A'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT *&lt;/P&gt;&lt;P&gt;   FROM ZSFLIGHT&lt;/P&gt;&lt;P&gt;   INTO TABLE GI_SFLIGHT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL METHOD GO_GRID-&amp;gt;SET_TABLE_FOR_FIRST_DISPLAY&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      I_STRUCTURE_NAME = 'SFLIGHT'&lt;/P&gt;&lt;P&gt;      IS_LAYOUT        = GS_LAYOUT&lt;/P&gt;&lt;P&gt;      IS_VARIANT       = L_LAYOUT&lt;/P&gt;&lt;P&gt;      I_SAVE           = 'A'&lt;/P&gt;&lt;P&gt;    CHANGING&lt;/P&gt;&lt;P&gt;      IT_OUTTAB        = GI_SFLIGHT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " load_data_into_grid&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  USER_COMMAND_0100  INPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE USER_COMMAND_0100 INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA:&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for indexes of selected rows&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  GI_INDEX_ROWS TYPE LVC_T_ROW,&lt;/P&gt;&lt;P&gt;  L_LINES TYPE I,&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Information about 1 row&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  G_SELECTED_ROW LIKE LVC_S_ROW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CASE SY-UCOMM.&lt;/P&gt;&lt;P&gt;    WHEN 'EXIT'.&lt;/P&gt;&lt;P&gt;      LEAVE TO SCREEN 0.&lt;/P&gt;&lt;P&gt;    WHEN 'NL'.&lt;/P&gt;&lt;P&gt;      CALL METHOD GO_GRID-&amp;gt;GET_SELECTED_ROWS&lt;/P&gt;&lt;P&gt;        IMPORTING&lt;/P&gt;&lt;P&gt;          ET_INDEX_ROWS = GI_INDEX_ROWS.&lt;/P&gt;&lt;P&gt;      DESCRIBE TABLE GI_INDEX_ROWS LINES L_LINES.&lt;/P&gt;&lt;P&gt;      IF L_LINES = 0.&lt;/P&gt;&lt;P&gt;        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'&lt;/P&gt;&lt;P&gt;          EXPORTING&lt;/P&gt;&lt;P&gt;            TEXTLINE1 =&lt;/P&gt;&lt;P&gt;            'You must choose atleast one line to do the action'.&lt;/P&gt;&lt;P&gt;        EXIT.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LOOP AT GI_INDEX_ROWS INTO G_SELECTED_ROW.&lt;/P&gt;&lt;P&gt;        G_SELECTED_ROW-INDEX = G_SELECTED_ROW-INDEX + 1.&lt;/P&gt;&lt;P&gt;        MODIFY GI_INDEX_ROWS INDEX SY-TABIX FROM G_SELECTED_ROW&lt;/P&gt;&lt;P&gt;        TRANSPORTING INDEX.&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     LOOP AT GI_INDEX_ROWS INTO G_SELECTED_ROW.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       READ TABLE GI_SFLIGHT INDEX G_SELECTED_ROW-INDEX INTO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       G_WA_SFLIGHT.&lt;/P&gt;&lt;/LI&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;   ENDIF.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     ENDLOOP.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      DESCRIBE TABLE GI_INDEX_ROWS LINES L_LINES.&lt;/P&gt;&lt;P&gt;      IF L_LINES &amp;gt; 0.&lt;/P&gt;&lt;P&gt;        CALL METHOD GO_GRID-&amp;gt;SET_SELECTED_ROWS&lt;/P&gt;&lt;P&gt;          EXPORTING&lt;/P&gt;&lt;P&gt;            IT_INDEX_ROWS = GI_INDEX_ROWS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;  ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDMODULE.                 " USER_COMMAND_0100  INPUT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*reward points if useful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 03:37:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232251#M480383</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T03:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232252#M480384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mani ,&lt;/P&gt;&lt;P&gt;                 After displaying in the records in ALV maintain a  Button in Appilcation Toolbar , for Excel write a Subroutine for that there are  below some function modules which can display in Excel sheet &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;YOu can use the GUI_DOWNLOAD function module.&lt;/P&gt;&lt;P&gt;Once you have the data in the internal table, you can either display it as a report or download it to the excel sheet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you only want to transfer the data to Excel like when you transfer the data from&lt;/P&gt;&lt;P&gt;ALV to Excel simply use the Function Modules:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XXL_SIMPLE_API&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want more modifications when you transfer it to Excel use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XXL_FULL_API&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Often we face situations where we need to download internal table contents onto an Excel sheet. We are familiar with the function module WS_DOWNLOAD. Though this function module downloads the contents onto the Excel sheet, there cannot be any column headings or we cannot differentiate the primary keys just by seeing the Excel sheet.&lt;/P&gt;&lt;P&gt;For this purpose, we can use the function module XXL_FULL_API. The Excel sheet which is generated by this function module contains the column headings and the key columns are highlighted with a different color. Other options that are available with this function module are we can swap two columns or supress a field from displaying on the Excel sheet. The simple code for the usage of this function module is given below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Program code : Run this code&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------" /&gt;&lt;P&gt;REPORT Excel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES:&lt;/P&gt;&lt;P&gt;sflight.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;header data................................&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA :&lt;/P&gt;&lt;P&gt;header1 LIKE gxxlt_p-text VALUE 'Suresh',&lt;/P&gt;&lt;P&gt;header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for holding the SFLIGHT data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_sflight OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE sflight.&lt;/P&gt;&lt;P&gt;DATA END OF t_sflight.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for holding the horizontal key.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_hkey OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_h.&lt;/P&gt;&lt;P&gt;DATA END OF t_hkey .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for holding the vertical key.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_vkey OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_v.&lt;/P&gt;&lt;P&gt;DATA END OF t_vkey .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for holding the online text....&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_online OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_o.&lt;/P&gt;&lt;P&gt;DATA END OF t_online.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table to hold print text.............&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_print OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_p.&lt;/P&gt;&lt;P&gt;DATA END OF t_print.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table to hold SEMA data..............&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA BEGIN OF t_sema OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE gxxlt_s.&lt;/P&gt;&lt;P&gt;DATA END OF t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Retreiving data from sflight.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT * FROM sflight&lt;/P&gt;&lt;P&gt;INTO TABLE t_sflight.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Text which will be displayed online is declared here....&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;t_online-line_no = '1'.&lt;/P&gt;&lt;P&gt;t_online-info_name = 'Created by'.&lt;/P&gt;&lt;P&gt;t_online-info_value = 'KOTHUR SREEKANTH REDDY'.&lt;/P&gt;&lt;P&gt;APPEND t_online.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Text which will be printed out..........................&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;t_print-hf = 'H'.&lt;/P&gt;&lt;P&gt;t_print-lcr = 'L'.&lt;/P&gt;&lt;P&gt;t_print-line_no = '1'.&lt;/P&gt;&lt;P&gt;t_print-text = 'This is the header'.&lt;/P&gt;&lt;P&gt;APPEND t_print.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_print-hf = 'F'.&lt;/P&gt;&lt;P&gt;t_print-lcr = 'C'.&lt;/P&gt;&lt;P&gt;t_print-line_no = '1'.&lt;/P&gt;&lt;P&gt;t_print-text = 'This is the footer'.&lt;/P&gt;&lt;P&gt;APPEND t_print.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Defining the vertical key columns.......&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;t_vkey-col_no = '1'.&lt;/P&gt;&lt;P&gt;t_vkey-col_name = 'MANDT'.&lt;/P&gt;&lt;P&gt;APPEND t_vkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_vkey-col_no = '2'.&lt;/P&gt;&lt;P&gt;t_vkey-col_name = 'CARRID'.&lt;/P&gt;&lt;P&gt;APPEND t_vkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_vkey-col_no = '3'.&lt;/P&gt;&lt;P&gt;t_vkey-col_name = 'CONNID'.&lt;/P&gt;&lt;P&gt;APPEND t_vkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_vkey-col_no = '4'.&lt;/P&gt;&lt;P&gt;t_vkey-col_name = 'FLDATE'.&lt;/P&gt;&lt;P&gt;APPEND t_vkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Header text for the data columns................&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-row_no = '1'.&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 1.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'PRICE'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 2.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'CURRENCY'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 3.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'PLANETYPE'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 4.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'SEATSMAX'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 5.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'SEATSOCC'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_hkey-col_no = 6.&lt;/P&gt;&lt;P&gt;t_hkey-col_name = 'PAYMENTSUM'.&lt;/P&gt;&lt;P&gt;APPEND t_hkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;populating the SEMA data..........................&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;t_sema-col_no = 1.&lt;/P&gt;&lt;P&gt;t_sema-col_typ = 'STR'.&lt;/P&gt;&lt;P&gt;t_sema-col_ops = 'DFT'.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 2.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 3.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 4.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 5.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 6.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 7.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 8.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 9.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_sema-col_no = 10.&lt;/P&gt;&lt;P&gt;t_sema-col_typ = 'NUM'.&lt;/P&gt;&lt;P&gt;t_sema-col_ops = 'ADD'.&lt;/P&gt;&lt;P&gt;APPEND t_sema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'XXL_FULL_API'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;DATA_ENDING_AT = 54&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;DATA_STARTING_AT = 5&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;filename = 'TESTFILE'&lt;/P&gt;&lt;P&gt;header_1 = header1&lt;/P&gt;&lt;P&gt;header_2 = header2&lt;/P&gt;&lt;P&gt;no_dialog = 'X'&lt;/P&gt;&lt;P&gt;no_start = ' '&lt;/P&gt;&lt;P&gt;n_att_cols = 6&lt;/P&gt;&lt;P&gt;n_hrz_keys = 1&lt;/P&gt;&lt;P&gt;n_vrt_keys = 4&lt;/P&gt;&lt;P&gt;sema_type = 'X'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;SO_TITLE = ' '&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;data = t_sflight&lt;/P&gt;&lt;P&gt;hkey = t_hkey&lt;/P&gt;&lt;P&gt;online_text = t_online&lt;/P&gt;&lt;P&gt;print_text = t_print&lt;/P&gt;&lt;P&gt;sema = t_sema&lt;/P&gt;&lt;P&gt;vkey = t_vkey&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;cancelled_by_user = 1&lt;/P&gt;&lt;P&gt;data_too_big = 2&lt;/P&gt;&lt;P&gt;dim_mismatch_data = 3&lt;/P&gt;&lt;P&gt;dim_mismatch_sema = 4&lt;/P&gt;&lt;P&gt;dim_mismatch_vkey = 5&lt;/P&gt;&lt;P&gt;error_in_hkey = 6&lt;/P&gt;&lt;P&gt;error_in_sema = 7&lt;/P&gt;&lt;P&gt;file_open_error = 8&lt;/P&gt;&lt;P&gt;file_write_error = 9&lt;/P&gt;&lt;P&gt;inv_data_range = 10&lt;/P&gt;&lt;P&gt;inv_winsys = 11&lt;/P&gt;&lt;P&gt;inv_xxl = 12&lt;/P&gt;&lt;P&gt;OTHERS = 13&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/P&gt;&lt;P&gt;WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regsrds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;navjot&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use this method to download the contents of an internal table to an excel file.&lt;/P&gt;&lt;P&gt;It is a static method of the class cl_gui_frontend_services. So you dont need an instance to call it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just make sure the file name has an extension .xls&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call method cl_gui_frontend_services=&amp;gt;gui_download&lt;/P&gt;&lt;P&gt;exporting&lt;/P&gt;&lt;P&gt;filename = gv_file_name&lt;/P&gt;&lt;P&gt;filetype = lv_file_type&lt;/P&gt;&lt;P&gt;confirm_overwrite = space&lt;/P&gt;&lt;P&gt;changing&lt;/P&gt;&lt;P&gt;data_tab = &amp;lt;fs_download&amp;gt;&lt;/P&gt;&lt;P&gt;exceptions&lt;/P&gt;&lt;P&gt;file_write_error = 1&lt;/P&gt;&lt;P&gt;no_batch = 2&lt;/P&gt;&lt;P&gt;gui_refuse_filetransfer = 3&lt;/P&gt;&lt;P&gt;invalid_type = 4&lt;/P&gt;&lt;P&gt;no_authority = 5&lt;/P&gt;&lt;P&gt;unknown_error = 6&lt;/P&gt;&lt;P&gt;header_not_allowed = 7&lt;/P&gt;&lt;P&gt;separator_not_allowed = 8&lt;/P&gt;&lt;P&gt;filesize_not_allowed = 9&lt;/P&gt;&lt;P&gt;header_too_long = 10&lt;/P&gt;&lt;P&gt;dp_error_create = 11&lt;/P&gt;&lt;P&gt;dp_error_send = 12&lt;/P&gt;&lt;P&gt;dp_error_write = 13&lt;/P&gt;&lt;P&gt;unknown_dp_error = 14&lt;/P&gt;&lt;P&gt;access_denied = 15&lt;/P&gt;&lt;P&gt;dp_out_of_memory = 16&lt;/P&gt;&lt;P&gt;disk_full = 17&lt;/P&gt;&lt;P&gt;dp_timeout = 18&lt;/P&gt;&lt;P&gt;file_not_found = 19&lt;/P&gt;&lt;P&gt;dataprovider_exception = 20&lt;/P&gt;&lt;P&gt;control_flush_error = 21&lt;/P&gt;&lt;P&gt;not_supported_by_gui = 22&lt;/P&gt;&lt;P&gt;error_no_gui = 23&lt;/P&gt;&lt;P&gt;others = 24.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;message id sy-msgid type sy-msgty number sy-msgno&lt;/P&gt;&lt;P&gt;with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Bhaskar Rao.M&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 03:51:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232252#M480384</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T03:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232253#M480385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Refer the following code. The 'Download file' in the alv display download the alv into flat file. You can convert that flat file to excel or else insted of 'GUI_DOWNLOAD', you can use other functional module to download the internal table to excel file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  Z_82235_ALV_OOPS_PUSTBUTTON                                 *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;                                                                     *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*

report  z_82235_alv_oops_pustbutton             .

tables: mara.

types: begin of t_mara,
         matnr type matnr,
         mtart type mtart,
         matkl type matkl,
         meins type meins,
       end of t_mara.

data: gt_mara type standard table of t_mara,
      gs_mara like line of gt_mara.

class lcl_event_receiver definition deferred.

*-- Global Data defenation for ALV

*---Alv Grid instance referance
data : gr_alvgrid type ref to cl_gui_alv_grid,
       event_receiver type ref to lcl_event_receiver.

*---Name of the custom control added on the screen
data gc_custom_control_name type scrfname value 'CC_ALV'
.
*---Custom container instance referance
data: gr_ccontainer type ref to cl_gui_custom_container.

*---Field catalog table
data: gt_fieldcat type lvc_t_fcat,
      gs_fieldcat type lvc_s_fcat.

*---Layout structure
data: gs_layout type lvc_s_layo.

data: g_repid like sy-repid.

select matnr
       mtart
       matkl
       meins
       from mara into table gt_mara
       up to 25 rows.

g_repid = sy-repid.


include &amp;lt;icon&amp;gt;.
*********
* Predefine a local class for event handling to allow the
* declaration of a reference variable before the class is defined.


*
*********

* Set initial dynpro
set screen 100.

****************************************************************
* LOCAL CLASSES: Definition
****************************************************************
*===============================================================
* class lcl_event_receiver: local class to
*                         define and handle own functions.
*
* Definition:
* ~~~~~~~~~~~
class lcl_event_receiver definition.

  public section.

    methods:
    handle_toolbar
        for event toolbar of cl_gui_alv_grid
            importing e_object e_interactive,

    handle_user_command
        for event user_command of cl_gui_alv_grid
            importing e_ucomm.

  private section.

endclass.
*
* lcl_event_receiver (Definition)
*===============================================================

****************************************************************
* LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
* class lcl_event_receiver (Implementation)
*
*
class lcl_event_receiver implementation.

  method handle_toolbar.
* § 2.In event handler method for event TOOLBAR: Append own functions
*   by using event parameter E_OBJECT.
    data: ls_toolbar  type stb_button.
*....................................................................
* E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
* This class has got one attribute, namly MT_TOOLBAR, which
* is a table of type TTB_BUTTON. One line of this table is
* defined by the Structure STB_BUTTON (see data deklaration above).
*

* A remark to the flag E_INTERACTIVE:
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*         'e_interactive' is set, if this event is raised due to
*         the call of 'set_toolbar_interactive' by the user.
*         You can distinguish this way if the event was raised
*         by yourself or by ALV
*         (e.g. in method 'refresh_table_display').
*         An application of this feature is still unknown... :-)

* append a separator to normal toolbar
    clear ls_toolbar.
    move 3 to ls_toolbar-butn_type.
    append ls_toolbar to e_object-&amp;gt;mt_toolbar.
* append an icon to download
    clear ls_toolbar.
    ls_toolbar-function = 'DOWN'.
    ls_toolbar-icon = 'icon_generate'.
    ls_toolbar-quickinfo = 'DOWNLOAD FILE'.
    ls_toolbar-text = 'DOWNLOAD FILE'.

*    MOVE ' ' TO ls_toolbar-disabled.
    append ls_toolbar to e_object-&amp;gt;mt_toolbar.

  endmethod.
*-------------------------------------------------------------------
  method handle_user_command.
* § 3.In event handler method for event USER_COMMAND: Query your
*   function codes defined in step 2 and react accordingly.

    data: lt_rows type lvc_t_row.

    case e_ucomm.
      when 'DOWN'.

      call function 'GUI_DOWNLOAD'
        exporting
*         BIN_FILESIZE                  =
          filename                      = 'D:a.txt'
*         FILETYPE                      = 'ASC'
*         APPEND                        = ' '
*         WRITE_FIELD_SEPARATOR         = ' '
*         HEADER                        = '00'
        tables
          data_tab                      = gt_mara
       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 &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.




   endcase.
  endmethod.                           "handle_user_command
*-----------------------------------------------------------------
endclass.
*
* lcl_event_receiver (Implementation)
*===================================================================





*--------------------------------------------------------------------
* S T A R T - O F - S E L E C T I O N.
*--------------------------------------------------------------------
start-of-selection.
  set screen '100'.


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  display_alv  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module display_alv output.

  if gr_alvgrid is initial.

*---Creating custom container instance
    create object gr_ccontainer
      exporting
        container_name              = gc_custom_control_name
      exceptions
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5
        others                      = 6
        .
    if sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.


*---Creating ALV gris instance
    create object gr_alvgrid
      exporting
        i_parent          = gr_ccontainer
        i_appl_events     = 'X'
      exceptions
        error_cntl_create = 1
        error_cntl_init   = 2
        error_cntl_link   = 3
        error_dp_create   = 4
        others            = 5
        .
    if sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.

*---Prepare field catalog
    perform prepare_field_catalog tables gt_fieldcat.

*---Prepare layout
    perform prepare_layout changing gs_layout.


*---Call ALV grid
    call method gr_alvgrid-&amp;gt;set_table_for_first_display
      exporting
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
*    I_STRUCTURE_NAME              =
*    IS_VARIANT                    =
*    I_SAVE                        =
*    I_DEFAULT                     = 'X'
        is_layout                     = gs_layout
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
      changing
        it_outtab                     = gt_mara[]
        it_fieldcatalog               = gt_fieldcat
*    IT_SORT                       =
*    IT_FILTER                     =
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        others                        = 4
            .
    if sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.




********
* -&amp;gt;Create Object to receive events and link them to handler methods.
* When the ALV Control raises the event for the specified instance
* the corresponding method is automatically called.
*
    create object event_receiver.
    set handler event_receiver-&amp;gt;handle_user_command for gr_alvgrid.
    set handler event_receiver-&amp;gt;handle_toolbar for gr_alvgrid.
*
********

* § 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
    call method gr_alvgrid-&amp;gt;set_toolbar_interactive.

*  endif.                               "IF grid1 IS INITIAL
*  call method cl_gui_control=&amp;gt;set_focus exporting control = gr_alvgrid.

*--- the instance is present
  else .

    call method gr_alvgrid-&amp;gt;refresh_table_display
*      EXPORTING
*        IS_STABLE      =
*        I_SOFT_REFRESH =
      exceptions
        finished       = 1
        others         = 2
            .
    if sy-subrc &amp;lt;&amp;gt; 0.
*     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.


  endif.

endmodule.                 " display_alv  OUTPUT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  prepare_field_catalog
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_GT_FIELDCAT  text
*----------------------------------------------------------------------*
form prepare_field_catalog  tables gt_fieldcat.

  clear : gs_fieldcat.
  gs_fieldcat-fieldname = 'MATNR'.
  gs_fieldcat-col_pos   = 1.
  gs_fieldcat-emphasize = 'X'.
  gs_fieldcat-outputlen = 10.
  gs_fieldcat-coltext   = 'Material No'.
  gs_fieldcat-edit      = 'X'.
  append gs_fieldcat to gt_fieldcat.

  clear : gs_fieldcat.
  gs_fieldcat-fieldname = 'MTART'.
  gs_fieldcat-col_pos   = 2.
  gs_fieldcat-outputlen = 6.
  gs_fieldcat-coltext   = 'Material Type'.
  append gs_fieldcat to gt_fieldcat.

  clear : gs_fieldcat.
  gs_fieldcat-fieldname = 'MATKL'.
  gs_fieldcat-col_pos   = 3.
  gs_fieldcat-outputlen = 5.
  gs_fieldcat-coltext   = 'Material Grp'.
  append gs_fieldcat to gt_fieldcat.


  clear : gs_fieldcat.
  gs_fieldcat-fieldname = 'MEINS'.
  gs_fieldcat-col_pos   = 4.
  gs_fieldcat-outputlen = 4.
  gs_fieldcat-coltext   = 'Unit'.
  append gs_fieldcat to gt_fieldcat.





endform.                    " prepare_field_catalog

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  prepare_layout
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_GS_LAYOUT  text
*----------------------------------------------------------------------*
form prepare_layout  changing p_gs_layout type lvc_s_layo.

  p_gs_layout-zebra = 'X'.
  p_gs_layout-grid_title = 'Material'.
  p_gs_layout-smalltitle = 'X'.


endform.                    " prepare_layout
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  STATUS_0100  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'STATUS1'.
*  SET TITLEBAR 'xxx'.

endmodule.                 " STATUS_0100  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  USER_COMMAND_0100  INPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.

  case sy-ucomm.

    when 'BACK' or 'UP' or 'CANCEL'.
      leave program.
  endcase.

endmodule.                 " USER_COMMAND_0100  INPUT&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 03:56:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232253#M480385</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T03:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232254#M480386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi abhishek sarkar &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Thanks for ur reply.... My problem is how to display 150 in Alv(Large)....&lt;/P&gt;&lt;P&gt;how to achieve this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please Reply me&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ManiR&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 04:39:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2232254#M480386</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T04:39:19Z</dc:date>
    </item>
  </channel>
</rss>

