<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: alv in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975280#M702289</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 sample report to color an alv&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZALVCOLOR                                                   *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;                                                                     *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*

REPORT  ZALVCOLOR                               .

DATA : mara TYPE mara.                 " General Material Data

TYPE-POOLS: slis.                      " ALV Global types

FIELD-SYMBOLS :
  &amp;lt;data&amp;gt; TYPE table.                   " Data to display

SELECT-OPTIONS :
  s_matnr FOR mara-matnr.              " Material number

SELECTION-SCREEN :
  SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '50' OBLIGATORY.
SELECTION-SCREEN END OF LINE.

*---------------------------------------------------------------------*
INITIALIZATION.

  v_1 = 'Maximum of lines to display'.

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_data.

  PERFORM f_display_data.

*---------------------------------------------------------------------*
*      Form  f_read_data
*---------------------------------------------------------------------*
FORM f_read_data.

  FIELD-SYMBOLS :
    &amp;lt;field&amp;gt;    TYPE ANY,
    &amp;lt;field2&amp;gt;   TYPE ANY,
    &amp;lt;header&amp;gt;   TYPE ANY,
    &amp;lt;header2&amp;gt;  TYPE ANY,
    &amp;lt;lt_data&amp;gt;  TYPE table.             " Data read from DB

  DATA:
    lp_struct  TYPE REF TO data,
    lp_struct2 TYPE REF TO data,
    lp_table   TYPE REF TO data,       " Pointer to dynamic table
    lp_table2  TYPE REF TO data,       " Pointer to dynamic table
    ls_lvc_cat TYPE lvc_s_fcat,
    lt_lvc_cat TYPE lvc_t_fcat.        " Field catalog

* First column
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'MATNR'.
  ls_lvc_cat-ref_table = 'MARA'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* 2nd column
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'MAKTX'.
  ls_lvc_cat-ref_table = 'MAKT'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* 3rd column
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'MATKL'.
  ls_lvc_cat-ref_table = 'MARA'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* Create 1st internal table
  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
    EXPORTING it_fieldcatalog = lt_lvc_cat
    IMPORTING ep_table = lp_table.

  ASSIGN lp_table-&amp;gt;* TO &amp;lt;lt_data&amp;gt;.

* Read data into 1st internal table
  SELECT matnr maktx matkl
    INTO TABLE &amp;lt;lt_data&amp;gt;
    FROM v_matnr
      UP TO p_max ROWS
   WHERE matnr IN s_matnr.

* Create 2nd internal table
* Checkbox
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'CHECKBOX'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* Table color
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'TABCOLOR'.
  ls_lvc_cat-ref_table = 'CALENDAR_TYPE'.
  ls_lvc_cat-ref_field = 'COLTAB'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* Create 2nd internal table
  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
    EXPORTING it_fieldcatalog = lt_lvc_cat
    IMPORTING ep_table = lp_table2.

  ASSIGN lp_table2-&amp;gt;* TO &amp;lt;data&amp;gt;.

* Create structure = structure of the 1st internal table
  CREATE DATA lp_struct LIKE LINE OF &amp;lt;lt_data&amp;gt;.
  ASSIGN lp_struct-&amp;gt;* TO &amp;lt;header&amp;gt;.

* Create structure = structure of the 2nd internal table
  CREATE DATA lp_struct2 LIKE LINE OF &amp;lt;data&amp;gt;.
  ASSIGN lp_struct2-&amp;gt;* TO &amp;lt;header2&amp;gt;.

* Move data from 1st internal table --&amp;gt; 2nd internal table
  LOOP AT &amp;lt;lt_data&amp;gt; ASSIGNING &amp;lt;header&amp;gt;.

    DESCRIBE TABLE lt_lvc_cat.
    CLEAR &amp;lt;header2&amp;gt;.

*   Fill the internal to display &amp;lt;data&amp;gt;
    DO sy-tfill TIMES.
      READ TABLE lt_lvc_cat INTO ls_lvc_cat INDEX sy-index.
*     For each field of lt_lvc_cat.
      ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE &amp;lt;header&amp;gt;
                    TO &amp;lt;field&amp;gt;.
      IF sy-subrc NE 0. EXIT .ENDIF.
      ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE &amp;lt;header2&amp;gt;
                    TO &amp;lt;field2&amp;gt;.
      IF sy-subrc NE 0. EXIT .ENDIF.
      &amp;lt;field2&amp;gt; = &amp;lt;field&amp;gt;.
    ENDDO.

*   Modify color
    ASSIGN COMPONENT 'TABCOLOR' OF STRUCTURE &amp;lt;header2&amp;gt;
                  TO &amp;lt;field2&amp;gt;.
    IF sy-subrc EQ 0.
      PERFORM f_modify_color USING 'MAKTX' &amp;lt;field2&amp;gt;.
      PERFORM f_modify_color USING 'MATKL' &amp;lt;field2&amp;gt;.
    ENDIF.

    APPEND &amp;lt;header2&amp;gt; TO &amp;lt;data&amp;gt; .
  ENDLOOP.

ENDFORM.                    " f_read_data
*---------------------------------------------------------------------*
*      Form  F_DISPLAY_DATA
*---------------------------------------------------------------------*
FORM f_display_data.

* Macro definition
  DEFINE m_sort.
    add 1 to ls_sort-spos.
    ls_sort-fieldname = &amp;amp;1.
    ls_sort-down      = 'X'.
    append ls_sort to lt_sort.
  END-OF-DEFINITION.

  DATA:
    ls_layout   TYPE slis_layout_alv,
    lt_sort     TYPE slis_t_sortinfo_alv,
    ls_sort     TYPE slis_sortinfo_alv,
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv.  " Field catalog

* Build Fieldcatalog - First column
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MATNR'.
  ls_fieldcat-ref_tabname = 'MARA'.
  ls_fieldcat-key  = 'X'.
  APPEND ls_fieldcat TO lt_fieldcat.

* Build Fieldcatalog - 2nd column
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MAKTX'.
  ls_fieldcat-ref_tabname = 'MAKT'.
  APPEND ls_fieldcat TO lt_fieldcat.

* Build Fieldcatalog - 3rd column
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MATKL'.
  ls_fieldcat-ref_tabname = 'MARA'.
  APPEND ls_fieldcat TO lt_fieldcat.

* Layout
  ls_layout-zebra = 'X'.
  ls_layout-colwidth_optimize = 'X'.
  ls_layout-box_fieldname = 'CHECKBOX'.
  ls_layout-coltab_fieldname = 'TABCOLOR'.

  m_sort 'MATNR'.                      " Sort by creation date

* Display data
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            is_layout   = ls_layout
            it_fieldcat = lt_fieldcat
            it_sort     = lt_sort
       TABLES
            t_outtab    = &amp;lt;data&amp;gt;.

ENDFORM.                               " F_DISPLAY_DATA
*---------------------------------------------------------------------*
*      Form  F_modify_color
*---------------------------------------------------------------------*
FORM f_modify_color USING u_fieldname TYPE lvc_fname
                          ut_tabcolor TYPE table.

  DATA:
    l_rnd_value TYPE datatype-integer2,
    ls_tabcolor TYPE lvc_s_scol.

* Random value
  CALL FUNCTION 'RANDOM_I2'
       EXPORTING
            rnd_min   = 0
            rnd_max   = 3
       IMPORTING
            rnd_value = l_rnd_value.

  CLEAR ls_tabcolor.
  ls_tabcolor-fname = u_fieldname.

  CASE l_rnd_value.
    WHEN 0.
      ls_tabcolor-color-col = 1.       " Blue.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
    WHEN 1.
      ls_tabcolor-color-col = 3.       " Yellow.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
    WHEN 2.
      ls_tabcolor-color-col = 5.       " Green.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
    WHEN 3.
      ls_tabcolor-color-col = 6.       " Red.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
  ENDCASE.

  INSERT ls_tabcolor INTO TABLE ut_tabcolor.

ENDFORM.                               " F_MODIFY_COLOR&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>Thu, 01 Nov 2007 11:16:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-11-01T11:16:56Z</dc:date>
    <item>
      <title>alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975277#M702286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how can i color the perticular row in alv output?&lt;/P&gt;&lt;P&gt;plz reply...............&lt;/P&gt;&lt;P&gt;Thanks.......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 11:08:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975277#M702286</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-01T11:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975278#M702287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check this link for ALV row color example&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.geocities.com/mpioud/Z_ALV_LINE_COLOR.html" target="test_blank"&gt;http://www.geocities.com/mpioud/Z_ALV_LINE_COLOR.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.abap4.it/download/ALV.pdf" target="test_blank"&gt;http://www.abap4.it/download/ALV.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 11:09:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975278#M702287</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-01T11:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975279#M702288</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;Please check the link mentioned below for detailed info.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://saptechnical.com/Tutorials/ALV/ColorSALV/Demo.htm" target="test_blank"&gt;http://saptechnical.com/Tutorials/ALV/ColorSALV/Demo.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Harini.S&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 11:15:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975279#M702288</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-01T11:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975280#M702289</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 sample report to color an alv&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZALVCOLOR                                                   *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;                                                                     *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*

REPORT  ZALVCOLOR                               .

DATA : mara TYPE mara.                 " General Material Data

TYPE-POOLS: slis.                      " ALV Global types

FIELD-SYMBOLS :
  &amp;lt;data&amp;gt; TYPE table.                   " Data to display

SELECT-OPTIONS :
  s_matnr FOR mara-matnr.              " Material number

SELECTION-SCREEN :
  SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '50' OBLIGATORY.
SELECTION-SCREEN END OF LINE.

*---------------------------------------------------------------------*
INITIALIZATION.

  v_1 = 'Maximum of lines to display'.

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_data.

  PERFORM f_display_data.

*---------------------------------------------------------------------*
*      Form  f_read_data
*---------------------------------------------------------------------*
FORM f_read_data.

  FIELD-SYMBOLS :
    &amp;lt;field&amp;gt;    TYPE ANY,
    &amp;lt;field2&amp;gt;   TYPE ANY,
    &amp;lt;header&amp;gt;   TYPE ANY,
    &amp;lt;header2&amp;gt;  TYPE ANY,
    &amp;lt;lt_data&amp;gt;  TYPE table.             " Data read from DB

  DATA:
    lp_struct  TYPE REF TO data,
    lp_struct2 TYPE REF TO data,
    lp_table   TYPE REF TO data,       " Pointer to dynamic table
    lp_table2  TYPE REF TO data,       " Pointer to dynamic table
    ls_lvc_cat TYPE lvc_s_fcat,
    lt_lvc_cat TYPE lvc_t_fcat.        " Field catalog

* First column
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'MATNR'.
  ls_lvc_cat-ref_table = 'MARA'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* 2nd column
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'MAKTX'.
  ls_lvc_cat-ref_table = 'MAKT'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* 3rd column
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'MATKL'.
  ls_lvc_cat-ref_table = 'MARA'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* Create 1st internal table
  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
    EXPORTING it_fieldcatalog = lt_lvc_cat
    IMPORTING ep_table = lp_table.

  ASSIGN lp_table-&amp;gt;* TO &amp;lt;lt_data&amp;gt;.

* Read data into 1st internal table
  SELECT matnr maktx matkl
    INTO TABLE &amp;lt;lt_data&amp;gt;
    FROM v_matnr
      UP TO p_max ROWS
   WHERE matnr IN s_matnr.

* Create 2nd internal table
* Checkbox
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'CHECKBOX'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* Table color
  CLEAR ls_lvc_cat.
  ls_lvc_cat-fieldname = 'TABCOLOR'.
  ls_lvc_cat-ref_table = 'CALENDAR_TYPE'.
  ls_lvc_cat-ref_field = 'COLTAB'.
  APPEND ls_lvc_cat TO lt_lvc_cat.

* Create 2nd internal table
  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
    EXPORTING it_fieldcatalog = lt_lvc_cat
    IMPORTING ep_table = lp_table2.

  ASSIGN lp_table2-&amp;gt;* TO &amp;lt;data&amp;gt;.

* Create structure = structure of the 1st internal table
  CREATE DATA lp_struct LIKE LINE OF &amp;lt;lt_data&amp;gt;.
  ASSIGN lp_struct-&amp;gt;* TO &amp;lt;header&amp;gt;.

* Create structure = structure of the 2nd internal table
  CREATE DATA lp_struct2 LIKE LINE OF &amp;lt;data&amp;gt;.
  ASSIGN lp_struct2-&amp;gt;* TO &amp;lt;header2&amp;gt;.

* Move data from 1st internal table --&amp;gt; 2nd internal table
  LOOP AT &amp;lt;lt_data&amp;gt; ASSIGNING &amp;lt;header&amp;gt;.

    DESCRIBE TABLE lt_lvc_cat.
    CLEAR &amp;lt;header2&amp;gt;.

*   Fill the internal to display &amp;lt;data&amp;gt;
    DO sy-tfill TIMES.
      READ TABLE lt_lvc_cat INTO ls_lvc_cat INDEX sy-index.
*     For each field of lt_lvc_cat.
      ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE &amp;lt;header&amp;gt;
                    TO &amp;lt;field&amp;gt;.
      IF sy-subrc NE 0. EXIT .ENDIF.
      ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE &amp;lt;header2&amp;gt;
                    TO &amp;lt;field2&amp;gt;.
      IF sy-subrc NE 0. EXIT .ENDIF.
      &amp;lt;field2&amp;gt; = &amp;lt;field&amp;gt;.
    ENDDO.

*   Modify color
    ASSIGN COMPONENT 'TABCOLOR' OF STRUCTURE &amp;lt;header2&amp;gt;
                  TO &amp;lt;field2&amp;gt;.
    IF sy-subrc EQ 0.
      PERFORM f_modify_color USING 'MAKTX' &amp;lt;field2&amp;gt;.
      PERFORM f_modify_color USING 'MATKL' &amp;lt;field2&amp;gt;.
    ENDIF.

    APPEND &amp;lt;header2&amp;gt; TO &amp;lt;data&amp;gt; .
  ENDLOOP.

ENDFORM.                    " f_read_data
*---------------------------------------------------------------------*
*      Form  F_DISPLAY_DATA
*---------------------------------------------------------------------*
FORM f_display_data.

* Macro definition
  DEFINE m_sort.
    add 1 to ls_sort-spos.
    ls_sort-fieldname = &amp;amp;1.
    ls_sort-down      = 'X'.
    append ls_sort to lt_sort.
  END-OF-DEFINITION.

  DATA:
    ls_layout   TYPE slis_layout_alv,
    lt_sort     TYPE slis_t_sortinfo_alv,
    ls_sort     TYPE slis_sortinfo_alv,
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv.  " Field catalog

* Build Fieldcatalog - First column
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MATNR'.
  ls_fieldcat-ref_tabname = 'MARA'.
  ls_fieldcat-key  = 'X'.
  APPEND ls_fieldcat TO lt_fieldcat.

* Build Fieldcatalog - 2nd column
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MAKTX'.
  ls_fieldcat-ref_tabname = 'MAKT'.
  APPEND ls_fieldcat TO lt_fieldcat.

* Build Fieldcatalog - 3rd column
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname   = 'MATKL'.
  ls_fieldcat-ref_tabname = 'MARA'.
  APPEND ls_fieldcat TO lt_fieldcat.

* Layout
  ls_layout-zebra = 'X'.
  ls_layout-colwidth_optimize = 'X'.
  ls_layout-box_fieldname = 'CHECKBOX'.
  ls_layout-coltab_fieldname = 'TABCOLOR'.

  m_sort 'MATNR'.                      " Sort by creation date

* Display data
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            is_layout   = ls_layout
            it_fieldcat = lt_fieldcat
            it_sort     = lt_sort
       TABLES
            t_outtab    = &amp;lt;data&amp;gt;.

ENDFORM.                               " F_DISPLAY_DATA
*---------------------------------------------------------------------*
*      Form  F_modify_color
*---------------------------------------------------------------------*
FORM f_modify_color USING u_fieldname TYPE lvc_fname
                          ut_tabcolor TYPE table.

  DATA:
    l_rnd_value TYPE datatype-integer2,
    ls_tabcolor TYPE lvc_s_scol.

* Random value
  CALL FUNCTION 'RANDOM_I2'
       EXPORTING
            rnd_min   = 0
            rnd_max   = 3
       IMPORTING
            rnd_value = l_rnd_value.

  CLEAR ls_tabcolor.
  ls_tabcolor-fname = u_fieldname.

  CASE l_rnd_value.
    WHEN 0.
      ls_tabcolor-color-col = 1.       " Blue.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
    WHEN 1.
      ls_tabcolor-color-col = 3.       " Yellow.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
    WHEN 2.
      ls_tabcolor-color-col = 5.       " Green.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
    WHEN 3.
      ls_tabcolor-color-col = 6.       " Red.
      ls_tabcolor-color-int = 0.
      ls_tabcolor-color-inv = 0.
  ENDCASE.

  INSERT ls_tabcolor INTO TABLE ut_tabcolor.

ENDFORM.                               " F_MODIFY_COLOR&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>Thu, 01 Nov 2007 11:16:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975280#M702289</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-01T11:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975281#M702290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;ABAP List Viewer&lt;/P&gt;&lt;P&gt;Simple ALV report&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;/P&gt;&lt;P&gt;&lt;A href="http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox" target="test_blank"&gt;http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ALV&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Please give me general info on ALV.&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=58286" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=58286&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=76490" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=76490&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=20591" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=20591&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=66305" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=66305&lt;/A&gt; - this one discusses which way should you use - ABAP Objects calls or simple function modules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. How do I program double click in ALV?&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=11601" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=11601&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=23010" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=23010&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the program in the following link:&lt;/P&gt;&lt;P&gt;&lt;A href="http://sap-img.com/abap/display-secondary-list-using-alv-grid.htm" target="test_blank"&gt;http://sap-img.com/abap/display-secondary-list-using-alv-grid.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. How do I add subtotals (I have problem to add them)...&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=20386" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=20386&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=85191" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=85191&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=88401" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=88401&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=17335" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=17335&lt;/A&gt;&lt;/P&gt;&lt;P&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;&lt;/P&gt;&lt;P&gt;4. How to add list heading like top-of-page in ABAP lists?&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=58775" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=58775&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=60550" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=60550&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=16629" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=16629&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. How to print page number / total number of pages X/XX in ALV?&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=29597" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=29597&lt;/A&gt; (no direct solution)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=64320" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=64320&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=44477" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=44477&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7. How can I set the cell color in ALV?&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=52107" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=52107&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;8. How do I print a logo/graphics in ALV?&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=81149" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=81149&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=35498" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=35498&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=5013" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=5013&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;9. How do I create and use input-enabled fields in ALV?&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=84933" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=84933&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=69878" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=69878&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10. How can I use ALV for reports that are going to be run in background?&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=83243" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=83243&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=19224" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=19224&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;11. How can I display an icon in ALV? (Common requirement is traffic light icon).&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=79424" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=79424&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=24512" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=24512&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;12. How can I display a checkbox in ALV?&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=88376" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=88376&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=40968" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=40968&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=6919" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=6919&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;13. Top-of-page in ALV&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="147020"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;14. ALV Group Heading&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/fu037.htm" target="test_blank"&gt;http://www.sap-img.com/fu037.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;How to add list heading like top-of-page in ABAP lists?&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=58775" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=58775&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=60550" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=60550&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=16629" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=16629&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;15. ALV output to PDF conversion&lt;/P&gt;&lt;P&gt;It has an example code for PDF Conversion.&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.erpgenie.com/abap/code/abap51.htm" target="test_blank"&gt;http://www.erpgenie.com/abap/code/abap51.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="291161"&gt;&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Go thru these programs they may help u to try on some hands on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ALV Demo program&lt;/P&gt;&lt;P&gt;BCALV_DEMO_HTML&lt;/P&gt;&lt;P&gt;BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode&lt;/P&gt;&lt;P&gt;BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode&lt;/P&gt;&lt;P&gt;BCALV_GRID_DEMO Simple ALV Control Call Demo Program&lt;/P&gt;&lt;P&gt;BCALV_TREE_DEMO Demo for ALV tree control&lt;/P&gt;&lt;P&gt;BCALV_TREE_SIMPLE_DEMO&lt;/P&gt;&lt;P&gt;BC_ALV_DEMO_HTML_D0100&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV). &lt;/P&gt;&lt;P&gt;This helps us to implement all the features mentioned very effectively.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using ALV, We can have three types of reports:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Simple Report&lt;/P&gt;&lt;P&gt;2. Block Report&lt;/P&gt;&lt;P&gt;3. Hierarchical Sequential Report&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are some function modules which will enable to produce the above reports without much effort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. SIMPLE REPORT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The important function modules are &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a. Reuse_alv_list_display&lt;/P&gt;&lt;P&gt;b. Reuse_alv_fieldcatalog_merge&lt;/P&gt;&lt;P&gt;c. Reuse_alv_events_get&lt;/P&gt;&lt;P&gt;d. Reuse_alv_commentary_write&lt;/P&gt;&lt;P&gt;e. Reuse_alv_grid_display&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The important parameters are :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I. Export :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i. I_callback_program : report id&lt;/P&gt;&lt;P&gt;ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status&lt;/P&gt;&lt;P&gt;iii. I_callback_user_command : routine where the function codes are handled&lt;/P&gt;&lt;P&gt;iv. I_structure name : name of the dictionary table &lt;/P&gt;&lt;P&gt;v. Is_layout : structure to set the layout of the report&lt;/P&gt;&lt;P&gt;vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE&lt;/P&gt;&lt;P&gt;vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;II. Tables :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i. t_outtab : internal table with the data to be output&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Important Parameters are :&lt;/P&gt;&lt;P&gt;I. Export :&lt;/P&gt;&lt;P&gt;i. I_program_name : report id&lt;/P&gt;&lt;P&gt;ii. I_internal_tabname : the internal output table&lt;/P&gt;&lt;P&gt;iii. I_inclname : include or the report name where all the dynamic forms are handled.&lt;/P&gt;&lt;P&gt;II Changing&lt;/P&gt;&lt;P&gt;ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is &lt;/P&gt;&lt;P&gt;declared in the type pool SLIS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parameters : &lt;/P&gt;&lt;P&gt;I. Import :&lt;/P&gt;&lt;P&gt;Et_Events : The event table is returned with all possible CALLBACK events &lt;/P&gt;&lt;P&gt;for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV. &lt;/P&gt;&lt;P&gt;II. Export :&lt;/P&gt;&lt;P&gt;I_List_type : &lt;/P&gt;&lt;P&gt;0 = simple list REUSE_ALV_LIST_DISPLAY &lt;/P&gt;&lt;P&gt;1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY &lt;/P&gt;&lt;P&gt;2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND &lt;/P&gt;&lt;P&gt;3 = hierarchical-sequential block list &lt;/P&gt;&lt;P&gt;REUSE_ALV_BLOCK_LIST_HS_APPEND&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parameters : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I. it_list_commentary : internal table with the headings of the type slis_t_listheader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This internal table has three fields :&lt;/P&gt;&lt;P&gt;Typ : &amp;#145;H&amp;#146; &amp;#150; header, &amp;#145;S&amp;#146; &amp;#150; selection , &amp;#145;A&amp;#146; - action&lt;/P&gt;&lt;P&gt;Key : only when typ is &amp;#145;S&amp;#146;.&lt;/P&gt;&lt;P&gt;Info : the text to be printed&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parameters : same as reuse_alv_list_display&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is an example for simple list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. BLOCK REPORT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is used to have multiple lists continuously.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The important functions used in this report are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A. REUSE_ALV_BLOCK_LIST_INIT&lt;/P&gt;&lt;P&gt;B. REUSE_ALV_BLOCK_LIST_APPEND&lt;/P&gt;&lt;P&gt;C. REUSE_ALV_BLOCK_LIST_HS_APPEND&lt;/P&gt;&lt;P&gt;D. REUSE_ALV_BLOCK_LIST_DISPLAY&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;A. REUSE_ALV_BLOCK_LIST_INIT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parameters: &lt;/P&gt;&lt;P&gt;I. I_CALLBACK_PROGRAM &lt;/P&gt;&lt;P&gt;II. I_CALLBACK_PF_STATUS_SET &lt;/P&gt;&lt;P&gt;III. I_CALLBACK_USER_COMMAND &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This function module is used to set the default gui status etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B. REUSE_ALV_BLOCK_LIST_APPEND&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parameters : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Export : &lt;/P&gt;&lt;P&gt;I. is_layout : layout settings for block &lt;/P&gt;&lt;P&gt;II. it_fieldcat : field catalog &lt;/P&gt;&lt;P&gt;III. i_tabname : internal table name with output data &lt;/P&gt;&lt;P&gt;IV. it_events : internal table with all possible events&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tables :&lt;/P&gt;&lt;P&gt;i. t_outtab : internal table with output data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This function module adds the data to the block. &lt;/P&gt;&lt;P&gt;Repeat this function for all the different blocks to be displayed one after the other.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C. REUSE_ALV_BLOCK_LIST_HS_APPEND&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This function module is used for hierarchical sequential blocks. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;D. REUSE_ALV_BLOCK_LIST_DISPLAY &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parameters : All the parameters are optional. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This function module display the list with data appended by the above function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Hierarchical reports : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hierarchical sequential list output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function module is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A. REUSE_ALV_HIERSEQ_LIST_DISPLAY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parameters: &lt;/P&gt;&lt;P&gt;I. Export: &lt;/P&gt;&lt;P&gt;i. I_CALLBACK_PROGRAM &lt;/P&gt;&lt;P&gt;ii. I_CALLBACK_PF_STATUS_SET &lt;/P&gt;&lt;P&gt;iii. I_CALLBACK_USER_COMMAND &lt;/P&gt;&lt;P&gt;iv. IS_LAYOUT &lt;/P&gt;&lt;P&gt;v. IT_FIELDCAT &lt;/P&gt;&lt;P&gt;vi. IT_EVENTS &lt;/P&gt;&lt;P&gt;vii. i_tabname_header : Name of the internal table in the program containing the &lt;/P&gt;&lt;P&gt;output data of the highest hierarchy level.&lt;/P&gt;&lt;P&gt;viii. i_tabname_item : Name of the internal table in the program containing the &lt;/P&gt;&lt;P&gt;output data of the lowest hierarchy level.&lt;/P&gt;&lt;P&gt;ix. is_keyinfo : This structure contains the header and item table field &lt;/P&gt;&lt;P&gt;names which link the two tables (shared key). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;II. Tables&lt;/P&gt;&lt;P&gt;i. t_outtab_header : Header table with data to be output&lt;/P&gt;&lt;P&gt;ii. t_outtab_item : Name of the internal table in the program containing the &lt;/P&gt;&lt;P&gt;output data of the lowest hierarchy level. &lt;/P&gt;&lt;P&gt;slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using &amp;#145;REUSE_ALV_FIELDCATALOG_MERGE&amp;#146;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Important Attributes :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A. col_pos : position of the column&lt;/P&gt;&lt;P&gt;B. fieldname : internal fieldname&lt;/P&gt;&lt;P&gt;C. tabname : internal table name&lt;/P&gt;&lt;P&gt;D. ref_fieldname : fieldname (dictionary)&lt;/P&gt;&lt;P&gt;E. ref_tabname : table (dictionary)&lt;/P&gt;&lt;P&gt;F. key(1) : column with key-color&lt;/P&gt;&lt;P&gt;G. icon(1) : icon&lt;/P&gt;&lt;P&gt;H. symbol(1) : symbol&lt;/P&gt;&lt;P&gt;I. checkbox(1) : checkbox&lt;/P&gt;&lt;P&gt;J. just(1) : (R)ight (L)eft (C)ent.&lt;/P&gt;&lt;P&gt;K. do_sum(1) : sum up&lt;/P&gt;&lt;P&gt;L. no_out(1) : (O)blig.(X)no out&lt;/P&gt;&lt;P&gt;M. outputlen : output length&lt;/P&gt;&lt;P&gt;N. seltext_l : long key word&lt;/P&gt;&lt;P&gt;O. seltext_m : middle key word&lt;/P&gt;&lt;P&gt;P. seltext_s : short key word&lt;/P&gt;&lt;P&gt;Q. reptext_ddic : heading (ddic)&lt;/P&gt;&lt;P&gt;R. ddictxt(1) : (S)hort (M)iddle (L)ong&lt;/P&gt;&lt;P&gt;S. datatype : datatype&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 11:17:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975281#M702290</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-01T11:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975282#M702291</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;&lt;/P&gt;&lt;P&gt;check this report&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;report zuseofhashedtables.&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Program: ZUseOfHashedTables                                        **&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Author: Horacio Zapettini                                          **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;                                                                   **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Versions: 4.6b - 4.6c                                              **&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Notes:                                                             **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;    this program shows how we can use hashed tables to improve     **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;    the responce time.                                             **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;    It shows,                                                      **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;       1. how to declare hashed tables                             **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;       2. a cache-like technique to improve access to master data  **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;       3. how to collect data using hashed tables                  **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;       4. how to avoid deletions of unwanted data                  **&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Results: the test we run read about 31000 rows from mkpf, 150000   **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         rows from mseg, 500 rows from makt and 400 from lfa1.     **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         it filled ht_lst with 24500 rows and displayed them in    **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         alv grid format.                                          **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;                                                                   **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         It took about 65 secodns to perform this task (first time **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         we run it when all the db buffers are empty.              **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;                                                                   **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         The same program with standard tables needed 140 seconds  **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         to run with the same recordset and with buffers filled in **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;                                                                   **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         A simmilar test over more than a million rows&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Objetive: show a list that consists of  all the material movements **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         '101' - '901' for a certain range of dates in mkpf-budat. **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;the columns to be displayed are:                                   **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         mkpf-budat,                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         mkpf-mblnr,                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         mseg-lifnr,                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         lfa1-name1,                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         mkpf-xblnr,                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         mseg-zeile                                                **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         mseg-charg,                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         mseg-matnr,                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         makt-maktx,                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         mseg-erfmg,                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         mseg-erfme.                                               **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;or show a sumary list by matnr - menge                             **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;                                                                   **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;You'll have to create a pf-status called vista -                   **&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;See form set_pf_status for details                                 **&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;tables used -&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;tables: mkpf,&lt;/P&gt;&lt;P&gt;        mseg,&lt;/P&gt;&lt;P&gt;        lfa1,&lt;/P&gt;&lt;P&gt;        makt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;global hashed tables used&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;data: begin of wa_mkpf, "header&lt;/P&gt;&lt;P&gt;      mblnr like mkpf-mblnr,&lt;/P&gt;&lt;P&gt;      mjahr like mkpf-mjahr,&lt;/P&gt;&lt;P&gt;      budat like mkpf-budat,&lt;/P&gt;&lt;P&gt;      xblnr like mkpf-xblnr,&lt;/P&gt;&lt;P&gt;      end of wa_mkpf.&lt;/P&gt;&lt;P&gt;data: ht_mkpf like hashed table of wa_mkpf&lt;/P&gt;&lt;P&gt;      with unique key mblnr mjahr&lt;/P&gt;&lt;P&gt;      with header line.&lt;/P&gt;&lt;P&gt;data: st_mkpf like standard table of wa_mkpf&lt;/P&gt;&lt;P&gt;      with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;data: begin of wa_mseg, " line items&lt;/P&gt;&lt;P&gt;      mblnr like mseg-mblnr,&lt;/P&gt;&lt;P&gt;      mjahr like mseg-mjahr,&lt;/P&gt;&lt;P&gt;      zeile like mseg-zeile,&lt;/P&gt;&lt;P&gt;      bwart like mseg-bwart,&lt;/P&gt;&lt;P&gt;      charg like mseg-charg,&lt;/P&gt;&lt;P&gt;      matnr like mseg-matnr,&lt;/P&gt;&lt;P&gt;      lifnr like mseg-lifnr,&lt;/P&gt;&lt;P&gt;      erfmg like mseg-erfmg,&lt;/P&gt;&lt;P&gt;      erfme like mseg-erfme,&lt;/P&gt;&lt;P&gt;      end of wa_mseg.&lt;/P&gt;&lt;P&gt;data ht_mseg like hashed table of wa_mseg&lt;/P&gt;&lt;P&gt;      with unique key mblnr mjahr zeile&lt;/P&gt;&lt;P&gt;      with header line.&lt;/P&gt;&lt;P&gt;data st_mseg like standard table of wa_mseg&lt;/P&gt;&lt;P&gt;      with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;cache structure for lfa1 records&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;data: begin of wa_lfa1,&lt;/P&gt;&lt;P&gt;      lifnr like lfa1-lifnr,&lt;/P&gt;&lt;P&gt;      name1 like lfa1-name1,&lt;/P&gt;&lt;P&gt;      end of wa_lfa1.&lt;/P&gt;&lt;P&gt;data ht_lfa1 like hashed table of wa_lfa1&lt;/P&gt;&lt;P&gt;      with unique key lifnr&lt;/P&gt;&lt;P&gt;      with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;cache structure for material related data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;data: begin of wa_material,&lt;/P&gt;&lt;P&gt;      matnr like makt-matnr,&lt;/P&gt;&lt;P&gt;      maktx like makt-maktx,&lt;/P&gt;&lt;P&gt;      end of wa_material.&lt;/P&gt;&lt;P&gt;data: ht_material like hashed table of wa_material&lt;/P&gt;&lt;P&gt;        with unique key matnr&lt;/P&gt;&lt;P&gt;        with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;result table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;data: begin of wa_lst, "&lt;/P&gt;&lt;P&gt;      budat like mkpf-budat,&lt;/P&gt;&lt;P&gt;      mblnr like mseg-mblnr,&lt;/P&gt;&lt;P&gt;      lifnr like mseg-lifnr,&lt;/P&gt;&lt;P&gt;      name1 like lfa1-name1,    &lt;/P&gt;&lt;P&gt;      xblnr like mkpf-xblnr,&lt;/P&gt;&lt;P&gt;      zeile like mseg-zeile,&lt;/P&gt;&lt;P&gt;      charg like mseg-charg,&lt;/P&gt;&lt;P&gt;      matnr like mseg-matnr,&lt;/P&gt;&lt;P&gt;      maktx like makt-maktx,&lt;/P&gt;&lt;P&gt;      erfmg like mseg-erfmg,&lt;/P&gt;&lt;P&gt;      erfme like mseg-erfme,&lt;/P&gt;&lt;P&gt;      mjahr like mseg-mjahr,&lt;/P&gt;&lt;P&gt;      end of wa_lst.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: ht_lst like hashed table of wa_lst&lt;/P&gt;&lt;P&gt;        with unique key mblnr mjahr zeile&lt;/P&gt;&lt;P&gt;        with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of wa_lst1, " sumary by material&lt;/P&gt;&lt;P&gt;      matnr like mseg-matnr,&lt;/P&gt;&lt;P&gt;      maktx like makt-maktx,&lt;/P&gt;&lt;P&gt;      erfmg like mseg-erfmg,&lt;/P&gt;&lt;P&gt;      erfme like mseg-erfme,&lt;/P&gt;&lt;P&gt;      color_line(4) TYPE c,           " Line color&lt;/P&gt;&lt;P&gt;      color_cell    TYPE lvc_t_scol,  " Cell color&lt;/P&gt;&lt;P&gt;      celltab type LVC_T_STYL,&lt;/P&gt;&lt;P&gt;      end of wa_lst1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: ht_lst1 like hashed table of wa_lst1&lt;/P&gt;&lt;P&gt;        with unique key matnr&lt;/P&gt;&lt;P&gt;        with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;structures for alv grid display.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;itabs&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;type-pools: slis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: it_lst            like standard table of wa_lst with header line,&lt;/P&gt;&lt;P&gt;      it_fieldcat_lst   type slis_t_fieldcat_alv with header line,&lt;/P&gt;&lt;P&gt;      it_sort_lst       type slis_t_sortinfo_alv,&lt;/P&gt;&lt;P&gt;      it_lst1           like standard table of wa_lst1 with header line,&lt;/P&gt;&lt;P&gt;      it_fieldcat_lst1  type slis_t_fieldcat_alv with header line,&lt;/P&gt;&lt;P&gt;      it_sort_lst1      type slis_t_sortinfo_alv.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;structures&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;data: wa_sort         type slis_sortinfo_alv,&lt;/P&gt;&lt;P&gt;      ls_layout       type slis_layout_alv.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;color management.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;DATA  : wa_color    TYPE lvc_s_scol.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Internal table for color management.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA : it_color    TYPE TABLE          OF lvc_s_scol.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;itab for input enabling.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: lt_celltab TYPE lvc_t_styl. "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;global varialbes&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: g_lines type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: g_repid like sy-repid,&lt;/P&gt;&lt;P&gt;      ok_code       like sy-ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;selection-screen&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"text: Dates:&lt;/P&gt;&lt;P&gt;select-options: so_budat for mkpf-budat default sy-datum.&lt;/P&gt;&lt;P&gt;"text: Material numbers.&lt;/P&gt;&lt;P&gt;select-options: so_matnr for mseg-matnr.&lt;/P&gt;&lt;P&gt;selection-screen uline.&lt;/P&gt;&lt;P&gt;selection-screen skip 1.&lt;/P&gt;&lt;P&gt;"Text: show summary by material.&lt;/P&gt;&lt;P&gt;parameters: gp_bymat as checkbox default ''.&lt;/P&gt;&lt;P&gt;parameters: gp_hier  as checkbox default 'X'.&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;  perform get_data.&lt;/P&gt;&lt;P&gt;  perform show_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end-of-selection.&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;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      FORM get_data                                                 *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&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;      ........                                                      *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="---------------------------------------------------------------" /&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;form get_data.&lt;/P&gt;&lt;P&gt;        select mblnr mjahr budat xblnr&lt;/P&gt;&lt;P&gt;            into table ht_mkpf&lt;/P&gt;&lt;P&gt;           from mkpf&lt;/P&gt;&lt;P&gt;          where budat in so_budat. " make use of std index.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;have we retrieved data from mkpf?&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;  describe table ht_mkpf lines g_lines.&lt;/P&gt;&lt;P&gt;  if g_lines &amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;if true then retrieve all related records from mseg.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Doing this way we make sure that the access is by primary key&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;of mseg.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;The reason is that is faster to filter them in memory&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;than to allow the db server to do it.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;    select mblnr mjahr zeile bwart charg&lt;/P&gt;&lt;P&gt;             matnr lifnr erfmg erfme&lt;/P&gt;&lt;P&gt;      into table ht_mseg&lt;/P&gt;&lt;P&gt;      from mseg&lt;/P&gt;&lt;P&gt;        for all entries in ht_mkpf&lt;/P&gt;&lt;P&gt;     where mblnr = ht_mkpf-mblnr&lt;/P&gt;&lt;P&gt;       and mjahr = ht_mkpf-mjahr.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;fill t_lst or t_lst1 according to user's choice.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;  if gp_bymat = ' '.&lt;/P&gt;&lt;P&gt;    perform fill_ht_lst.&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;    perform fill_ht_lst1.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form fill_ht_lst.&lt;/P&gt;&lt;P&gt;  refresh ht_lst.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Example: how to discard unwanted data in an efficient way.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;  loop at ht_mseg.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  filter unwanted data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.&lt;/P&gt;&lt;P&gt;    check ht_mseg-matnr in so_matnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  read header line.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    read table ht_mkpf with table key mblnr = ht_mseg-mblnr&lt;/P&gt;&lt;P&gt;    mjahr = ht_mseg-mjahr.&lt;/P&gt;&lt;P&gt;    clear ht_lst.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; * note : this may be faster if you specify field by field.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    move-corresponding ht_mkpf to ht_lst.&lt;/P&gt;&lt;P&gt;    move-corresponding ht_mseg to ht_lst.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1.&lt;/P&gt;&lt;P&gt;    perform read_material using ht_mseg-matnr changing ht_lst-maktx.&lt;/P&gt;&lt;P&gt;    insert table ht_lst.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form fill_ht_lst1.&lt;/P&gt;&lt;P&gt;data: colorear.&lt;/P&gt;&lt;P&gt;  refresh ht_lst1.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Example: how to discard unwanted data in an efficient way.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;         hot to simulate a collect in a faster way&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;  loop at ht_mseg.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  filter unwanted data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.&lt;/P&gt;&lt;P&gt;    check ht_mseg-matnr in so_matnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; * note : this may be faster if you specify field by field.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    read table ht_lst1 with table key matnr = ht_mseg-matnr&lt;/P&gt;&lt;P&gt;    transporting erfmg.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0. " if matnr doesn't exist in sumary table&lt;/P&gt;&lt;P&gt;    " insert a new record&lt;/P&gt;&lt;P&gt;      clear ht_lst1.&lt;/P&gt;&lt;P&gt;      ht_lst1-matnr = ht_mseg-matnr.&lt;/P&gt;&lt;P&gt;      perform read_material using ht_mseg-matnr changing ht_lst1-maktx.&lt;/P&gt;&lt;P&gt;      ht_lst1-erfmg = ht_mseg-erfmg.&lt;/P&gt;&lt;P&gt;      ht_lst1-erfme = ht_mseg-erfme.&lt;/P&gt;&lt;P&gt;      if colorear = ''.&lt;/P&gt;&lt;P&gt;        colorear = 'X'.&lt;/P&gt;&lt;P&gt;        refresh it_color.&lt;/P&gt;&lt;P&gt;        ht_lst1-color_cell[] = it_color[].&lt;/P&gt;&lt;P&gt;        MOVE 'C410' TO ht_lst1-color_line.&lt;/P&gt;&lt;P&gt;      else.&lt;/P&gt;&lt;P&gt;        colorear = ' '.&lt;/P&gt;&lt;P&gt;        refresh it_color. clear it_color.&lt;/P&gt;&lt;P&gt;        MOVE 'MATNR' TO wa_color-fname.&lt;/P&gt;&lt;P&gt;        MOVE '6'         TO wa_color-color-col.&lt;/P&gt;&lt;P&gt;        MOVE '1'         TO wa_color-color-int.&lt;/P&gt;&lt;P&gt;        MOVE '1'         TO wa_color-color-inv.&lt;/P&gt;&lt;P&gt;        APPEND wa_color TO it_color.&lt;/P&gt;&lt;P&gt;        MOVE 'MAKTX' TO wa_color-fname.&lt;/P&gt;&lt;P&gt;        MOVE '3'         TO wa_color-color-col.&lt;/P&gt;&lt;P&gt;        MOVE '1'         TO wa_color-color-int.&lt;/P&gt;&lt;P&gt;        MOVE '1'         TO wa_color-color-inv.&lt;/P&gt;&lt;P&gt;        APPEND wa_color TO it_color.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        MOVE 'ERFMG' TO wa_color-fname.&lt;/P&gt;&lt;P&gt;        MOVE '5'         TO wa_color-color-col.&lt;/P&gt;&lt;P&gt;        MOVE '1'         TO wa_color-color-int.&lt;/P&gt;&lt;P&gt;        MOVE '1'         TO wa_color-color-inv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        APPEND wa_color TO it_color.&lt;/P&gt;&lt;P&gt;        ht_lst1-color_cell[] = it_color[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        clear ht_lst1-color_line.&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;      insert table ht_lst1.&lt;/P&gt;&lt;P&gt;    else." a record was found.&lt;/P&gt;&lt;P&gt;    " collect erfmg.  To do so, fill in the unique key and add&lt;/P&gt;&lt;P&gt;    " the numeric fields.&lt;/P&gt;&lt;P&gt;      ht_lst1-matnr = ht_mseg-matnr.&lt;/P&gt;&lt;P&gt;      add ht_mseg-erfmg to ht_lst1-erfmg.&lt;/P&gt;&lt;P&gt;      modify table ht_lst1 transporting erfmg.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;implementation of cache for lfa1.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;form read_lfa1 using p_lifnr changing p_name1.&lt;/P&gt;&lt;P&gt;        read table ht_lfa1 with table key lifnr = p_lifnr&lt;/P&gt;&lt;P&gt;        transporting name1.&lt;/P&gt;&lt;P&gt;  if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    clear ht_lfa1.&lt;/P&gt;&lt;P&gt;    ht_lfa1-lifnr = p_lifnr.&lt;/P&gt;&lt;P&gt;    select single name1&lt;/P&gt;&lt;P&gt;       into ht_lfa1-name1&lt;/P&gt;&lt;P&gt;      from lfa1&lt;/P&gt;&lt;P&gt;    where lifnr = p_lifnr.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0. ht_lfa1-name1 = 'n/a in lfa1'. endif.&lt;/P&gt;&lt;P&gt;    insert table ht_lfa1.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  p_name1 = ht_lfa1-name1.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;implementation of cache for material data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;form read_material using p_matnr changing p_maktx.&lt;/P&gt;&lt;P&gt;  read table ht_material with table key matnr = p_matnr&lt;/P&gt;&lt;P&gt;  transporting maktx.&lt;/P&gt;&lt;P&gt;  if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    ht_material-matnr = p_matnr.&lt;/P&gt;&lt;P&gt;    select single maktx into  ht_material-maktx&lt;/P&gt;&lt;P&gt;      from makt&lt;/P&gt;&lt;P&gt;     where spras = sy-langu&lt;/P&gt;&lt;P&gt;       and matnr = p_matnr.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0. ht_material-maktx = 'n/a in makt'. endif.&lt;/P&gt;&lt;P&gt;    insert table ht_material.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  p_maktx = ht_material-maktx.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;form show_data.&lt;/P&gt;&lt;P&gt;  if gp_hier = 'X'. "no anda.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   perform show_hierarchicalALV.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;    if gp_bymat = ' '.&lt;/P&gt;&lt;P&gt;      perform show_ht_lst.&lt;/P&gt;&lt;P&gt;    else.&lt;/P&gt;&lt;P&gt;      perform show_ht_lst1.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;form show_hierarchicalALV.&lt;/P&gt;&lt;P&gt;st_mkpf[] = ht_mkpf[].&lt;/P&gt;&lt;P&gt;st_mseg[] = ht_mseg[].&lt;/P&gt;&lt;P&gt;call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; exporting&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_INTERFACE_CHECK              = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_CALLBACK_PROGRAM             =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_CALLBACK_PF_STATUS_SET       = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_CALLBACK_USER_COMMAND        = ' '&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;  IT_FIELDCAT                    =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  IT_EXCLUDING                   =&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_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;LI level="1" type="ul"&gt;&lt;P&gt;  IS_SEL_HIDE                    =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_SCREEN_START_COLUMN          = 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_SCREEN_START_LINE            = 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_SCREEN_END_COLUMN            = 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_SCREEN_END_LINE              = 0&lt;/P&gt;&lt;/LI&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;  I_SAVE                         = ' '&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;LI level="1" type="ul"&gt;&lt;P&gt;  IT_EVENTS                      =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  IT_EVENT_EXIT                  =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   i_tabname_header               =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   i_tabname_item                 =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_STRUCTURE_NAME_HEADER        =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  I_STRUCTURE_NAME_ITEM          =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   is_keyinfo                     =&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;  IS_REPREP_ID                   =&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_BYPASSING_BUFFER             =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  E_EXIT_CAUSED_BY_CALLER        =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  ES_EXIT_CAUSED_BY_USER         =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  tables&lt;/P&gt;&lt;P&gt;    t_outtab_header                = st_mkpf&lt;/P&gt;&lt;P&gt;    t_outtab_item                  = st_mseg&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  PROGRAM_ERROR                  = 1&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  OTHERS                         = 2&lt;/P&gt;&lt;/LI&gt;&lt;/UL&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;endform.&lt;/P&gt;&lt;P&gt;form show_ht_lst.&lt;/P&gt;&lt;P&gt;  "needed because the FM can't use a hashed table.&lt;/P&gt;&lt;P&gt;  it_lst[] = ht_lst[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  perform fill_layout using 'full display'&lt;/P&gt;&lt;P&gt;                       changing ls_layout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  perform fill_columns_lst.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; perform sort_lst.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  g_repid = sy-repid.&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       = g_repid&lt;/P&gt;&lt;P&gt;            i_callback_pf_status_set = 'SET_PF_STATUS'&lt;/P&gt;&lt;P&gt;            is_layout                = ls_layout&lt;/P&gt;&lt;P&gt;            it_fieldcat              = it_fieldcat_lst[]&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           it_sort                  = it_sort_lst&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       tables&lt;/P&gt;&lt;P&gt;            t_outtab                 = it_lst&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;endform.&lt;/P&gt;&lt;P&gt;form show_ht_lst1.&lt;/P&gt;&lt;P&gt;  "needed because the FM can't use a hashed table.&lt;/P&gt;&lt;P&gt;  it_lst1[] = ht_lst1[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  perform fill_layout using 'Sumary by matnr'&lt;/P&gt;&lt;P&gt;                       changing ls_layout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  perform fill_columns_lst1.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; perform sort_lst.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  g_repid = sy-repid.&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       = g_repid&lt;/P&gt;&lt;P&gt;            i_callback_pf_status_set = 'SET_PF_STATUS'&lt;/P&gt;&lt;P&gt;            is_layout                = ls_layout&lt;/P&gt;&lt;P&gt;            it_fieldcat              = it_fieldcat_lst1[]&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           it_sort                  = it_sort_lst&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       tables&lt;/P&gt;&lt;P&gt;            t_outtab                 = it_lst1&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;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form fill_layout using p_window_titlebar&lt;/P&gt;&lt;P&gt;               changing cs_layo type slis_layout_alv.&lt;/P&gt;&lt;P&gt;  clear cs_layo.&lt;/P&gt;&lt;P&gt;  cs_layo-window_titlebar        = p_window_titlebar.&lt;/P&gt;&lt;P&gt;  cs_layo-edit                   = 'X'.&lt;/P&gt;&lt;P&gt;  cs_layo-edit_mode              = space.&lt;/P&gt;&lt;P&gt;  MOVE 'COLOR_LINE' TO cs_layo-info_fieldname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Field that identify cell color in inetrnal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  MOVE 'COLOR_CELL' TO cs_layo-coltab_fieldname.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; move 'CELLTAB' TO cs_layo-stylefname.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " armar_layout_stock&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form set_pf_status using rt_extab type slis_t_extab.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;create a new status&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;and then select extras -&amp;gt; adjust template -&amp;gt; listviewer&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;  set pf-status 'VISTA'.&lt;/P&gt;&lt;P&gt;endform.        "set_pf_status&lt;/P&gt;&lt;P&gt;define add_lst.&lt;/P&gt;&lt;P&gt;  clear it_fieldcat_lst.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst-fieldname     = &amp;amp;1.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst-outputlen     = &amp;amp;2.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst-ddictxt       = 'L'.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst-seltext_l       = &amp;amp;1.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst-seltext_m       = &amp;amp;1.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst-seltext_m       = &amp;amp;1.&lt;/P&gt;&lt;P&gt;  if &amp;amp;1 = 'MATNR'.&lt;/P&gt;&lt;P&gt;    it_fieldcat_lst-emphasize = 'C111'.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  append it_fieldcat_lst.&lt;/P&gt;&lt;P&gt;end-of-definition.&lt;/P&gt;&lt;P&gt;define add_lst1.&lt;/P&gt;&lt;P&gt;  clear it_fieldcat_lst.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst1-fieldname     = &amp;amp;1.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst1-outputlen     = &amp;amp;2.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst1-ddictxt       = 'L'.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst1-seltext_l       = &amp;amp;1.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst1-seltext_m       = &amp;amp;1.&lt;/P&gt;&lt;P&gt;  it_fieldcat_lst1-seltext_m       = &amp;amp;1.&lt;/P&gt;&lt;P&gt;  append it_fieldcat_lst1.&lt;/P&gt;&lt;P&gt;end-of-definition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form fill_columns_lst.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set columns for output.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  refresh it_fieldcat_lst.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;  add_lst 'BUDAT' 10.&lt;/P&gt;&lt;P&gt;  add_lst   'MBLNR' 10.&lt;/P&gt;&lt;P&gt;  add_lst  'LIFNR' 10.&lt;/P&gt;&lt;P&gt;  add_lst  'NAME1' 35.&lt;/P&gt;&lt;P&gt;  add_lst  'XBLNR' 15.&lt;/P&gt;&lt;P&gt;  add_lst    'ZEILE' 5.&lt;/P&gt;&lt;P&gt;  add_lst    'CHARG' 10.&lt;/P&gt;&lt;P&gt;  add_lst   'MATNR' 18.&lt;/P&gt;&lt;P&gt;  add_lst   'MAKTX' 30.&lt;/P&gt;&lt;P&gt;  add_lst   'ERFMG' 17.&lt;/P&gt;&lt;P&gt;  add_lst   'ERFME' 5.&lt;/P&gt;&lt;P&gt;  add_lst   'MJAHR' 4.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;form fill_columns_lst1.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set columns for output.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  refresh it_fieldcat_lst1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  add_lst1 'MATNR' 18.&lt;/P&gt;&lt;P&gt;  add_lst1 'MAKTX' 30.&lt;/P&gt;&lt;P&gt;  add_lst1 'ERFMG' 17.&lt;/P&gt;&lt;P&gt;  add_lst1 'ERFME' 5..&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Horacio Zapettini&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;Program to Calculate FI Opening Balance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to find the Opening balance for a given period in FI Module for a Particular GL A/c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was calculated opening balance, code is below maybe it will be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*find period.&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      i_date         = s_budat-low&lt;/P&gt;&lt;P&gt;      i_periv        = i_tab-periv                          "'K4'&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      e_buper        = v_donem&lt;/P&gt;&lt;P&gt;      e_gjahr        = v_gjahr&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      input_false    = 1&lt;/P&gt;&lt;P&gt;      t009_notfound  = 2&lt;/P&gt;&lt;P&gt;      t009b_notfound = 3&lt;/P&gt;&lt;P&gt;      OTHERS         = 4.&lt;/P&gt;&lt;P&gt;*calc opening balance hesabý&lt;/P&gt;&lt;P&gt;  SELECT * FROM knc1 WHERE kunnr = i_tab-kunnr&lt;/P&gt;&lt;P&gt;                     AND bukrs = i_tab-bukrs " s_bukrs&lt;/P&gt;&lt;P&gt;                     AND gjahr EQ v_gjahr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    v_dnm = v_donem.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;opening balance first calc &amp;gt; old year ,&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    WHILE v_dnm &amp;gt; 1.&lt;/P&gt;&lt;P&gt;      v_dnm = v_dnm - 1.&lt;/P&gt;&lt;P&gt;      CONCATENATE 'knc1-um' v_dnm 's' INTO v_field_name_borc.&lt;/P&gt;&lt;P&gt;      CONCATENATE 'knc1-um' v_dnm 'h' INTO v_field_name_alacak.&lt;/P&gt;&lt;P&gt;      ASSIGN (v_field_name_borc) TO  old&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;add days which is from selected date-low month&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    IF v_donem &amp;gt; 1.&lt;/P&gt;&lt;P&gt;      v_dnm = v_donem - 1.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      v_dnm = v_donem.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT SINGLE * FROM t009b WHERE periv = i_tab-periv    "'K4'&lt;/P&gt;&lt;P&gt;                                 AND bdatj = s_budat-low+0(4)&lt;/P&gt;&lt;P&gt;                                 AND poper = v_dnm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    t009b-butag = t009b-butag + 1.&lt;/P&gt;&lt;P&gt;    IF s_budat-low+6(2) NE t009b-butag.&lt;/P&gt;&lt;P&gt;      v_date_high = s_budat-low - 1.&lt;/P&gt;&lt;P&gt;      IF v_donem = 1.&lt;/P&gt;&lt;P&gt;        v_date_low = s_budat-low.&lt;/P&gt;&lt;P&gt;        v_date_low+4(4)  = '0101'.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        CONCATENATE t009b-bdatj t009b-bumon t009b-butag INTO&lt;/P&gt;&lt;P&gt;        v_date_low.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;      SELECT *  FROM bsad WHERE bukrs EQ i_tab-bukrs "IN s_bukrs&lt;/P&gt;&lt;P&gt;                            AND kunnr = i_tab-kunnr&lt;/P&gt;&lt;P&gt;                            AND budat BETWEEN v_date_low AND&lt;/P&gt;&lt;P&gt;                            v_date_high&lt;/P&gt;&lt;P&gt;                            AND umskz = space&lt;/P&gt;&lt;P&gt;                            AND blart IN s_blart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        IF bsad-shkzg = 'S'.&lt;/P&gt;&lt;P&gt;          i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsad-dmbtr ).&lt;/P&gt;&lt;P&gt;        ELSEIF bsad-shkzg = 'H'.&lt;/P&gt;&lt;P&gt;          i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsad-dmbtr   ).&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;      ENDSELECT.&lt;/P&gt;&lt;P&gt;      SELECT *  FROM bsid WHERE bukrs EQ i_tab-bukrs "IN s_bukrs&lt;/P&gt;&lt;P&gt;                           AND kunnr = i_tab-kunnr&lt;/P&gt;&lt;P&gt;                           AND budat BETWEEN v_date_low AND&lt;/P&gt;&lt;P&gt;                           v_date_high&lt;/P&gt;&lt;P&gt;                           AND umskz = space&lt;/P&gt;&lt;P&gt;                           AND blart IN s_blart.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                             AND gsber IN gsber.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        IF bsid-shkzg = 'S'.&lt;/P&gt;&lt;P&gt;          i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsid-dmbtr   ).&lt;/P&gt;&lt;P&gt;        ELSEIF bsid-shkzg = 'H'.&lt;/P&gt;&lt;P&gt;          i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsid-dmbtr   ).&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;      ENDSELECT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    "opening balance ( þirket bazlý )z1 degeri&lt;/P&gt;&lt;P&gt;   i_tab-z1 = i_tab-z1 + ( knc1-umsav + i_tab-dmbtr_s - i_tab-dmbtr_h ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;for israel&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    i_tab-dmbtril_s = i_tab-dmbtr_s .&lt;/P&gt;&lt;P&gt;    i_tab-dmbtril_h = i_tab-dmbtr_h .&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward point if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;mrutyun^&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 11:19:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975282#M702291</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-01T11:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975283#M702292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abhishek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; do like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; add an extra field rowcolor in your final internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab INTO wa.
      wa-rowcolor = 'C500'.
      MODIFY itab FROM wa TRANSPORTING rowcolor
        WHERE clause.
      CLEAR wa.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;lt;b&amp;gt;Reward points if it helps,&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Satish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 11:30:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv/m-p/2975283#M702292</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-01T11:30:12Z</dc:date>
    </item>
  </channel>
</rss>

