<?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: sap alv examples in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215192#M134582</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/fu002.htm" target="test_blank"&gt;http://www.sap-img.com/fu002.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm" target="test_blank"&gt;http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/alv-grid.htm" target="test_blank"&gt;http://www.sap-img.com/abap/alv-grid.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/fu015.htm" target="test_blank"&gt;http://www.sap-img.com/fu015.htm&lt;/A&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;REgards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Apr 2006 10:08:09 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-04-17T10:08:09Z</dc:date>
    <item>
      <title>sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215183#M134573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hai &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;blow the function modules can u send the some code examples&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reuse_alv_list_display&lt;/P&gt;&lt;P&gt;Reuse_alv_fieldcatalog_merge&lt;/P&gt;&lt;P&gt;Reuse_alv_events_get&lt;/P&gt;&lt;P&gt;Reuse_alv_commentary_write&lt;/P&gt;&lt;P&gt;Reuse_alv_grid_display&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 09:55:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215183#M134573</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T09:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215184#M134574</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;You should see the demo programs, so in SE38 see all programs whose name begin with BALV* or BCALV*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 09:58:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215184#M134574</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T09:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215185#M134575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Go to se38, give &lt;/P&gt;&lt;P&gt;bc&lt;STRONG&gt;alv&lt;/STRONG&gt; in the program name. and press f4.&lt;/P&gt;&lt;P&gt;YOu can find lots of them.&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>Mon, 17 Apr 2006 09:58:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215185#M134575</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T09:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215186#M134576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Franklin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; You can check the std programs under the development package SLIS. Goto se80 and display SLIS development package you can find a lot of SAP programs giving you details of the usage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Hope this helps.&lt;/P&gt;&lt;P&gt; Cheers&lt;/P&gt;&lt;P&gt; VJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 09:58:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215186#M134576</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T09:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215187#M134577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Franklin&lt;/P&gt;&lt;P&gt;here is everything about ALV&lt;/P&gt;&lt;P&gt;Its excellent just go through its&lt;/P&gt;&lt;P&gt;I hope you will get what you want&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapgenie.com/abap/controls/alvgrid.htm" target="test_blank"&gt;http://www.sapgenie.com/abap/controls/alvgrid.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sappoint.com/ppt/alv.ppt" target="test_blank"&gt;http://www.sappoint.com/ppt/alv.ppt&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm" target="test_blank"&gt;http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt; Basic ALV programs &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.sap.com/www.sapdevelopment.co.uk" target="test_blank"&gt;www.sapdevelopment.co.uk&lt;/A&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:01:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215187#M134577</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T10:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215188#M134578</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 this forum..&lt;/P&gt;&lt;P&gt;check package SLIS from SE80.&lt;/P&gt;&lt;P&gt;check the links..&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.geocities.com/mpioud/Abap_programs.html" target="test_blank"&gt;http://www.geocities.com/mpioud/Abap_programs.html&lt;/A&gt;&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;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:02:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215188#M134578</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T10:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215189#M134579</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;Take a look at this site.&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.geocities.com/mpioud/Abap_programs.html" target="test_blank"&gt;http://www.geocities.com/mpioud/Abap_programs.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Quite a few examples.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note : Please mark all the helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:02:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215189#M134579</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T10:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215190#M134580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;here is a link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/an" target="test_blank"&gt;http://sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/an&lt;/A&gt; easy reference for alv grid control.pdf&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and the code which might help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ZKINTEST_ALV                                                .

type-pools:slis.
data :   it_fieldcat type slis_t_fieldcat_alv,
          it_fieldcat1 type slis_t_fieldcat_alv.
data: begin of itab occurs 0,
vbeln like vbak-vbeln,
posnr like vbap-posnr,
end of itab.
data: begin of itab1 occurs 0,
vbeln like likp-vbeln,
posnr like lips-posnr,
vgbel like lips-vgbel,
vgpos like lips-vgpos,
end of itab1.

data: it_lips like itab1 occurs 0 with header line.

select  vbeln posnr  up to 1000 rows
  from vbap
  into table itab.

if sy-subrc = 0.

  sort itab by vbeln .
  select vbeln   posnr   vgbel   vgpos   into table
itab1   from lips   for all entries in itab   where vgbel = itab-vbeln
and    vgpos = itab-posnr.
endif.
data: x_fieldcat type
slis_fieldcat_alv.
x_fieldcat-fieldname = 'VBELN'.x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos  = 1.append x_fieldcat to it_fieldcat.
clear x_fieldcat.
x_fieldcat-fieldname = 'POSNR'.x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos  = 1.append x_fieldcat to it_fieldcat.
clear x_fieldcat.
perform alv_grid_display.
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form
*&amp;amp;-----------------------------------------------------------------
**
*------------------------------------------------------------------
**      --&amp;gt;P_EXTAB
*-------------------------------------------------------------------
form popup using p_extab type slis_t_extab.
  set pf-status 'POPUP'.
  endform.
*&amp;amp;-----------------------------------------------------------------
**&amp;amp;      Form
*&amp;amp;---------------------------------------------------
*-------------------------------------------------------------------
**      --&amp;gt;R_UCOMM      text*      --&amp;gt;RS_SELFIELD
*-------------------------------------------------------------------
form handle_user_command using r_ucomm     like sy-ucomm
                   rs_selfield type slis_selfield.
case r_ucomm.
when 'BACK' or 'CANC' or 'EXIT'.
  leave to screen 0.
when '&amp;amp;IC1'.
  set parameter id 'AUN' field rs_selfield-value.
  call transaction 'VA03' and skip first screen.
when 'BUTTON'.
  loop at it_fieldcat into x_fieldcat.
    if x_fieldcat-fieldname = 'POSNR'.
      x_fieldcat-no_out = 'X'.
      modify it_fieldcat from x_fieldcat transporting no_out.
    endif.
  endloop.
  rs_selfield-exit = 'X'.
  perform alv_grid_display.
endcase.
endform.

"HANDLE_USER_COMMAND
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      **text*---------------------------------------------------------
**  --&amp;gt;  p1        text
*  &amp;lt;--
*-------------------------------------------------------------------
form alv_grid_display .
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program       = sy-repid
i_callback_pf_status_set = 'POPUP'
i_callback_user_command  = 'HANDLE_USER_COMMAND'
i_callback_top_of_page = 'TOP-OF-PAGE'
it_fieldcat              = it_fieldcat
TABLES
t_outtab                 = itab
EXCEPTIONS
program_error            = 1
others                   = 2.
if
sy-subrc  = 0.
endif.
endform.                    " alv_grid_display



FORM TOP-OF-PAGE.

*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.

* Title
wa_header-typ = 'H'.
wa_header-info+10(15) = '                SY-REPID'.
*wa_header-info+21(10) = text-001.
append wa_header to t_header.
clear wa_header.

* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.

endform.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Kinshuk&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS reward points if you find this useful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:05:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215190#M134580</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T10:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215191#M134581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;check this sample..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  Z_TEST_ALV_EVENTS                       .

type-pools: slis.
data: x_fieldcat type slis_fieldcat_Alv,
      it_fieldcat type slis_t_fieldcat_alv,
      x_events type slis_alv_event,
      it_events type SLIS_T_EVENT.
data: v_lines type i.
data: begin of itab occurs 0,
       vbeln like vbak-vbeln,
       posnr like vbap-posnr,
      end of itab.

select vbeln
       posnr
       from vbap
       up to 100 rows
       into table itab.

 x_events-name =  'END_OF_LIST'.
 x_events-form =  'END_OF_LIST'.
 append x_events to it_events.
 clear x_events.
  x_events-name =  'TOP_OF_PAGE'.
 x_events-form =  'TOP_OF_PAGE'.
 append x_events to it_events.
 clear x_events.
"if you use FM..
* call function 'REUSE_ALV_EVENTS_GET'
*  EXPORTING
*    I_LIST_TYPE           = 0
*  IMPORTING
*    ET_EVENTS             = IT_EVENTS
*  EXCEPTIONS
*    LIST_TYPE_WRONG       = 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.
*
* read table it_events into x_events with key name = 'TOP_OF_PAGE'.
*      if sy-subrc = 0.
*      x_events-form = 'TOP_OF_PAGE'.
*      modify it_events from x_events index sy-tabix transporting form .
*      endif.
*

call function 'REUSE_ALV_FIELDCATALOG_MERGE'
 EXPORTING
   I_PROGRAM_NAME               = sy-repid
   I_INTERNAL_TABNAME           = 'ITAB'
   I_INCLNAME                   = sy-repid
  changing
    ct_fieldcat                  = IT_FIELDCAT
 EXCEPTIONS
   INCONSISTENT_INTERFACE       = 1
   PROGRAM_ERROR                = 2
   OTHERS                       = 3
          .
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.

describe table itab lines v_lines.
 call function 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM                = sy-repid
    I_CALLBACK_PF_STATUS_SET          = 'STATUS'
    I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
    IT_FIELDCAT                       = IT_FIELDCAT
    IT_EVENTS                         = IT_EVENTS
    tables
     t_outtab                         = ITAB[]
  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.
 
 FORM TOP_OF_PAGE.
    DATA: LS_LINE TYPE SLIS_LISTHEADER,
          E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

*   Listenüberschrift: Typ H
    CLEAR LS_LINE.
    LS_LINE-TYP  = 'H'.

*   LS_LINE-KEY:  not used for this type
    LS_LINE-INFO = 'Summary'.
    APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

*   Kopfinfo: Typ S
    CLEAR LS_LINE.
    LS_LINE-TYP  = 'S'.
    LS_LINE-KEY  = 'Test'.
    LS_LINE-INFO = ''.
    APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    LS_LINE-KEY  = 'ASIA'.
    LS_LINE-INFO = 'test'.
    APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

*   Aktionsinfo: Typ A
    CLEAR LS_LINE.
    LS_LINE-TYP  = 'A'.

*   LS_LINE-KEY:  not used for this type
    LS_LINE-INFO = TEXT-105.
    APPEND LS_LINE TO  E04_LT_TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY = E04_LT_TOP_OF_PAGE
        I_LOGO             = 'ENJOYSAP_LOGO'.

 ENDFORM.
 FORM END_OF_LIST.
 write :/ 'No of Records ', v_lines.
 ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:07:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215191#M134581</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T10:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215192#M134582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/fu002.htm" target="test_blank"&gt;http://www.sap-img.com/fu002.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm" target="test_blank"&gt;http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/alv-grid.htm" target="test_blank"&gt;http://www.sap-img.com/abap/alv-grid.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/fu015.htm" target="test_blank"&gt;http://www.sap-img.com/fu015.htm&lt;/A&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;REgards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:08:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215192#M134582</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T10:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215193#M134583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the below example programs by SAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BCALV_GRID_01,02...10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Abdul Hakim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:09:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215193#M134583</guid>
      <dc:creator>abdul_hakim</dc:creator>
      <dc:date>2006-04-17T10:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215194#M134584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;good&lt;/P&gt;&lt;P&gt;Reuse_alv_list_display-&amp;gt;data definition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables:&lt;/P&gt;&lt;P&gt;marav. "Table MARA and table MAKT&lt;/P&gt;&lt;P&gt;&lt;/P&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;Data to be displayed in ALV&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;matically determine the fieldstructure from this source program&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;begin of imat occurs 100,&lt;/P&gt;&lt;P&gt;matnr like marav-matnr, "Material number&lt;/P&gt;&lt;P&gt;maktx like marav-maktx, "Material short text&lt;/P&gt;&lt;P&gt;matkl like marav-matkl, "Material group (so you can test to make&lt;/P&gt;&lt;P&gt;                        " intermediate sums)&lt;/P&gt;&lt;P&gt;ntgew like marav-ntgew, "Net weight, numeric field (so you can test to&lt;/P&gt;&lt;P&gt;                        "make sums)&lt;/P&gt;&lt;P&gt;gewei like marav-gewei, "weight unit (just to be complete)&lt;/P&gt;&lt;P&gt;end of imat.&lt;/P&gt;&lt;P&gt;&lt;/P&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;Other data needed&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;field to store report name&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data i_repid like sy-repid.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;field to check table length&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data i_lines like sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&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;Data for ALV display&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;TYPE-POOLS: SLIS.&lt;/P&gt;&lt;P&gt;data int_fcat type SLIS_T_FIELDCAT_ALV.&lt;/P&gt;&lt;P&gt;&lt;/P&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;select-options:&lt;/P&gt;&lt;P&gt;s_matnr for marav-matnr matchcode object MAT1.&lt;/P&gt;&lt;P&gt;&lt;/P&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;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;read data into table imat&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  select * from marav&lt;/P&gt;&lt;P&gt;  into corresponding fields of table imat&lt;/P&gt;&lt;P&gt;  where&lt;/P&gt;&lt;P&gt;  matnr in s_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Check if material was found&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  clear i_lines.&lt;/P&gt;&lt;P&gt;  describe table imat lines i_lines.&lt;/P&gt;&lt;P&gt;  if i_lines lt 1.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Using hardcoded write here for easy upload&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    write: /&lt;/P&gt;&lt;P&gt;    'No materials found.'.&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;end-of-selection.&lt;/P&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;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now, we start with ALV&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&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;*&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The fieldcatalouge can be generated by FUNCTION&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;report source, including this report.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The only problem one might have is that the report and table names&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;need to be in capital letters. (I had it &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt; )&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*&lt;/P&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;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Store report name&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  i_repid = sy-repid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create Fieldcatalogue from internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            I_PROGRAM_NAME         = i_repid&lt;/P&gt;&lt;P&gt;            I_INTERNAL_TABNAME     = 'IMAT'  "capital letters!&lt;/P&gt;&lt;P&gt;            I_INCLNAME             = i_repid&lt;/P&gt;&lt;P&gt;       CHANGING&lt;/P&gt;&lt;P&gt;            CT_FIELDCAT            = int_fcat&lt;/P&gt;&lt;P&gt;       EXCEPTIONS&lt;/P&gt;&lt;P&gt;            INCONSISTENT_INTERFACE = 1&lt;/P&gt;&lt;P&gt;            PROGRAM_ERROR          = 2&lt;/P&gt;&lt;P&gt;            OTHERS                 = 3.&lt;/P&gt;&lt;P&gt;*explanations:&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_PROGRAM_NAME is the program which calls this function&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;   I_INTERNAL_TABNAME is the name of the internal table which you want&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                      to display in ALV&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;   I_INCLNAME is the ABAP-source where the internal table is defined&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;              (DATA....)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CT_FIELDCAT contains the Fieldcatalouge that we need later for&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     ALV display&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&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;    write: /&lt;/P&gt;&lt;P&gt;    'Returncode',&lt;/P&gt;&lt;P&gt;    sy-subrc,&lt;/P&gt;&lt;P&gt;    'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*This was the fieldcatlogue&lt;/P&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;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;And now, we are ready to display our list&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;Call for ALV list display&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;            I_CALLBACK_PROGRAM = i_repid&lt;/P&gt;&lt;P&gt;            IT_FIELDCAT        = int_fcat&lt;/P&gt;&lt;P&gt;            I_SAVE             = 'A'&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            T_OUTTAB           = imat&lt;/P&gt;&lt;P&gt;       EXCEPTIONS&lt;/P&gt;&lt;P&gt;            PROGRAM_ERROR      = 1&lt;/P&gt;&lt;P&gt;            OTHERS             = 2.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*explanations:&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_CALLBACK_PROGRAM is the program which calls this function&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;   IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                now the data definition needed for display&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;   I_SAVE allows the user to save his own layouts&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;     T_OUTTAB contains the data to be displayed in ALV&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&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;    write: /&lt;/P&gt;&lt;P&gt;    'Returncode',&lt;/P&gt;&lt;P&gt;    sy-subrc,&lt;/P&gt;&lt;P&gt;    'from FUNCTION REUSE_ALV_LIST_DISPLAY'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------" /&gt;&lt;P&gt;Reuse_alv_fieldcatalog_merge-&amp;gt;&lt;/P&gt;&lt;P&gt;*data definition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables:&lt;/P&gt;&lt;P&gt;marav. "Table MARA and table MAKT&lt;/P&gt;&lt;P&gt;&lt;/P&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;Data to be displayed in ALV&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;matically determine the fieldstructure from this source program&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;begin of imat occurs 100,&lt;/P&gt;&lt;P&gt;matnr like marav-matnr, "Material number&lt;/P&gt;&lt;P&gt;maktx like marav-maktx, "Material short text&lt;/P&gt;&lt;P&gt;matkl like marav-matkl, "Material group (so you can test to make&lt;/P&gt;&lt;P&gt;                        " intermediate sums)&lt;/P&gt;&lt;P&gt;ntgew like marav-ntgew, "Net weight, numeric field (so you can test to&lt;/P&gt;&lt;P&gt;                        "make sums)&lt;/P&gt;&lt;P&gt;gewei like marav-gewei, "weight unit (just to be complete)&lt;/P&gt;&lt;P&gt;end of imat.&lt;/P&gt;&lt;P&gt;&lt;/P&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;Other data needed&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;field to store report name&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data i_repid like sy-repid.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;field to check table length&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data i_lines like sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&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;Data for ALV display&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;TYPE-POOLS: SLIS.&lt;/P&gt;&lt;P&gt;data int_fcat type SLIS_T_FIELDCAT_ALV.&lt;/P&gt;&lt;P&gt;&lt;/P&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;select-options:&lt;/P&gt;&lt;P&gt;s_matnr for marav-matnr matchcode object MAT1.&lt;/P&gt;&lt;P&gt;&lt;/P&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;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;read data into table imat&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  select * from marav&lt;/P&gt;&lt;P&gt;  into corresponding fields of table imat&lt;/P&gt;&lt;P&gt;  where&lt;/P&gt;&lt;P&gt;  matnr in s_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Check if material was found&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  clear i_lines.&lt;/P&gt;&lt;P&gt;  describe table imat lines i_lines.&lt;/P&gt;&lt;P&gt;  if i_lines lt 1.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Using hardcoded write here for easy upload&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    write: /&lt;/P&gt;&lt;P&gt;    'No materials found.'.&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;end-of-selection.&lt;/P&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;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now, we start with ALV&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&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;*&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The fieldcatalouge can be generated by FUNCTION&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;report source, including this report.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The only problem one might have is that the report and table names&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;need to be in capital letters. (I had it &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt; )&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*&lt;/P&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;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Store report name&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  i_repid = sy-repid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create Fieldcatalogue from internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            I_PROGRAM_NAME         = i_repid&lt;/P&gt;&lt;P&gt;            I_INTERNAL_TABNAME     = 'IMAT'  "capital letters!&lt;/P&gt;&lt;P&gt;            I_INCLNAME             = i_repid&lt;/P&gt;&lt;P&gt;       CHANGING&lt;/P&gt;&lt;P&gt;            CT_FIELDCAT            = int_fcat&lt;/P&gt;&lt;P&gt;       EXCEPTIONS&lt;/P&gt;&lt;P&gt;            INCONSISTENT_INTERFACE = 1&lt;/P&gt;&lt;P&gt;            PROGRAM_ERROR          = 2&lt;/P&gt;&lt;P&gt;            OTHERS                 = 3.&lt;/P&gt;&lt;P&gt;*explanations:&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_PROGRAM_NAME is the program which calls this function&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;   I_INTERNAL_TABNAME is the name of the internal table which you want&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                      to display in ALV&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;   I_INCLNAME is the ABAP-source where the internal table is defined&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;              (DATA....)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CT_FIELDCAT contains the Fieldcatalouge that we need later for&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     ALV display&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&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;    write: /&lt;/P&gt;&lt;P&gt;    'Returncode',&lt;/P&gt;&lt;P&gt;    sy-subrc,&lt;/P&gt;&lt;P&gt;    'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*This was the fieldcatlogue&lt;/P&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;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;And now, we are ready to display our list&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;Call for ALV list display&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;            I_CALLBACK_PROGRAM = i_repid&lt;/P&gt;&lt;P&gt;            IT_FIELDCAT        = int_fcat&lt;/P&gt;&lt;P&gt;            I_SAVE             = 'A'&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            T_OUTTAB           = imat&lt;/P&gt;&lt;P&gt;       EXCEPTIONS&lt;/P&gt;&lt;P&gt;            PROGRAM_ERROR      = 1&lt;/P&gt;&lt;P&gt;            OTHERS             = 2.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*explanations:&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_CALLBACK_PROGRAM is the program which calls this function&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;   IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                now the data definition needed for display&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;   I_SAVE allows the user to save his own layouts&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;     T_OUTTAB contains the data to be displayed in ALV&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&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;    write: /&lt;/P&gt;&lt;P&gt;    'Returncode',&lt;/P&gt;&lt;P&gt;    sy-subrc,&lt;/P&gt;&lt;P&gt;    'from FUNCTION REUSE_ALV_LIST_DISPLAY'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------" /&gt;&lt;P&gt;Reuse_alv_events_get-&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sappoint.com/ppt/alv.ppt" target="test_blank"&gt;http://www.sappoint.com/ppt/alv.ppt&lt;/A&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------------------" /&gt;&lt;P&gt;Reuse_alv_commentary_write-&amp;gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            i_logo             = 'ENJOYSAP_LOGO'&lt;/P&gt;&lt;P&gt;            it_list_commentary = heading.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------------" /&gt;&lt;P&gt;Reuse_alv_grid_display-&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            i_callback_program       = repname&lt;/P&gt;&lt;P&gt;            i_callback_pf_status_set = 'SET_PF_STATUS'&lt;/P&gt;&lt;P&gt;            i_callback_user_command  = 'USER_COMMAND'&lt;/P&gt;&lt;P&gt;            i_callback_top_of_page   = 'TOP_OF_PAGE'&lt;/P&gt;&lt;P&gt;            i_structure_name         = 'TI_ACRED'&lt;/P&gt;&lt;P&gt;            is_layout                = layout&lt;/P&gt;&lt;P&gt;            it_fieldcat              = fieldtab&lt;/P&gt;&lt;P&gt;            i_default                = 'X'&lt;/P&gt;&lt;P&gt;            i_save                   = g_save&lt;/P&gt;&lt;P&gt;            is_variant               = g_variant&lt;/P&gt;&lt;P&gt;            it_events                = events[]&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            t_outtab                 = ti_acred&lt;/P&gt;&lt;P&gt;       EXCEPTIONS&lt;/P&gt;&lt;P&gt;            program_error            = 1&lt;/P&gt;&lt;P&gt;            OTHERS                   = 2.&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;amp;lt;&amp;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;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Mrutyun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:14:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215194#M134584</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-17T10:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: sap alv examples</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215195#M134585</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;&amp;lt;b&amp;gt;Reuse_alv_list_display&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; type-pools: slis.
 
data: fieldcat type slis_t_fieldcat_alv,
fieldcat_ln like line of fieldcat,
fs_layout type slis_layout_alv,
t_layoout like standard table
of fs_layout.
 
data: begin of fs_spfli,
carrid type spfli-carrid,
connid type spfli-connid,
countryfr type spfli-countryfr,
cityfrom type spfli-cityfrom,
airpfrom type spfli-airpfrom,
countryto type spfli-countryto,
cityto type spfli-cityto,
airpto type spfli-airpto,
fltime type spfli-fltime,
deptime type spfli-deptime,
arrtime type spfli-arrtime,
distance type spfli-distance,
distid type spfli-distid,
fltype type spfli-fltype,
period type spfli-period,
checkbox,
color(3),
end of fs_spfli.
data:
begin of fs_table,
carrid type spfli-carrid,
connid type spfli-connid,
end of fs_table.
 
 
data: begin of fs_sflight,
check,
color(3).
include type sflight.
data:end of fs_sflight.
 
data:
begin of fs_table1,
carrid type sflight-carrid,
connid type sflight-connid,
fldate type sflight-fldate,
end of fs_table1.
 
data:
t_spfli like standard table
of fs_spfli.
 
data:
t_table like standard table
of fs_table.
 
data:
t_table1 like standard table
of fs_table1.
 
data:
t_sflight like standard table
of fs_sflight.
 
data:
t_sbook like standard table
of sbook.
 
 
data t_layout type slis_layout_alv.
 
select *
into corresponding fields of table t_spfli
from spfli.
 
perform start_list_viewer.
perform get_spfli_details.
 
*&amp;amp;--------------------------------------------------------------------*
*&amp;amp; Form SUB1
*&amp;amp;--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* --&amp;gt;RT_EXTAB text
*---------------------------------------------------------------------*
 
form sub1 using rt_extab type slis_t_extab.
 
data: flight type slis_extab.
flight-fcode = 'SFLIGHT'.
append flight to rt_extab.
set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.
 
endform. "SUB1
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Form START_LIST_VIEWER
*&amp;amp;---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&amp;gt; p1 text
* &amp;lt;-- p2 text
*----------------------------------------------------------------------*
 
form start_list_viewer .
 
data: pgm like sy-repid.
pgm = sy-repid.
 
fs_layout-box_fieldname = 'CHECKBOX'.
fs_layout-info_fieldname = 'COLOR'.
 
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = pgm
i_callback_pf_status_set = 'SUB1'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'SPFLI'
is_layout = fs_layout
tables
t_outtab = t_spfli
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. " START_LIST_VIEWER
 
 
********Process Call Back Events (Begin)***************************
 
form user_command using ucomm like sy-ucomm
selfield type slis_selfield.
 
case ucomm.
when 'SFLIGHT'.
selfield-refresh = 'X'.
perform get_spfli_details.
select *
from sflight
into corresponding fields of table t_sflight
for all entries in t_table
where carrid eq t_table-carrid
and connid eq t_table-connid.
 
perform display_sflight.
 
when 'SBOOK'.
selfield-refresh = 'X'.
perform get_sflight_details.
select *
from sbook
into corresponding fields of table t_sbook
for all entries in t_table1
where carrid eq t_table1-carrid
and connid eq t_table1-connid
and fldate eq t_table1-fldate.
 
perform display_sbook.
 
endcase.
endform. "USER_COMMAND
 
*&amp;amp;--------------------------------------------------------------------*
*&amp;amp; Form SUB2
*&amp;amp;--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* --&amp;gt;RT_EXTAB text
*---------------------------------------------------------------------*
 
form sub2 using rt_extab type slis_t_extab.
 
data: flight type slis_extab.
flight-fcode = 'SBOOK'.
append flight to rt_extab.
set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.
 
endform. "SUB2
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Form DISPLAY_SFLIGHT
*&amp;amp;---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&amp;gt; p1 text
* &amp;lt;-- p2 text
*----------------------------------------------------------------------*
 
form display_sflight .
 
data: pgm like sy-repid.
pgm = sy-repid.
 
clear t_layout.
fs_layout-box_fieldname = 'CHECK'.
fs_layout-info_fieldname = 'COLOR'.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = pgm
i_callback_pf_status_set = 'SUB2'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'SFLIGHT'
is_layout = fs_layout
tables
t_outtab = t_sflight
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_SFLIGHT
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Form GET_SPFLI_DETAILS
*&amp;amp;---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&amp;gt; p1 text
* &amp;lt;-- p2 text
*----------------------------------------------------------------------*
 
form get_spfli_details .
 
loop at t_spfli into fs_spfli.
if fs_spfli-checkbox = 'X'.
fs_spfli-color = 'C51'.
fs_spfli-checkbox = '1'.
fs_table-carrid = fs_spfli-carrid.
fs_table-connid = fs_spfli-connid.
append fs_table to t_table.
modify t_spfli from fs_spfli.
endif.
endloop.
endform. " GET_SFLIGHT_DETAILS
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Form GET_SFLIGHT_DETAILS
*&amp;amp;---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&amp;gt; p1 text
* &amp;lt;-- p2 text
*----------------------------------------------------------------------*
 
form get_sflight_details .
 
loop at t_sflight into fs_sflight.
if fs_sflight-check = 'X'.
fs_sflight-color = 'C71'.
fs_sflight-check = '1'.
fs_table1-carrid = fs_sflight-carrid.
fs_table1-connid = fs_sflight-connid.
fs_table1-fldate = fs_sflight-fldate.
append fs_table1 to t_table1.
modify t_sflight from fs_sflight.
endif.
endloop.
 
endform. " GET_SFLIGHT_DETAILS
 
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Form DISPLAY_SBOOK
*&amp;amp;---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&amp;gt; p1 text
* &amp;lt;-- p2 text
*----------------------------------------------------------------------*
 
form display_sbook .
 
data: pgm like sy-repid.
pgm = sy-repid.
 
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = pgm
i_structure_name = 'SBOOK'
tables
t_outtab = t_sbook
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_SBOOK


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt; Reuse_alv_fieldcatalog_merge&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; *data definition

tables:
marav. "Table MARA and table MAKT

*---------------------------------------------------------------------*
* Data to be displayed in ALV
* Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
* matically determine the fieldstructure from this source program
Data:
begin of imat occurs 100,
matnr like marav-matnr, "Material number
maktx like marav-maktx, "Material short text
matkl like marav-matkl, "Material group (so you can test to make
                        " intermediate sums)
ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
                        "make sums)
gewei like marav-gewei, "weight unit (just to be complete)
end of imat.

*---------------------------------------------------------------------*
* Other data needed
* field to store report name
data i_repid like sy-repid.
* field to check table length
data i_lines like sy-tabix.

*---------------------------------------------------------------------*
* Data for ALV display
TYPE-POOLS: SLIS.
data int_fcat type SLIS_T_FIELDCAT_ALV.

*---------------------------------------------------------------------*
select-options:
s_matnr for marav-matnr matchcode object MAT1.

*---------------------------------------------------------------------*
start-of-selection.

* read data into table imat
  select * from marav
  into corresponding fields of table imat
  where
  matnr in s_matnr.

* Check if material was found
  clear i_lines.
  describe table imat lines i_lines.
  if i_lines lt 1.
*   Using hardcoded write here for easy upload
    write: /
    'No materials found.'.
    exit.
  endif.

end-of-selection.
*---------------------------------------------------------------------*
*
* Now, we start with ALV
*
*---------------------------------------------------------------------*
*
*
* To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
* The fieldcatalouge can be generated by FUNCTION
* 'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
* report source, including this report.
* The only problem one might have is that the report and table names
* need to be in capital letters. (I had it :-( )
*
*
*---------------------------------------------------------------------*

* Store report name
  i_repid = sy-repid.

* Create Fieldcatalogue from internal table
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            I_PROGRAM_NAME         = i_repid
            I_INTERNAL_TABNAME     = 'IMAT'  "capital letters!
            I_INCLNAME             = i_repid
       CHANGING
            CT_FIELDCAT            = int_fcat
       EXCEPTIONS
            INCONSISTENT_INTERFACE = 1
            PROGRAM_ERROR          = 2
            OTHERS                 = 3.
*explanations:
*    I_PROGRAM_NAME is the program which calls this function
*
*    I_INTERNAL_TABNAME is the name of the internal table which you want
*                       to display in ALV
*
*    I_INCLNAME is the ABAP-source where the internal table is defined
*               (DATA....)
*      CT_FIELDCAT contains the Fieldcatalouge that we need later for
*      ALV display


  IF SY-SUBRC &amp;lt;&amp;gt; 0.
    write: /
    'Returncode',
    sy-subrc,
    'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
  ENDIF.

*This was the fieldcatlogue
*---------------------------------------------------------------------*
*
* And now, we are ready to display our list

* Call for ALV list display
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
*            I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
            I_CALLBACK_PROGRAM = i_repid
            IT_FIELDCAT        = int_fcat
            I_SAVE             = 'A'
       TABLES
            T_OUTTAB           = imat
       EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.
*
*explanations:
*    I_CALLBACK_PROGRAM is the program which calls this function
*
*    IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains
*                 now the data definition needed for display
*
*    I_SAVE allows the user to save his own layouts
*
*      T_OUTTAB contains the data to be displayed in ALV


  IF SY-SUBRC &amp;lt;&amp;gt; 0.
    write: /
    'Returncode',
    sy-subrc,
    'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt; Reuse_alv_events_get&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By using this  function module called 'REUSE_ALV_EVENTS_GET' where u get all the events like PF_STATUS_SET, TOP_OF_LIST, END_OF_PAGE,END_OF_LIST etc populated into an internal table So u can read this internal table and call the appropriate form to print the content at the end of the list. Below is the sample code for ur reference.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM build_events USING flag
CHANGING pa_events TYPE slis_t_event.

*Get all possible events
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = pa_events
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.

IF sy-subrc &amp;lt;&amp;gt; 0.
ENDIF.
* Specify events used in selection screen
READ TABLE pa_events WITH KEY name = slis_ev_top_of_page
INTO ls_events.
IF sy-subrc = 0.
IF flag = 1.
ls_events-form = 'TOP_OF_PAGE1'.
ELSEIF flag = 2.
ls_events-form = 'TOP_OF_PAGE2'.
ELSE.
ls_events-form = 'TOP_OF_PAGE3'.
ENDIF.
MODIFY pa_events FROM ls_events INDEX sy-tabix.
CLEAR ls_events.
ENDIF.

ENDFORM. "build_events

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Form top_of_page1
*&amp;amp;---------------------------------------------------------------------*
FORM top_of_page1.

WRITE: 'Last Year'.

ENDFORM. "TOP_OF_PAGE1

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Form top_of_page2
*&amp;amp;---------------------------------------------------------------------*
FORM top_of_page2.

WRITE: 'Budget'.

ENDFORM. "TOP_OF_PAGE2


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Form top_of_page3
*&amp;amp;---------------------------------------------------------------------*
FORM top_of_page3.

WRITE: 'This year'.
ENDFORM. "TOP_OF_PAGE3  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Reuse_alv_commentary_write &amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZALV                                                        *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;                                                                     *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
Report  ZALV  .

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,
      gt_events     type slis_t_event,
      gd_prntparams type slis_print_alv.


************************************************************************
*Start-of-selection.
START-OF-SELECTION.

perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
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-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_events
            is_print                = gd_prntparams
            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.                    " DATA_RETRIEVAL


*-------------------------------------------------------------------*
* Form  TOP-OF-PAGE                                                 *
*-------------------------------------------------------------------*
* ALV Report Header                                                 *
*-------------------------------------------------------------------*
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
      wa_header type slis_listheader,
      t_line like wa_header-info,
      ld_lines type i,
      ld_linesc(10) type c.

* Title
  wa_header-typ  = 'H'.
  wa_header-info = 'EKKO Table Report'.
  append wa_header to t_header.
  clear wa_header.

* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Date: '.
  CONCATENATE  sy-datum+6(2) '.'
               sy-datum+4(2) '.'
               sy-datum(4) INTO wa_header-info.   "todays date
  append wa_header to t_header.
  clear: wa_header.

* Total No. of Records Selected
  describe table it_ekko lines ld_lines.
  ld_linesc = ld_lines.
  concatenate 'Total No. of Records Selected: ' ld_linesc
                    into t_line separated by space.
  wa_header-typ  = 'A'.
  wa_header-info = t_line.
  append wa_header to t_header.
  clear: wa_header, t_line.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
       exporting
            it_list_commentary = t_header.
*            i_logo             = 'Z_LOGO'.
endform.


*------------------------------------------------------------------*
*       FORM USER_COMMAND                                          *
*------------------------------------------------------------------*
*       --&amp;gt; R_UCOMM                                                *
*       --&amp;gt; RS_SELFIELD                                            *
*------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.

* Check function code
  CASE r_ucomm.
    WHEN '&amp;amp;IC1'.
*   Check field clicked on within ALVgrid report
    IF rs_selfield-fieldname = 'EBELN'.
*     Read data table, using index of row user clicked on
      READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
*     Set parameter ID for transaction screen field
      SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
*     Sxecute transaction ME23N, and skip initial data entry screen
      CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDCASE.
ENDFORM.


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_EVENTS
*&amp;amp;---------------------------------------------------------------------*
*       Build events table
*----------------------------------------------------------------------*
form build_events.
  data: ls_event type slis_alv_event.

  call function 'REUSE_ALV_EVENTS_GET'
       exporting
            i_list_type = 0
       importing
            et_events   = gt_events[].
  read table gt_events with key name =  slis_ev_end_of_page
                           into ls_event.
  if sy-subrc = 0.
    move 'END_OF_PAGE' to ls_event-form.
    append ls_event to gt_events.
  endif.

    read table gt_events with key name =  slis_ev_end_of_list
                           into ls_event.
  if sy-subrc = 0.
    move 'END_OF_LIST' to ls_event-form.
    append ls_event to gt_events.
  endif.
endform.                    " BUILD_EVENTS


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_PRINT_PARAMS
*&amp;amp;---------------------------------------------------------------------*
*       Setup print parameters
*----------------------------------------------------------------------*
form build_print_params.
  gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
  gd_prntparams-no_coverpage = 'X'.
endform.                    " BUILD_PRINT_PARAMS


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  END_OF_PAGE
*&amp;amp;---------------------------------------------------------------------*
form END_OF_PAGE.
  data: listwidth type i,
        ld_pagepos(10) type c,
        ld_page(10)    type c.

  write: sy-uline(50).
  skip.
  write:/40 'Page:', sy-pagno .
endform.


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  END_OF_LIST
*&amp;amp;---------------------------------------------------------------------*
form END_OF_LIST.
  data: listwidth type i,
        ld_pagepos(10) type c,
        ld_page(10)    type c.

  skip.
  write:/40 'Page:', sy-pagno .
endform. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Reuse_alv_grid_display&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZALVTEST                                                    *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;                                                                     *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*

REPORT  ZALVTEST.

TABLES: mara, makt.

TYPE-POOLS: slis.

TYPES: BEGIN OF tab,
          matnr TYPE matnr,
          matkl TYPE matkl,
          maktx TYPE maktx,
       END OF tab.

DATA: itab TYPE TABLE OF tab,
      wa LIKE LINE OF itab.



*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   = 'MATNR'.
  fieldcatalog-seltext_m   = 'Material No'.
  fieldcatalog-col_pos     = 0.
  fieldcatalog-outputlen   = 10.
  fieldcatalog-emphasize   = 'X'.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'MATKL'.
  fieldcatalog-seltext_m   = 'Group'.
  fieldcatalog-col_pos     = 2.
   fieldcatalog-outputlen   = 5.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'MAKTX'.
  fieldcatalog-seltext_m   = 'Description'.
  fieldcatalog-col_pos     = 1.
  fieldcatalog-outputlen   = 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'.
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                = itab
       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 F~matnr F~matkl P~maktx
    INTO table itab
    FROM mara AS F INNER JOIN makt AS P
           ON F~matnr = P~matnr.

endform.                    " DATA_RETRIEVAL&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Nov 2007 07:00:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-alv-examples/m-p/1215195#M134585</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-28T07:00:18Z</dc:date>
    </item>
  </channel>
</rss>

