<?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: SORT IN ALV with Objects in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754860#M640929</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right now my reprt is like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matnr     total quant                  kunnr            quant&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------------------------------" /&gt;&lt;P&gt;mat1       500                           kun1              100&lt;/P&gt;&lt;P&gt;mat1       500                           kun2              400&lt;/P&gt;&lt;P&gt;mat2      300                           kun3               150&lt;/P&gt;&lt;P&gt;mat2      300                           kun1               150&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My output should look like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matnr     total quant                  kunnr            quant&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------------------------------" /&gt;&lt;P&gt;mat1       500                           kun1              100   &lt;/P&gt;&lt;P&gt;                                              kun2              400&lt;/P&gt;&lt;P&gt;mat2      300                           kun3               150&lt;/P&gt;&lt;P&gt;                                              kun1               150&lt;/P&gt;&lt;P&gt;I am using ALV grid in ABAp objects. There is only one internal table that is passed to the ALV.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Sep 2007 20:31:05 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-12T20:31:05Z</dc:date>
    <item>
      <title>SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754857#M640926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi , I want to build a sort table for my ALV output to show duplicate values only once. Currently I have three fields : material number , description and quantity , that are being repeated for all entries. How to use a sort and how to pass it to the field catalog .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 20:14:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754857#M640926</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T20:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754858#M640927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can write simple logic :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATES FROM itab comparing matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Seshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 20:21:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754858#M640927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T20:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754859#M640928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot to tell you before deleting the duplicates &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just use  sort itab by matnr and delete it.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nothing with fieldcatlog,you just need add the code after select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Seshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 20:23:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754859#M640928</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T20:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754860#M640929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right now my reprt is like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matnr     total quant                  kunnr            quant&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------------------------------" /&gt;&lt;P&gt;mat1       500                           kun1              100&lt;/P&gt;&lt;P&gt;mat1       500                           kun2              400&lt;/P&gt;&lt;P&gt;mat2      300                           kun3               150&lt;/P&gt;&lt;P&gt;mat2      300                           kun1               150&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My output should look like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matnr     total quant                  kunnr            quant&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------------------------------" /&gt;&lt;P&gt;mat1       500                           kun1              100   &lt;/P&gt;&lt;P&gt;                                              kun2              400&lt;/P&gt;&lt;P&gt;mat2      300                           kun3               150&lt;/P&gt;&lt;P&gt;                                              kun1               150&lt;/P&gt;&lt;P&gt;I am using ALV grid in ABAp objects. There is only one internal table that is passed to the ALV.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 20:31:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754860#M640929</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T20:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754861#M640930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please see this revised post , this is more clear. &lt;/P&gt;&lt;P&gt;This is the display I am getting right now.&lt;/P&gt;&lt;P&gt;Matnr total quant kunnr quant&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------------------------------" /&gt;&lt;P&gt;mat1 500 kun1 100&lt;/P&gt;&lt;P&gt;mat1 500 kun2 400&lt;/P&gt;&lt;P&gt;mat2 300 kun3 150&lt;/P&gt;&lt;P&gt;mat2 300 kun1 150&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My output should look like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matnr&lt;DEL&gt;- total quant&lt;/DEL&gt;&lt;DEL&gt;- kunnr&lt;/DEL&gt;--- quant&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------------------------------" /&gt;&lt;P&gt;mat1--&lt;DEL&gt;&lt;/DEL&gt;&lt;/P&gt;&lt;HR originaltext="----" /&gt; 500&lt;DEL&gt;&lt;HR originaltext="------" /&gt; kun1&lt;/DEL&gt;--- 100 &lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------" /&gt;&lt;P&gt;kun2 -&lt;/P&gt;&lt;HR originaltext="--------" /&gt;&lt;P&gt;400&lt;/P&gt;&lt;P&gt;mat2--&lt;DEL&gt;&lt;/DEL&gt;&lt;/P&gt;&lt;HR originaltext="-----" /&gt; 300&lt;DEL&gt;&lt;HR originaltext="----" /&gt; kun3&lt;/DEL&gt;--&lt;P&gt;&lt;/P&gt;&lt;HR originaltext="---" /&gt;&lt;P&gt; 150&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------------" /&gt;&lt;P&gt;kun1----&lt;/P&gt;&lt;HR originaltext="---" /&gt;&lt;P&gt; 150&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 20:40:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754861#M640930</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T20:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754862#M640931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you want to display repeated data only once but not delete the records,&lt;/P&gt;&lt;P&gt;then the solution is to use the "sort table catalog" , a kind of input table for function REUSE_ALV* . Modify the "sort catalog" by adding those fields and sort order , &lt;/P&gt;&lt;P&gt;then pass the "sort catalog" to the function along with other input ( e.g. field catalog ).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 20:42:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754862#M640931</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T20:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754863#M640932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using ALV in abap Objects. If there is a sample code for achieving the output , I will really appreciate it. &lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 20:46:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754863#M640932</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T20:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754864#M640933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the below code ,bold one is important..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just declare one more internal table and use control break statements ..,use total qty field as charcter for ALV Internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT ZTEST_ALV1 no standard page heading.&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; Good Example for Object Oriented ALV&lt;/P&gt;&lt;/LI&gt;&lt;/UL&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;Handles Double click&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;class cl_event_receiver definition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;public section.&lt;/P&gt;&lt;P&gt;methods handle_double_click&lt;/P&gt;&lt;P&gt;        for event double_click of cl_gui_alv_grid&lt;/P&gt;&lt;P&gt;        importing e_row e_column.&lt;/P&gt;&lt;P&gt;private section.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class cl_event_receiver implementation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;method handle_double_click.&lt;/P&gt;&lt;P&gt;perform drill_down using e_row-index.&lt;/P&gt;&lt;P&gt;endmethod.&lt;/P&gt;&lt;P&gt;endclass.&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;Data Declaration Part&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables : makt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;types : begin of ty_itab ,&lt;/P&gt;&lt;P&gt;        matnr(18) type c,&lt;/P&gt;&lt;P&gt;        tqty like vbap-kwmeng,&lt;/P&gt;&lt;P&gt;        kunnr(10) type c,&lt;/P&gt;&lt;P&gt;        qty like vbap-kwmeng,&lt;/P&gt;&lt;P&gt;        end of ty_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data itab type standard table of ty_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data wa_itab like line of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data wa_itab2 like line of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;ALV Internal table&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;Internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;types : begin of ty_itab1 ,&lt;/P&gt;&lt;P&gt;        matnr(18) type c,&lt;/P&gt;&lt;P&gt;        tqty(15) type c,&lt;/P&gt;&lt;P&gt;        kunnr(10) type c,&lt;/P&gt;&lt;P&gt;        qty like vbap-kwmeng,&lt;/P&gt;&lt;P&gt;        end of ty_itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : itab1 type standard table of ty_itab1.&lt;/P&gt;&lt;P&gt;data : wa_itab1 like line of itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;ALV Variable&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data : v_repid like sy-repid,&lt;/P&gt;&lt;P&gt;       v_dynnr like sy-dynnr,&lt;/P&gt;&lt;P&gt;       ok_code like sy-ucomm,&lt;/P&gt;&lt;P&gt;       cl_gui_custom_container type ref to cl_gui_custom_container,&lt;/P&gt;&lt;P&gt;       cl_gui_alv_grid type ref to cl_gui_alv_grid,&lt;/P&gt;&lt;P&gt;       cl_event_reciver type  ref to cl_event_receiver,&lt;/P&gt;&lt;P&gt;       layout type lvc_s_layo,&lt;/P&gt;&lt;P&gt;       fieldcat type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : flag type c.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill the default values&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;initialization.&lt;/P&gt;&lt;P&gt;v_repid = sy-repid.&lt;/P&gt;&lt;P&gt;v_dynnr = sy-dynnr.&lt;/P&gt;&lt;P&gt;&lt;/P&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;Get the data from MAKT Table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;perform get_data_makt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Call Screen&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;perform call_screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  get_data_makt&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;     Get the data from makt table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM get_data_makt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_itab-matnr = 'Mat1'.&lt;/P&gt;&lt;P&gt;wa_itab-tqty =  '500'.&lt;/P&gt;&lt;P&gt;wa_itab-kunnr = 'Kun1'.&lt;/P&gt;&lt;P&gt;wa_itab-qty = '100'.&lt;/P&gt;&lt;P&gt;append wa_itab to itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_itab-matnr = 'Mat1'.&lt;/P&gt;&lt;P&gt;wa_itab-tqty =  '500'.&lt;/P&gt;&lt;P&gt;wa_itab-kunnr = 'Kun2'.&lt;/P&gt;&lt;P&gt;wa_itab-qty = '400'.&lt;/P&gt;&lt;P&gt;append wa_itab to itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_itab-matnr = 'Mat2'.&lt;/P&gt;&lt;P&gt;wa_itab-tqty =  '300'.&lt;/P&gt;&lt;P&gt;wa_itab-kunnr = 'Kun3'.&lt;/P&gt;&lt;P&gt;wa_itab-qty = '150'.&lt;/P&gt;&lt;P&gt;append wa_itab to itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_itab-matnr = 'Mat2'.&lt;/P&gt;&lt;P&gt;wa_itab-tqty =  '300'.&lt;/P&gt;&lt;P&gt;wa_itab-kunnr = 'Kun1'.&lt;/P&gt;&lt;P&gt;wa_itab-qty = '150'.&lt;/P&gt;&lt;P&gt;append wa_itab to itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort itab by matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;* Use internal table control break statements&lt;/P&gt;&lt;P&gt;loop at itab into wa_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;move wa_itab to wa_itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at new tqty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;move wa_itab2-matnr to wa_itab1-matnr.&lt;/P&gt;&lt;P&gt;move wa_itab2-tqty to wa_itab1-tqty.&lt;/P&gt;&lt;P&gt;move wa_itab2-kunnr to wa_itab1-kunnr.&lt;/P&gt;&lt;P&gt;move wa_itab2-qty to wa_itab1-qty.&lt;/P&gt;&lt;P&gt;flag = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if flag ne 'X'.&lt;/P&gt;&lt;P&gt;move space to wa_itab1-tqty.&lt;/P&gt;&lt;P&gt;move wa_itab2-kunnr to wa_itab1-kunnr.&lt;/P&gt;&lt;P&gt;move wa_itab2-qty to wa_itab1-qty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append wa_itab1 to itab1.&lt;/P&gt;&lt;P&gt;clear : wa_itab,&lt;/P&gt;&lt;P&gt;        flag,&lt;/P&gt;&lt;P&gt;        wa_itab1,&lt;/P&gt;&lt;P&gt;        wa_itab2.&lt;/P&gt;&lt;P&gt;endloop.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " get_data_makt&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  call_screen&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;      Screen 1000&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM call_screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call screen 1000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " call_screen&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  USER_COMMAND_1000  INPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE USER_COMMAND_1000 INPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case ok_code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when 'EXIT'.&lt;/P&gt;&lt;P&gt;leave to screen 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when 'BACK'.&lt;/P&gt;&lt;P&gt;leave to screen 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when 'CANC'.&lt;/P&gt;&lt;P&gt;leave to screen 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDMODULE.                 " USER_COMMAND_1000  INPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Module  STATUS_1000  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE STATUS_1000 OUTPUT.&lt;/P&gt;&lt;P&gt;  SET PF-STATUS '1000'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; SET TITLEBAR 'xxx'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OBJECT CL_GUI_CUSTOM_CONTAINER&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   PARENT                      =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    CONTAINER_NAME              = 'GRID1'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   STYLE                       =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   LIFETIME                    = lifetime_default&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    REPID                       = v_repid&lt;/P&gt;&lt;P&gt;    DYNNR                       = v_dynnr&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   NO_AUTODEF_PROGID_DYNNR     =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  EXCEPTIONS&lt;/P&gt;&lt;P&gt;    CNTL_ERROR                  = 1&lt;/P&gt;&lt;P&gt;    CNTL_SYSTEM_ERROR           = 2&lt;/P&gt;&lt;P&gt;    CREATE_ERROR                = 3&lt;/P&gt;&lt;P&gt;    LIFETIME_ERROR              = 4&lt;/P&gt;&lt;P&gt;    LIFETIME_DYNPRO_DYNPRO_LINK = 5&lt;/P&gt;&lt;P&gt;    others                      = 6&lt;/P&gt;&lt;P&gt;    .&lt;/P&gt;&lt;P&gt;IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OBJECT CL_GUI_ALV_GRID&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_SHELLSTYLE      = 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_LIFETIME        =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    I_PARENT          = cl_gui_custom_container&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_APPL_EVENTS     = space&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_PARENTDBG       =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_APPLOGPARENT    =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_GRAPHICSPARENT  =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_USE_VARIANT_CLASS = SPACE&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_NAME            =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  EXCEPTIONS&lt;/P&gt;&lt;P&gt;    ERROR_CNTL_CREATE = 1&lt;/P&gt;&lt;P&gt;    ERROR_CNTL_INIT   = 2&lt;/P&gt;&lt;P&gt;    ERROR_CNTL_LINK   = 3&lt;/P&gt;&lt;P&gt;    ERROR_DP_CREATE   = 4&lt;/P&gt;&lt;P&gt;    others            = 5&lt;/P&gt;&lt;P&gt;    .&lt;/P&gt;&lt;P&gt;IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create Event Receiver&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;create object cl_event_reciver.&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;ALV Specific .Data Selection&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Populate field catalog&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;perform get_fieldcatlog.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL METHOD cl_gui_alv_grid-&amp;gt;SET_TABLE_FOR_FIRST_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_BYPASSING_BUFFER            =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_BUFFER_ACTIVE               =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_CONSISTENCY_CHECK           =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    I_STRUCTURE_NAME              = 'I_MAKT'&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IS_VARIANT                    =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    I_SAVE                        = 'U'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   I_DEFAULT                     = 'X'&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IS_LAYOUT                     =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IS_PRINT                      =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IT_SPECIAL_GROUPS             =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IT_TOOLBAR_EXCLUDING          =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IT_HYPERLINK                  =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IT_ALV_GRAPHICS               =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IT_EXCEPT_QINFO               =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CHANGING&lt;/P&gt;&lt;P&gt;    IT_OUTTAB                     = itab1&lt;/P&gt;&lt;P&gt;    IT_FIELDCATALOG               = fieldcat&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IT_SORT                       =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IT_FILTER                     =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  EXCEPTIONS&lt;/P&gt;&lt;P&gt;    INVALID_PARAMETER_COMBINATION = 1&lt;/P&gt;&lt;P&gt;    PROGRAM_ERROR                 = 2&lt;/P&gt;&lt;P&gt;    TOO_MANY_LINES                = 3&lt;/P&gt;&lt;P&gt;    others                        = 4&lt;/P&gt;&lt;P&gt;        .&lt;/P&gt;&lt;P&gt;IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set handler cl_event_reciver-&amp;gt;handle_double_click for cl_gui_alv_grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDMODULE.                 " STATUS_1000  OUTPUT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  get_fieldcatlog&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM get_fieldcatlog.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data ls_fcat type lvc_s_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refresh fieldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Material #&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;clear ls_fcat.&lt;/P&gt;&lt;P&gt;ls_fcat-reptext = 'Material Number'.&lt;/P&gt;&lt;P&gt;ls_fcat-coltext = 'Material Number'.&lt;/P&gt;&lt;P&gt;ls_fcat-fieldname = 'MATNR'.&lt;/P&gt;&lt;P&gt;ls_fcat-tabname = 'ITAB1'.&lt;/P&gt;&lt;P&gt;ls_fcat-outputlen = '18'.&lt;/P&gt;&lt;P&gt;ls_fcat-col_pos = 1.&lt;/P&gt;&lt;P&gt;append ls_fcat to fieldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Material #&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;clear ls_fcat.&lt;/P&gt;&lt;P&gt;ls_fcat-reptext = 'Total Qty'.&lt;/P&gt;&lt;P&gt;ls_fcat-coltext = 'Total Qty'.&lt;/P&gt;&lt;P&gt;ls_fcat-fieldname = 'TQTY'.&lt;/P&gt;&lt;P&gt;ls_fcat-tabname = 'ITAB1'.&lt;/P&gt;&lt;P&gt;ls_fcat-outputlen = '15'.&lt;/P&gt;&lt;P&gt;ls_fcat-col_pos = 2.&lt;/P&gt;&lt;P&gt;append ls_fcat to fieldcat.&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;Material #&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;clear ls_fcat.&lt;/P&gt;&lt;P&gt;ls_fcat-reptext = 'Customer Number'.&lt;/P&gt;&lt;P&gt;ls_fcat-coltext = 'Customer Number'.&lt;/P&gt;&lt;P&gt;ls_fcat-fieldname = 'KUNNR'.&lt;/P&gt;&lt;P&gt;ls_fcat-tabname = 'ITAB1'.&lt;/P&gt;&lt;P&gt;ls_fcat-outputlen = '18'.&lt;/P&gt;&lt;P&gt;ls_fcat-col_pos = 3.&lt;/P&gt;&lt;P&gt;append ls_fcat to fieldcat.&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;Material #&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;clear ls_fcat.&lt;/P&gt;&lt;P&gt;ls_fcat-reptext = 'QTY'.&lt;/P&gt;&lt;P&gt;ls_fcat-coltext = 'QTY'.&lt;/P&gt;&lt;P&gt;ls_fcat-fieldname = 'QTY'.&lt;/P&gt;&lt;P&gt;ls_fcat-tabname = 'ITAB1'.&lt;/P&gt;&lt;P&gt;ls_fcat-outputlen = '18'.&lt;/P&gt;&lt;P&gt;ls_fcat-col_pos = 4.&lt;/P&gt;&lt;P&gt;append ls_fcat to 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;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " get_fieldcatlog&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  drill_down&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     --&amp;gt;P_E_ROW_INDEX  text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM drill_down USING    P_E_ROW_INDEX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*read table i_makt into wa_makt index p_e_row_index.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*set parameter id 'MAT' field wa_makt-matnr.&lt;/P&gt;&lt;P&gt;*call transaction 'MM02' and skip first screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " drill_down&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Seshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 21:15:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754864#M640933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T21:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754865#M640934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem that I am facing does not get solved by using these events. I have to actually use event handler to input a value , this should be subtracted from the total quantity for each block of code for matnr. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Thank you Seshu for your help. ,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 21:23:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754865#M640934</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T21:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754866#M640935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Which version of ALV objects are you using?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CL_GUI_ALV_GRID and related clases or CL_SALV_TABLE and related classes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;They're not the same; always please identify the actual class name since there is more than one way to do this in objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For CL_GUI_ALV_GRID, you have to set values in the field catalog and sort table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: gt_sort TYPE lvc_t_sort,
      gs_sort TYPE lvc_t_sort.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To set a field as a sort field, you create a sort table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
refresh gt_sort. 

clear gs_sort. 
gs_sort-fieldname = 'FIELD1'. 
gs_sort-spos = 1. 
gs_sort-up = 'X'. 
*gs_sort-down = 'X'.   " only do one of up or down, depending on desired sort order
gs_sort-subtot = 'X'.   "subtotal is optional
append gs_sort to gt_sort.

clear gs_sort. 
gs_sort-fieldname = 'FIELD2'. 
gs_sort-spos = 2. 
gs_sort-up = 'X'. 
*gs_sort-down = 'X'.   " only do one of up or down, depending on desired sort order
gs_sort-subtot = 'X'.   "optional
append gs_sort to gt_sort.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc for as many sort fields as needed&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then to identify the fields to be subtotaled, set the DO_SUM attribute for each field in the field catalog that should be subtotaled:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;gt_fieldcat-do_sum = 'X'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would add the sort table to you method call for SET_TABLE_FOR_FIRST_DISPLAY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    CALL METHOD g_alv-&amp;gt;set_table_for_first_display
      EXPORTING
        is_variant           = gs_variant   
        i_save               = 'A'            
        is_layout            = gs_layout
        it_toolbar_excluding = gt_toolbar_excl
      CHANGING
        it_outtab            = gt_alv_grid_tab
        it_fieldcatalog      = gt_fieldcat
        it_sort              = gt_sort.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you wanted to change the sort later under program control, you would call the method SET_SORT_CRITERIA&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL METHOD g_alv-&amp;gt;set_sort_criteria
  EXPORTING
    it_sort                   = gt_sort
*  EXCEPTIONS
*    NO_FIELDCATALOG_AVAILABLE = 1
*    others                    = 2&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For SALV&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  DATA: lr_sorts            TYPE REF TO cl_salv_sorts.
  DATA: lr_agg              TYPE REF TO cl_salv_aggregations.

  TRY.
      lr_sorts = gr_table-&amp;gt;get_sorts( ).
      lr_sorts-&amp;gt;add_sort( columnname = 'FIELD1'     subtotal = gc_true ).  
      lr_sorts-&amp;gt;add_sort( columnname = 'FIELD2'    subtotal = gc_true ).
      lr_sorts-&amp;gt;add_sort( columnname = 'FIELD3'    subtotal = gc_true ).  "subtotal is optional for each field

etc

    CATCH cx_salv_existing.                             "#EC NO_HANDLER
    CATCH cx_salv_not_found.                            "#EC NO_HANDLER
    CATCH cx_salv_data_error.                           "#EC NO_HANDLER
  ENDTRY.

  TRY.
      lr_agg = gr_table-&amp;gt;get_aggregations( ).
      lr_agg-&amp;gt;add_aggregation( 'FIELD4' ).
      lr_agg-&amp;gt;add_aggregation( 'FIELD5' ).

etc

    CATCH cx_salv_existing.                             "#EC NO_HANDLER
    CATCH cx_salv_not_found.                            "#EC NO_HANDLER
    CATCH cx_salv_data_error.                           "#EC NO_HANDLER
  ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;good luck&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 21:48:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754866#M640935</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T21:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754867#M640936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi , thank you for the code , however the output remains unchanged. &lt;/P&gt;&lt;P&gt;I am using CL_GUI_ALV_GRID , had created the sort table the way you showed , and also passed it to the set_table_for_first_display ,, but there is no change inthe out put I also put the method go_grid-&amp;gt;set_sort_criteria right after set_table_for_first _diplay , There is still no change. I am able to see the material numbers and the qunatity fields repeated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 23:03:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754867#M640936</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T23:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754868#M640937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hmmm &lt;/P&gt;&lt;P&gt;i clear the no_merging in gs_layout and fieldcat in my program , but it does not work either .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2007 01:21:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754868#M640937</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-13T01:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754869#M640938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check Std progarams BCALV *  OR RSDEMO * in SE38 for ALV OOPs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rewards if useful...................&lt;/P&gt;&lt;P&gt;Minal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2007 03:04:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754869#M640938</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-13T03:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: SORT IN ALV with Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754870#M640939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Krish, i have run into this problem with sorting on CL_GUI_ALV_GRID, where the merging feature does not work, regardless of the setting of the no_merging flag, and I do not have a solution for that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In such cases, I have generally converted to SALV, unless I need input/edit features that SALV does not have, and in that case I just live with the unmerged cells.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While the answer that I gave above is the "textbook" correct answer for sorting with CL_GUI_ALV_GRID, it appears that problems with the merge feature in CL_GUI_ALV_GRID still exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There appear to be some bugs in particular releases related to ALV and cell merging.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, see&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.elec.ucl.ac.be/logistique/informatique/SAP/Manual-6.4r4/relnotes/new.htm" target="test_blank"&gt;http://www.elec.ucl.ac.be/logistique/informatique/SAP/Manual-6.4r4/relnotes/new.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which highlight when bug fixes were released.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In particular note the following (for example):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Release 6.40 rev 2 (June 7, 2005)
Bugfixes

     * Grid control: 
          * The titlebar has not been displayed when the toolbar did not have any
             buttons. 
          * The methods SelectedRowsType2() and  SelectedRows2() were missing, 
             causing an ABAP dump in case they were called by the application. 
          * The wrong column was sorted after pressing the sort button in the toolbar. 
          * Rows can now be (de)selected by ctrl-click. 
          * Row selection buttons have been missing in some cases. 
          * Merging cells of several columns is now also supported for complete
             columns, not only for particular cells. 
          * In some cases, the background color of non-changeable cells has been
            wrong.
          * The new data of a currently edited cell now is sent to the application
             server. 
          * Reordering columns by Drag &amp;amp; Drop has not been reported correctly.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are on a release prior to the one specified, you may still have problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if you are doing output only, it should be relatively easy to convert to SALV.   SALV is nice in that you don't have to handcode the field catalog.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rich Heilman, who is a regular on SDN, did a nice write up on SALV, which is available on-line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/207dc670-6e8e-2910-3297-d1a1ae9c04e8" target="test_blank"&gt;https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/207dc670-6e8e-2910-3297-d1a1ae9c04e8&lt;/A&gt; &lt;B&gt;[original link is broken]&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use SE84, Info system and search for program examples starting SALV*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2007 22:40:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-in-alv-with-objects/m-p/2754870#M640939</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-13T22:40:17Z</dc:date>
    </item>
  </channel>
</rss>

