<?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 Subtotal in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422984#M822120</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;A href="http://www.sap-img.com/abap/what-is-alv-programming.htm" target="test_blank"&gt;http://www.sap-img.com/abap/what-is-alv-programming.htm&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;A href="http://www.erpgenie.com/abap/code/abap28.htm" target="test_blank"&gt;http://www.erpgenie.com/abap/code/abap28.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB .&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*Simple example to use ALV and to define the ALV data in an internal&lt;/P&gt;&lt;P&gt;*table&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Martin Schlegel, BearingPoint, December 2004&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;Thanks to Madhusudhan Sonee and Rama Krishna Kommineni for testing&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and feedback&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;/P&gt;&lt;P&gt;*For a very long time, people gave me the feeling that ALV is a&lt;/P&gt;&lt;P&gt;*complicated tool that is difficult to understand and to use.&lt;/P&gt;&lt;P&gt;*Lately I had to use it and I discovered that ALV is easy to use and&lt;/P&gt;&lt;P&gt;*saves a lot of work:&lt;/P&gt;&lt;P&gt;*ALV will generate the column headings on its own, so one does not need&lt;/P&gt;&lt;P&gt;*to work on headlines and transalation.&lt;/P&gt;&lt;P&gt;*ALV allows the user to select the columns he wants to see, so the user&lt;/P&gt;&lt;P&gt;*does not need to contact a developer for every change he likes to have.&lt;/P&gt;&lt;P&gt;*ALV allows the user to create his own sums, so &amp;#133;&lt;/P&gt;&lt;P&gt;*ALV has a simple way to work with internal tables.&lt;/P&gt;&lt;P&gt;*If you really want to save time, use ALV instead of write!&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*Please take 30 minutes to explore the following example and see how&lt;/P&gt;&lt;P&gt;*easy it is to use ALV!&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*data 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;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;yes, it is that simple. Go ahead and try yourself!&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;regards&lt;/P&gt;&lt;P&gt;sreelatha gullapalli&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Feb 2008 05:23:18 GMT</pubDate>
    <dc:creator>sreelatha_gullapalli</dc:creator>
    <dc:date>2008-02-26T05:23:18Z</dc:date>
    <item>
      <title>ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422983#M822119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to display Subtotal &amp;amp; total in my ALV like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Item        Material&lt;/P&gt;&lt;P&gt;______________________________________&lt;/P&gt;&lt;P&gt;1            100000012&lt;/P&gt;&lt;P&gt;______________________________________&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;______________________________________&lt;/P&gt;&lt;P&gt;1            100000040&lt;/P&gt;&lt;P&gt;1            100000040&lt;/P&gt;&lt;P&gt;______________________________________&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;______________________________________&lt;/P&gt;&lt;P&gt;1            100000050&lt;/P&gt;&lt;P&gt;1            100000050&lt;/P&gt;&lt;P&gt;1            100000050&lt;/P&gt;&lt;P&gt;1            100000050&lt;/P&gt;&lt;P&gt;______________________________________&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;_______________________________________&lt;/P&gt;&lt;P&gt;7(Total)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can we achive this ? Item field is simply an int field with constant 1. Subtotal of items should be dependent on materials.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried  below code but no result.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  alv_it_sort_subtotal&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      sort &amp;amp; subtotal&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM alv_it_sort_subtotal .&lt;/P&gt;&lt;P&gt;  PERFORM ale_sort&lt;/P&gt;&lt;P&gt;              USING 'MATNR' '' 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " alv_it_sort_subtotal&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  ale_sort&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM ale_sort  USING  fieldname&lt;/P&gt;&lt;P&gt;                      subtotal&lt;/P&gt;&lt;P&gt;                      up.&lt;/P&gt;&lt;P&gt;  CLEAR it_sort_subtotal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  it_sort_subtotal-fieldname = fieldname.&lt;/P&gt;&lt;P&gt;  it_sort_subtotal-subtot    = subtotal.&lt;/P&gt;&lt;P&gt;  it_sort_subtotal-up        = up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  APPEND it_sort_subtotal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " ale_sort&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Nik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 05:17:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422983#M822119</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T05:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422984#M822120</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;A href="http://www.sap-img.com/abap/what-is-alv-programming.htm" target="test_blank"&gt;http://www.sap-img.com/abap/what-is-alv-programming.htm&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;A href="http://www.erpgenie.com/abap/code/abap28.htm" target="test_blank"&gt;http://www.erpgenie.com/abap/code/abap28.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB .&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*Simple example to use ALV and to define the ALV data in an internal&lt;/P&gt;&lt;P&gt;*table&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Martin Schlegel, BearingPoint, December 2004&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;Thanks to Madhusudhan Sonee and Rama Krishna Kommineni for testing&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and feedback&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;/P&gt;&lt;P&gt;*For a very long time, people gave me the feeling that ALV is a&lt;/P&gt;&lt;P&gt;*complicated tool that is difficult to understand and to use.&lt;/P&gt;&lt;P&gt;*Lately I had to use it and I discovered that ALV is easy to use and&lt;/P&gt;&lt;P&gt;*saves a lot of work:&lt;/P&gt;&lt;P&gt;*ALV will generate the column headings on its own, so one does not need&lt;/P&gt;&lt;P&gt;*to work on headlines and transalation.&lt;/P&gt;&lt;P&gt;*ALV allows the user to select the columns he wants to see, so the user&lt;/P&gt;&lt;P&gt;*does not need to contact a developer for every change he likes to have.&lt;/P&gt;&lt;P&gt;*ALV allows the user to create his own sums, so &amp;#133;&lt;/P&gt;&lt;P&gt;*ALV has a simple way to work with internal tables.&lt;/P&gt;&lt;P&gt;*If you really want to save time, use ALV instead of write!&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*Please take 30 minutes to explore the following example and see how&lt;/P&gt;&lt;P&gt;*easy it is to use ALV!&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*data 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;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;yes, it is that simple. Go ahead and try yourself!&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;regards&lt;/P&gt;&lt;P&gt;sreelatha gullapalli&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 05:23:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422984#M822120</guid>
      <dc:creator>sreelatha_gullapalli</dc:creator>
      <dc:date>2008-02-26T05:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422985#M822121</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;DATA : w_fieldcat TYPE slis_fieldcat_alv,&lt;/P&gt;&lt;P&gt;          i_fieldcat TYPE slis_t_fieldcat_alv,&lt;/P&gt;&lt;P&gt;          gs_layout   TYPE slis_layout_alv,&lt;/P&gt;&lt;P&gt;          wa_sort1 TYPE slis_t_sortinfo_alv,&lt;/P&gt;&lt;P&gt;          wa_sort2 TYPE slis_sortinfo_alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; wa_sort2-spos = '01'.&lt;/P&gt;&lt;P&gt;  wa_sort2-up = 'X'.&lt;/P&gt;&lt;P&gt;  wa_sort2-fieldname = 'ITEM'.--&amp;gt; here give field name of item&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  APPEND wa_sort2 TO wa_sort1.&lt;/P&gt;&lt;P&gt;  CLEAR wa_sort2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; wa_sort2-spos = '02'.&lt;/P&gt;&lt;P&gt;  wa_sort2-up = 'X'.&lt;/P&gt;&lt;P&gt;  wa_sort2-fieldname = 'MATNR'.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  APPEND wa_sort2 TO wa_sort1.&lt;/P&gt;&lt;P&gt;  CLEAR wa_sort2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Field Catelog&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; w_fieldcat-tabname   = 'INTERNAL TABLE NAME'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-fieldname = 'FIELD NAME'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-do_sum    = 'X'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-outputlen = '10'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-col_pos   = '1'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-row_pos   = '1'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-seltext_l = c_seltext_l6.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  APPEND w_fieldcat TO i_fieldcat.&lt;/P&gt;&lt;P&gt;  CLEAR w_fieldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  w_fieldcat-tabname   = 'INTERNAL TABLE NAME'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-fieldname = 'FIELD NAME'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-do_sum    = 'X'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-outputlen = '15'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-col_pos   = '2'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-row_pos   = '1'.&lt;/P&gt;&lt;P&gt;  w_fieldcat-seltext_l = c_seltext_l7.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  APPEND w_fieldcat TO i_fieldcat.&lt;/P&gt;&lt;P&gt;  CLEAR w_fieldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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       = ws_repid&lt;/P&gt;&lt;P&gt;              i_callback_pf_status_set = 'GUI_STAT1'&lt;/P&gt;&lt;P&gt;              i_callback_user_command  = 'STAT'&lt;/P&gt;&lt;P&gt;              is_layout                = gs_layout&lt;/P&gt;&lt;P&gt;              it_fieldcat              = i_fieldcat[]&lt;/P&gt;&lt;P&gt;              it_sort                  = wa_sort1&lt;/P&gt;&lt;P&gt;         TABLES&lt;/P&gt;&lt;P&gt;              t_outtab                 = i_zaw_pol_plan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 05:25:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422985#M822121</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T05:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422986#M822122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Guys read the Question properly.&lt;/P&gt;&lt;P&gt;The subtotal of items should be depends on the material field&lt;/P&gt;&lt;P&gt;The content you guys game i already tried but no result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Nik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 05:30:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422986#M822122</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T05:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422987#M822123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;Try this:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;CLEAR LS_FIELDCAT.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;LS_FIELDCAT-FIELDNAME      = 'COUNT'. " say item field&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;LS_FIELDCAT-TABNAME        = 'IT_FINAL'. " final itab&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;LS_FIELDCAT-DO_SUM = 'X'.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;APPEND LS_FIELDCAT TO LT_FIELDCAT. " filed catalog&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;CLEAR LS_SORT.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;LS_SORT-FIELDNAME         = 'MATNR'.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;LS_SORT-TABNAME           = 'IT_FINAL'.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;LS_SORT-SUBTOT            = 'X'.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;&lt;STRONG&gt;APPEND LS_SORT TO GT_SORT.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;i think this works out. if any concerns do reply....&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Ram&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 05:48:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422987#M822123</guid>
      <dc:creator>former_member206396</dc:creator>
      <dc:date>2008-02-26T05:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422988#M822124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Problem Solved. &lt;/P&gt;&lt;P&gt;I forgot to write the it_sort in the AVL GRID Function Module.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 05:56:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422988#M822124</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T05:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422989#M822125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the below code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

TABLES: mara.

SELECT-OPTIONS: s_matnr FOR mara-matnr.

types: begin of ty_marc,
         matnr type marc-matnr,
         werks type marc-werks,
         count type i,
       end of ty_marc.

data: it_marc type standard table of ty_marc with header line.

START-OF-SELECTION.

  SELECT matnr werks FROM marc INTO TABLE it_marc WHERE matnr IN s_matnr and werks in ('0888', '0811').

  loop at it_marc.
    it_marc-count = 1.
    modify it_marc transporting count.
  endloop.

"* Definition for Object Oriented ALV
  DATA: gr_table      TYPE REF TO cl_salv_table.
  DATA: gr_sorts      TYPE REF TO cl_salv_sorts.
  DATA: gr_agg        TYPE REF TO cl_salv_aggregations.
  DATA: gr_agg2       TYPE REF TO cl_salv_aggregation.
  DATA: gr_display    TYPE REF TO cl_salv_display_settings.
  DATA: gr_layout     TYPE REF TO cl_salv_layout.
  DATA: ls_key        TYPE salv_s_layout_key.


"* Display ALV as a Grid
  TRY.
      cl_salv_table=&amp;gt;factory( IMPORTING r_salv_table = gr_table
                              CHANGING  t_table      = it_marc[] ).
    CATCH cx_salv_msg.
  ENDTRY.
    TRY.
        gr_agg = gr_table-&amp;gt;get_aggregations( ).
        CALL METHOD gr_agg-&amp;gt;add_aggregation
          EXPORTING
            columnname  = 'COUNT'
            aggregation = if_salv_c_aggregation=&amp;gt;total
          RECEIVING
            value       = gr_agg2.
      CATCH cx_salv_data_error .
      CATCH cx_salv_not_found .
      CATCH cx_salv_existing .
    ENDTRY.
"* Set up Sorts
    TRY.
        gr_sorts = gr_table-&amp;gt;get_sorts( ).
        CALL METHOD gr_sorts-&amp;gt;add_sort
          EXPORTING
            columnname = 'MATNR'
            position   = 1
            sequence   = if_salv_c_sort=&amp;gt;sort_up
            subtotal   = if_salv_c_bool_sap=&amp;gt;true
            group      = if_salv_c_sort=&amp;gt;group_none
            obligatory = if_salv_c_bool_sap=&amp;gt;false.
      CATCH cx_salv_data_error .
      CATCH cx_salv_not_found .
      CATCH cx_salv_existing .
    ENDTRY.

"* Add layout variants in report
    TRY.
      gr_layout = gr_table-&amp;gt;get_layout( ).
"*... set the Layout Key
      ls_key-report = sy-repid.
      gr_layout-&amp;gt;set_key( ls_key ).
"*... set usage of default Layouts
      gr_layout-&amp;gt;set_default( abap_true ).
"*... set Layout save restriction
      gr_layout-&amp;gt;set_save_restriction( if_salv_c_layout=&amp;gt;restrict_none ).
    ENDTRY.

    TRY.
"* Display ALV
      gr_table-&amp;gt;display( ).
    ENDTRY.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Balaji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 06:18:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422989#M822125</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T06:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422990#M822126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Problem Solved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Mar 2008 01:31:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422990#M822126</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-08T01:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422991#M822127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thats good. Please close the thread and reward points for helpful answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Balaji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2008 06:42:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422991#M822127</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-10T06:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422992#M822128</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;Can you explain me how to get the title for the sub-totals and totals?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raghu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2008 11:23:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422992#M822128</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-15T11:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422993#M822129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;solved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Apr 2009 12:27:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-subtotal/m-p/3422993#M822129</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-26T12:27:03Z</dc:date>
    </item>
  </channel>
</rss>

