<?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/2208766#M472900</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 May 2007 15:43:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-11T15:43:18Z</dc:date>
    <item>
      <title>ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208759#M472893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what is ALV (detailed)? how v use it. related Questions asked in interview.&lt;/P&gt;&lt;P&gt;regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2007 07:42:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208759#M472893</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-01T07:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208760#M472894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this link.&lt;/P&gt;&lt;P&gt;All about ALV:&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="2121923"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;REgards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2007 07:45:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208760#M472894</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-01T07:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208761#M472895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please use the search functionality of this forum. Because this question is certainly asked before.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hans&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2007 07:45:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208761#M472895</guid>
      <dc:creator>h_senden2</dc:creator>
      <dc:date>2007-05-01T07:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208762#M472896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;advantages.&lt;/P&gt;&lt;P&gt;Collapse multiple reports into one, drastically cutting down your report development time &lt;/P&gt;&lt;P&gt;Save many hours using built-in ALV sorting, subtotaling and filtering capabilities &lt;/P&gt;&lt;P&gt;Add conditional structures into your ALV report: No programming required! &lt;/P&gt;&lt;P&gt;Combine ALV with display variants to meet a wide range of reporting requirements more easily &lt;/P&gt;&lt;P&gt;Dynamically reorder column layouts and add/subtract fields &lt;/P&gt;&lt;P&gt;Enable users and analysts to save their own personalized variants&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2007 07:49:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208762#M472896</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-01T07:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208763#M472897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The advantages are many - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The keyword is flexibility. In the past I have sometimes programmed more programs that was basically the same report with minor variations - in one case i programmed 10 very similar reports for pp evaluation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With ALV the users can define their own display variants without changing the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The display variant covers sorting, summarizing, filtering, hiding fields. The users can also make variants that show only total lines or subtotal lines or both - and by one click in the report they can expand one total line to display the underlying item lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The users can also choose to let the report show directly in excel. This is a very powerful option. You can upload excel templates with predefined formulas and macros. This can make you very popular - especially with Finance people that already have a lot of excel files, they populate with SAP data to make al kind of voodoo calculations that will help them see into the future.&lt;/P&gt;&lt;P&gt;With ALV you can give them an ABAP report that automatic popup with their own favorite excel book - without having to do a lot of troublesome and time consuming work to download the data and fit it into the excel sheet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are new to ALV you can very quick make a simple ALV report. Basically it has 3 steps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) build an internal table with the data you want do display&lt;/P&gt;&lt;P&gt;2) build a field catalog table (each record in this table describes one column in the list)&lt;/P&gt;&lt;P&gt;3) call the ALV function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Later you can make use of more complicated functions like call back routines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have both functions modules and ABAP OO classes to help you with step 2 and 3. I have used the function modules for many years so its hard for me to change, but if I should start all over today I would forget about the function modules and go for the OO approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_46c/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_46c/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and Look at this link.....&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/reporting/alvhome.htm" target="test_blank"&gt;http://www.sapdevelopment.co.uk/reporting/alvhome.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Go thru the foll link...just copy and paste the example pgms and know the diff.&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/reporting/alvhome.htm" target="test_blank"&gt;http://www.sapdevelopment.co.uk/reporting/alvhome.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. First we prepare a outputlist which we want to display .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.WE made a fieldcatalog table which will say the display of the columns.&lt;/P&gt;&lt;P&gt;Ex: position of columns, heading, length etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Then we prepare a layout structure which contain the layout informations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. we call a FM ( ex: RUSE_ALV_GRID_DISPLY or REUSE_ALV_LIST_DISPLAY)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZDEMO_ALVGRID                                               *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;                                                                     *
*&amp;amp; Example of a simple ALV Grid Report                                 *
*&amp;amp; ...................................                                 *
*&amp;amp;                                                                     *
*&amp;amp; The basic requirement for this demo is to display a number of       *
*&amp;amp; fields from the EKKO table.                                         *
*&amp;amp;---------------------------------------------------------------------*
REPORT  zdemo_alvgrid                 .
 
TABLES:     ekko.
 
type-pools: slis.                                 "ALV Declarations
*Data Declaration
*----------------
TYPES: BEGIN OF t_ekko,
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
  statu TYPE ekpo-statu,
  aedat TYPE ekpo-aedat,
  matnr TYPE ekpo-matnr,
  menge TYPE ekpo-menge,
  meins TYPE ekpo-meins,
  netpr TYPE ekpo-netpr,
  peinh TYPE ekpo-peinh,
 END OF t_ekko.
 
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
      wa_ekko TYPE t_ekko.
 
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
      gd_tab_group type slis_t_sp_group_alv,
      gd_layout    type slis_layout_alv,
      gd_repid     like sy-repid.
 
 
************************************************************************
*Start-of-selection.
START-OF-SELECTION.
 
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
 
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_FIELDCATALOG
*&amp;amp;---------------------------------------------------------------------*
*       Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.
 
* There are a number of ways to create a fieldcat. 
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then 
* appending the rows. This method can be the most time consuming but can
* also allow you  more control of the final product.
 
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were 
* simply displaying the result
*               I.e. Field type may be required in-order for
*                    the 'TOTAL' function to work.
 
  fieldcatalog-fieldname   = 'EBELN'.
  fieldcatalog-seltext_m   = 'Purchase Order'.
  fieldcatalog-col_pos     = 0.
  fieldcatalog-outputlen   = 10.
  fieldcatalog-emphasize   = 'X'.
  fieldcatalog-key         = 'X'.
*  fieldcatalog-do_sum      = 'X'.
*  fieldcatalog-no_zero     = 'X'.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
 
  fieldcatalog-fieldname   = 'EBELP'.
  fieldcatalog-seltext_m   = 'PO Item'.
  fieldcatalog-col_pos     = 1.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
 
  fieldcatalog-fieldname   = 'STATU'.
  fieldcatalog-seltext_m   = 'Status'.
  fieldcatalog-col_pos     = 2.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
 
  fieldcatalog-fieldname   = 'AEDAT'.
  fieldcatalog-seltext_m   = 'Item change date'.
  fieldcatalog-col_pos     = 3.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
 
  fieldcatalog-fieldname   = 'MATNR'.
  fieldcatalog-seltext_m   = 'Material Number'.
  fieldcatalog-col_pos     = 4.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
 
  fieldcatalog-fieldname   = 'MENGE'.
  fieldcatalog-seltext_m   = 'PO quantity'.
  fieldcatalog-col_pos     = 5.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
 
  fieldcatalog-fieldname   = 'MEINS'.
  fieldcatalog-seltext_m   = 'Order Unit'.
  fieldcatalog-col_pos     = 6.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
 
  fieldcatalog-fieldname   = 'NETPR'.
  fieldcatalog-seltext_m   = 'Net Price'.
  fieldcatalog-col_pos     = 7.
  fieldcatalog-outputlen   = 15.  
  fieldcatalog-do_sum      = 'X'        "Display column total
  fieldcatalog-datatype     = 'CURR'.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
 
  fieldcatalog-fieldname   = 'PEINH'.
  fieldcatalog-seltext_m   = 'Price Unit'.
  fieldcatalog-col_pos     = 8.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
endform.                    " BUILD_FIELDCATALOG
 
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_LAYOUT
*&amp;amp;---------------------------------------------------------------------*
*       Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
  gd_layout-no_input          = 'X'.
  gd_layout-colwidth_optimize = 'X'.
  gd_layout-totals_text       = 'Totals'(201).
*  gd_layout-totals_only        = 'X'.
*  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
*                                         "click(press f2)
*  gd_layout-zebra             = 'X'.
*  gd_layout-group_change_edit = 'X'.
*  gd_layout-header_text       = 'helllllo'.
endform.                    " BUILD_LAYOUT
 
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  DISPLAY_ALV_REPORT
*&amp;amp;---------------------------------------------------------------------*
*       Display report using ALV grid
*----------------------------------------------------------------------*
form display_alv_report.
  gd_repid = sy-repid.
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
*            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
*            i_callback_user_command = 'USER_COMMAND'
*            i_grid_title           = outtext
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
*            it_special_groups       = gd_tabgroup
*            IT_EVENTS                = GT_XEVENTS
            i_save                  = 'X'
*            is_variant              = z_template
 
       tables
            t_outtab                = it_ekko
       exceptions
            program_error           = 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.
endform.                    " DISPLAY_ALV_REPORT
 
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  DATA_RETRIEVAL
*&amp;amp;---------------------------------------------------------------------*
*       Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
form data_retrieval.
 
select ebeln ebelp statu aedat matnr menge meins netpr peinh
 up to 10 rows
  from ekpo
  into table it_ekko.
endform.                   

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also prepare alv display by using class.&lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STEPS:&lt;/P&gt;&lt;P&gt;1. Call a screen.&lt;/P&gt;&lt;P&gt;2. Go to the screen layout and add a custom control .&lt;/P&gt;&lt;P&gt;3. Go to attribute and give a name to the custom control (Ex: 'CUSTOM_CONTROL').&lt;/P&gt;&lt;P&gt;4. Give a name to the ok_code ( Ex: ok_code) in the attribute of the screen.&lt;/P&gt;&lt;P&gt;5. Data Declaration section:&lt;/P&gt;&lt;P&gt;I. Data declaration for ALV&lt;/P&gt;&lt;P&gt;a. Declare a object type cl_gui_alv_grid for ALV Grid instance referance&lt;/P&gt;&lt;P&gt;b. Declare a object type cl_gui_custom_container for Custom container instance referance&lt;/P&gt;&lt;P&gt;c. Declare Name of the custom control added to the screen&lt;/P&gt;&lt;P&gt;d. Declare field catalog table of type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;e. Declare layout of type lvc_s_layo.&lt;/P&gt;&lt;P&gt;II. Data declaration for fetching data as input&lt;/P&gt;&lt;P&gt;III. Declare variables for ok_code.&lt;/P&gt;&lt;P&gt;6. Set pf-status and titlebar for the screen.&lt;/P&gt;&lt;P&gt;7. Write PBO. IN PBO do the following:&lt;/P&gt;&lt;P&gt;i. Check whether gr_alvgrid is initial.&lt;/P&gt;&lt;P&gt;a. If yes do the following.&lt;/P&gt;&lt;P&gt;&amp;#149; Create instance for custom container (gr_container) by passing the container name.&lt;/P&gt;&lt;P&gt;&amp;#149; Create instance for ALV grid by passing the custom control instance reference.&lt;/P&gt;&lt;P&gt;&amp;#149; select the material data from database&lt;/P&gt;&lt;P&gt;&amp;#149; Build field ctalog&lt;/P&gt;&lt;P&gt;&amp;#149; Build layout&lt;/P&gt;&lt;P&gt;&amp;#149; Call method &amp;#145;set_table_for_first_display&amp;#146; for the object gr_alvgrid(alv grid instance reference) with passing layout, input table and field catalog.&lt;/P&gt;&lt;P&gt;b. If NO do the following.&lt;/P&gt;&lt;P&gt;&amp;#149; Call method &amp;#145;refresh_table_display for the object gr_alvgrid(alv grid instance reference).&lt;/P&gt;&lt;P&gt;ii.&lt;/P&gt;&lt;P&gt;8. Write PAI. IN PAI do the following:&lt;/P&gt;&lt;P&gt;Check the ok_code, if &amp;#145;Exit&amp;#146; then leave from program.&lt;/P&gt;&lt;P&gt;All the user commands where user do any actions in the screen will be code here . For this purpose check the value of ok_code and according that ok_code, code the functionality for the particular user actions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  zdemoab.
 
 
************************************
*DATA DECLARATION
*************************************
*---Global data deckaration for alv
*--ALV Grid instance referance
DATA: gr_alvgrid TYPE REF TO cl_gui_alv_grid,
*--Name of the custom control added to the screen
      gc_custom_control_name TYPE scrfname VALUE 'CUSTOM_CONTROL',
*--Custom container instance referance
      gr_container TYPE REF TO cl_gui_custom_container,
*--Field catalog table
      gt_fieldcat TYPE lvc_t_fcat,
*--Layout structure
      gs_layout TYPE lvc_s_layo.
 
DATA: ok_code LIKE sy-ucomm,
      save_ok LIKE sy-ucomm.
 
 
*---Input table
TYPES: BEGIN OF t_mara,
        matnr TYPE mara-matnr,
        mtart TYPE mara-mtart,
        matkl TYPE mara-matkl,
        meins TYPE mara-meins,
      END OF t_mara.
TYPES: t_mara_table TYPE STANDARD TABLE OF t_mara.
 
DATA: gt_mara TYPE STANDARD TABLE OF t_mara.
 
************************************
*MAIN
*************************************
CALL SCREEN 101.
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  STATUS_0101  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
 
MODULE status_0101 OUTPUT.
  SET PF-STATUS 'STATUS-0101'.
  SET TITLEBAR 'TITLE'.
 
ENDMODULE.                 " STATUS_0101  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  display_alv  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
 
MODULE display_alv OUTPUT.
 
  IF gr_alvgrid IS INITIAL.
*----Create custom container instance
    CREATE OBJECT gr_container
      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.
 
*----Create ALV grid instance
    CREATE OBJECT gr_alvgrid
      EXPORTING
        i_parent          = gr_container
      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.
 
* select the material data from database
    PERFORM get_input CHANGING gt_mara..
* prepare field catalog
    PERFORM prepare_fieldcatalog CHANGING gt_fieldcat.
* prepare layout
    PERFORM prepare_layout CHANGING gs_layout.
 
 
    CALL METHOD gr_alvgrid-&amp;gt;set_table_for_first_display
      EXPORTING
        is_layout                     = gs_layout
      CHANGING
        it_outtab                     = gt_mara[]
        it_fieldcatalog               = gt_fieldcat
      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.
  ELSE.
    CALL METHOD gr_alvgrid-&amp;gt;refresh_table_display
      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  get_input
*&amp;amp;---------------------------------------------------------------------*
FORM get_input CHANGING gt_mara_table TYPE t_mara_table.
  SELECT matnr mtart matkl meins INTO TABLE gt_mara_table
                                 FROM mara UP TO 10 ROWS.
ENDFORM.                    " get_input
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  prepare_fieldcatalog
*&amp;amp;---------------------------------------------------------------------*
 
FORM prepare_fieldcatalog  CHANGING gt_fieldcat_table TYPE lvc_t_fcat.
 
  DATA: ls_fcat TYPE lvc_s_fcat,
        l_col_no TYPE i.
 
  CLEAR: ls_fcat,
         l_col_no .
 
  l_col_no = l_col_no + 1.
  ls_fcat-fieldname = 'MATNR'.
  ls_fcat-ref_table = 'MARA'.
  ls_fcat-col_pos   = l_col_no.
  ls_fcat-outputlen = 18.
  ls_fcat-coltext   = 'Material No'.
  ls_fcat-seltext   = 'Material No'.
  APPEND ls_fcat TO gt_fieldcat_table.
 
  l_col_no = l_col_no + 1.
  ls_fcat-fieldname = 'MTART'.
  ls_fcat-ref_table = 'MARA'.
  ls_fcat-col_pos   = l_col_no.
  ls_fcat-outputlen = 4.
  ls_fcat-coltext   = 'Material type'.
  ls_fcat-seltext   = 'Material type'.
  APPEND ls_fcat TO gt_fieldcat_table.
 
  l_col_no = l_col_no + 1.
  ls_fcat-fieldname = 'MATKL'.
  ls_fcat-ref_table = 'MARA'.
  ls_fcat-col_pos   = l_col_no.
  ls_fcat-outputlen = 9.
  ls_fcat-coltext   = 'Material group'.
  ls_fcat-seltext   = 'Material group'.
  APPEND ls_fcat TO gt_fieldcat_table.
 
  l_col_no = l_col_no + 1.
  ls_fcat-fieldname = 'MEINS'.
  ls_fcat-ref_table = 'MARA'.
  ls_fcat-col_pos   = l_col_no.
  ls_fcat-outputlen = 3.
  ls_fcat-coltext   = 'Unit'.
  ls_fcat-seltext   = 'Unit'.
  APPEND ls_fcat TO gt_fieldcat_table.
 
  CLEAR: ls_fcat,
         l_col_no .
 
ENDFORM.                    " prepare_fieldcatalog
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  prepare_layout
*&amp;amp;---------------------------------------------------------------------*
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  USER_COMMAND_0101  INPUT
*&amp;amp;---------------------------------------------------------------------*
 
MODULE user_command_0101 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'EXIT'.
      PERFORM exit_program.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0101  INPUT
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  exit_program
*&amp;amp;---------------------------------------------------------------------*
FORM exit_program .
  LEAVE PROGRAM.
ENDFORM.                    " exit_program
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards Rk&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Rk Pasupuleti&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2007 08:06:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208763#M472897</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-01T08:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208764#M472898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   Sap provides a set of ALV (ABAP LIST VIEWER) function modules, which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.  In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The commonly used ALV functions used for this purpose are;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	REUSE_ALV_VARIANT_DEFAULT_GET&lt;/P&gt;&lt;P&gt;2.	REUSE_ALV_VARIANT_F4&lt;/P&gt;&lt;P&gt;3.	REUSE_ALV_VARIANT_EXISTENCE&lt;/P&gt;&lt;P&gt;4.	REUSE_ALV_EVENTS_GET&lt;/P&gt;&lt;P&gt;5.	REUSE_ALV_COMMENTARY_WRITE&lt;/P&gt;&lt;P&gt;6.   REUSE_ALV_FIELDCATALOG_MERGE&lt;/P&gt;&lt;P&gt;7.   REUSE_ALV_LIST_DISPLAY&lt;/P&gt;&lt;P&gt;8.	REUSE_ALV_GRID_DISPLAY&lt;/P&gt;&lt;P&gt;9.	REUSE_ALV_POPUP_TO_SELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The different steps used for getting the above function modules into use are described below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sap standard type pools:  SLIS, KKBLO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sap standard tables types taken from the type pools are:  &lt;/P&gt;&lt;P&gt;           SLIS_LAYOUT_ALV,&lt;/P&gt;&lt;P&gt;SLIS_T_FIELDCAT_ALV&lt;/P&gt;&lt;P&gt;SLIS_T_LISTHEADER,&lt;/P&gt;&lt;P&gt;SLIS_T_EVENT,&lt;/P&gt;&lt;P&gt;SLIS_SELFIELD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward points if helpful.&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;kiran kumar k&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2007 09:04:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208764#M472898</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-01T09:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208765#M472899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the following link:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap-function.htm" target="test_blank"&gt;http://www.sap-img.com/abap-function.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaskar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2007 17:54:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208765#M472899</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-01T17:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208766#M472900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2007 15:43:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2208766#M472900</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-11T15:43:18Z</dc:date>
    </item>
  </channel>
</rss>

