<?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 through oops and function module in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083603#M976420</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;oops method....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

REPORT ZWA_ALV_COLORS .
 
tables : BKPF.
 
types : begin of ty_BKPF,
  belnr like BKPF-belnr,
  bukrs like BKPF-bukrs,
  counter(4) type n,
  color_line(4) type c, " Line color
  color_cell type lvc_t_scol, " Cell color
end of ty_BKPF.
 
* Structures
data : wa_BKPF type ty_BKPF,
wa_fieldcat type lvc_s_fcat,
is_layout type lvc_s_layo,
wa_color type lvc_s_scol.
 
* Internal table
data : it_BKPF type standard table of ty_BKPF,
       it_fieldcat type standard table of lvc_s_fcat,
       it_color type table of lvc_s_scol.
 
* Variables
data : okcode like sy-ucomm,
       w_alv_grid type ref to cl_gui_alv_grid,
       w_docking_container type ref to cl_gui_docking_container.
 
 
parameters : p_column as checkbox DEFAULT 'X',
             p_line as checkbox DEFAULT 'X',
             p_cell as checkbox DEFAULT 'X'.
 
 
at selection-screen output.
 
  perform get_data.
  perform fill_catalog.
 
  if w_docking_container is initial.
    perform create_objects.
  endif.
 
*&amp;amp;--------------------------------------------------------------*
*&amp;amp; Form create_objects
*&amp;amp;--------------------------------------------------------------*
form create_objects.
 
  create object w_docking_container
  exporting
  ratio = 40
  exceptions
  cntl_error = 1
  cntl_system_error = 2
  create_error = 3
  lifetime_error = 4
  lifetime_dynpro_dynpro_link = 5
  others = 6.
 
  create object w_alv_grid
  exporting
  i_parent = w_docking_container.
 
* Field that identify color line in internal table
  move 'COLOR_LINE' to is_layout-info_fname.
 
* Field that identify cell color in inetrnal table
  move 'COLOR_CELL' to is_layout-ctab_fname.
 
  call method w_alv_grid-&amp;gt;set_table_for_first_display
  exporting
  is_layout = is_layout
  changing
  it_outtab = it_BKPF
  it_fieldcatalog = it_fieldcat
  exceptions
  invalid_parameter_combination = 1
  program_error = 2
  too_many_lines = 3
  others = 4.
 
endform.
*&amp;amp;--------------------------------------------------------------*
*&amp;amp; Form get_data
*&amp;amp;--------------------------------------------------------------*
form get_data.
 "Check this code for colour
  select * from BKPF up to 50 rows.
    clear : wa_BKPF-color_line, wa_BKPF-color_cell.
 
    move-corresponding BKPF to wa_BKPF.
    add 1 to wa_BKPF-counter.
 
    if wa_BKPF-COUNTER = '2' AND p_line = 'X'.
* Color line
      move 'C610' to wa_BKPF-color_line.
    elseif wa_BKPF-counter = '0004'
    and p_cell = 'X'.
* Color cell
      move 'BELNR' to wa_color-fname.
      move '1' to wa_color-color-col.
      move '1' to wa_color-color-int.
      move '1' to wa_color-color-inv.
      append wa_color to it_color.
      wa_BKPF-color_cell[] = it_color[].
    endif.
 
    append wa_BKPF to it_BKPF.
  endselect.
 
endform.
*&amp;amp;--------------------------------------------------------------*
*&amp;amp; Form fill_catalog
*&amp;amp;--------------------------------------------------------------*
form fill_catalog.
 
*****************************************************************
* Colour code : *
* Colour is a 4-char field where : *
* - 1st char = C (color property) *
* - 2nd char = color code (from 0 to 7) *
* 0 = background color *
* 1 = blue *
* 2 = gray *
* 3 = yellow *
* 4 = blue/gray *
* 5 = green *
* 6 = red *
* 7 = orange *
* - 3rd char = intensified (0=off, 1=on) *
* - 4th char = inverse display (0=off, 1=on) *
* *
* Colour overwriting priority : *
* 1. Line *
* 2. Cell *
* 3. Column *
*****************************************************************
  data : w_position type i value '1'.
 "In field catalog filling coulour
  clear wa_fieldcat.
  move w_position to wa_fieldcat-col_pos.
  move 'BELNR' to wa_fieldcat-fieldname.
  move 'BKPF' to wa_fieldcat-ref_table.
  move 'BELNR' to wa_fieldcat-ref_field.
  append wa_fieldcat to it_fieldcat.
 
  add 1 to w_position.
 
  clear wa_fieldcat.
  move w_position to wa_fieldcat-col_pos.
  move 'BUKRS' to wa_fieldcat-fieldname.
  move 'BKPF' to wa_fieldcat-ref_table.
  move 'BUKRS' to wa_fieldcat-ref_field.
* Color column
  if p_column = 'X'.
    move 'C510' to wa_fieldcat-emphasize.
  endif.
  append wa_fieldcat to it_fieldcat.
 
  add 1 to w_position.
 
  clear wa_fieldcat.
  move w_position to wa_fieldcat-col_pos.
  move 'COUNTER' to wa_fieldcat-fieldname.
  move 'N' to wa_fieldcat-inttype.
  move '4' to wa_fieldcat-intlen.
  move 'Counter' to wa_fieldcat-coltext.
  append wa_fieldcat to it_fieldcat.
 
  add 1 to w_position.
 
*  clear wa_fieldcat.
*  move w_position to wa_fieldcat-col_pos.
*  move 'FREE_TEXT' to wa_fieldcat-fieldname.
*  move 'C' to wa_fieldcat-inttype.
*  move '20' to wa_fieldcat-intlen.
*  move 'Text' to wa_fieldcat-coltext.
*  append wa_fieldcat to it_fieldcat.
ENDFORM.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Jun 2008 11:44:08 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-26T11:44:08Z</dc:date>
    <item>
      <title>AlV through oops and function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083597#M976414</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;I required a code to generate the alv through &lt;/P&gt;&lt;P&gt;oops and function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Jatender&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2008 11:15:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083597#M976414</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-26T11:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: AlV through oops and function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083598#M976415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this..&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdev.co.uk/reporting/alvhome.htm" target="test_blank"&gt;http://www.sapdev.co.uk/reporting/alvhome.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2008 11:16:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083598#M976415</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-26T11:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: AlV through oops and function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083599#M976416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The below is the obj oriented method.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

REPORT  ZAMIT_TEST2.


TYPE-POOLS: icon, col.
* type for internal table
TYPES: BEGIN OF t_marc.
        INCLUDE STRUCTURE marc.
* internal table for cell color information
TYPES : it_colors TYPE lvc_t_scol,
END OF t_marc.

DATA: it_marc TYPE TABLE OF t_marc.
DATA: wa_marc LIKE LINE OF it_marc.
DATA: wa_colors LIKE LINE OF wa_marc-it_colors.

DATA: gr_alv TYPE REF TO cl_salv_table.
DATA: lr_columns TYPE REF TO cl_salv_columns_table.

SELECT-OPTIONS: so_mat FOR wa_marc-matnr MEMORY ID car.

START-OF-SELECTION.
* retrieve data into internal table
  SELECT * FROM marc
    INTO CORRESPONDING FIELDS OF TABLE it_marc
  WHERE matnr IN so_mat.

  LOOP AT it_marc INTO wa_marc.

    IF wa_marc-werks = '1060'.
      CLEAR wa_colors.
      wa_colors-fname = ''.
      wa_colors-color-col = col_positive.
      wa_colors-color-int = 1.
      APPEND wa_colors TO wa_marc-it_colors.
    ENDIF.
    MODIFY it_marc FROM wa_marc TRANSPORTING it_colors.
  ENDLOOP.

  CALL METHOD cl_salv_table=&amp;gt;factory
  EXPORTING
  list_display = if_salv_c_bool_sap=&amp;gt;false
  IMPORTING
  r_salv_table = gr_alv
  CHANGING
  t_table = it_marc.

  lr_columns = gr_alv-&amp;gt;get_columns( ).

  lr_columns-&amp;gt;set_color_column( value = 'IT_COLORS' ).

* display ALV
gr_alv-&amp;gt;display( ).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2008 11:18:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083599#M976416</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-26T11:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: AlV through oops and function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083600#M976417</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;  Refer to the following link.&lt;/P&gt;&lt;P&gt;1.using function modules:&lt;/P&gt;&lt;P&gt;&lt;A href="http://saptechnical.com/Tutorials/ALV/SampleALVGridProgram.htm" target="test_blank"&gt;http://saptechnical.com/Tutorials/ALV/SampleALVGridProgram.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.Using OOPs.&lt;/P&gt;&lt;P&gt;&lt;A href="http://saptechnical.com/Tutorials/ALV/Interactive/oops.htm" target="test_blank"&gt;http://saptechnical.com/Tutorials/ALV/Interactive/oops.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jaya Vani&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2008 11:19:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083600#M976417</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-26T11:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: AlV through oops and function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083601#M976418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jatinder,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;welcome to SDN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just refer:&lt;/P&gt;&lt;P&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="749056"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&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="747362"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&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="737977"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dont forget to reward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Amit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2008 11:21:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083601#M976418</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-26T11:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: AlV through oops and function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083602#M976419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jatender,&lt;/P&gt;&lt;P&gt;Check below simple code to understand better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT z75694_alv.
*----------------------------------------------------------------------
*Internal tables
*----------------------------------------------------------------------
DATA: i_mara  TYPE STANDARD TABLE OF mara,
      i_fieldcat       TYPE STANDARD TABLE OF lvc_s_fcat,
      container        TYPE REF TO cl_gui_custom_container,
      container2       TYPE REF TO cl_gui_custom_container,
      grid             TYPE REF TO cl_gui_alv_grid,
      grid_c           TYPE REF TO cl_gui_alv_grid.
*----------------------------------------------------------------------
*Work-Areas
*----------------------------------------------------------------------
DATA: wa_fieldcat TYPE lvc_s_fcat.

*----------------------------------------------------------------------
*Selection Screen
*----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK main WITH FRAME.
SELECTION-SCREEN BEGIN OF BLOCK sub1 WITH FRAME.
SELECT-OPTIONS: so_matnr FOR mara-matnr.
SELECTION-SCREEN END OF BLOCK sub1.
SELECTION-SCREEN END OF BLOCK main.
*----------------------------------------------------------------------
*START-OF-SELECTION.
*----------------------------------------------------------------------
START-OF-SELECTION.
PERFORM select_data.
*----------------------------------------------------------------------
*END-OF-SELECTION.
*----------------------------------------------------------------------
END-OF-SELECTION.
PERFORM display_alv.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  select_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM select_data.
  SELECT * INTO TABLE i_mara
           FROM mara
           WHERE matnr IN so_matnr.
ENDFORM.                    " select_data

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  display_alv
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM display_alv.
  CALL SCREEN 100.
ENDFORM.                    " display_alv

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  fieldcat
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM fieldcat USING fname tname pos edit.
  CLEAR wa_fieldcat.
  wa_fieldcat-fieldname = fname.
  wa_fieldcat-tabname   = tname.
  wa_fieldcat-scrtext_l = fname.
  wa_fieldcat-scrtext_m = fname.
  wa_fieldcat-scrtext_s = fname.
  wa_fieldcat-just      = ' '.
  wa_fieldcat-col_pos   = pos.
  wa_fieldcat-edit = edit.
  APPEND wa_fieldcat TO i_fieldcat.
ENDFORM.                    " fieldcat

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  STATUS_0100  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS '100'.
  SET TITLEBAR '100'.
ENDMODULE.                 " STATUS_0100  OUTPUT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  USER_COMMAND_0100  INPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK' OR 'EXIT'.
      LEAVE TO SCREEN 0.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
    WHEN 'SAVE' OR 'UPDATE'.
*      PERFORM update_table.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  display_data  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE display_data OUTPUT.
  PERFORM: fieldcat USING 'MATNR'     'ZVINU' 2 space.

*clear i_fieldcat.

  CREATE OBJECT container
    EXPORTING
      container_name    = 'CON'.

  CREATE OBJECT grid
    EXPORTING
      i_parent          = container.


  CALL METHOD grid-&amp;gt;set_table_for_first_display
*    EXPORTING
*      is_layout                     = wa_layout
    CHANGING
      it_outtab                     = i_mara
      it_fieldcatalog               = i_fieldcat
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc &amp;lt;&amp;gt; 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDMODULE.                 " display_data  OUTPUT
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Define screen 100 with one container name as &lt;STRONG&gt;CON&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinod.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2008 11:23:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083602#M976419</guid>
      <dc:creator>vinod_vemuru2</dc:creator>
      <dc:date>2008-06-26T11:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: AlV through oops and function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083603#M976420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;oops method....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

REPORT ZWA_ALV_COLORS .
 
tables : BKPF.
 
types : begin of ty_BKPF,
  belnr like BKPF-belnr,
  bukrs like BKPF-bukrs,
  counter(4) type n,
  color_line(4) type c, " Line color
  color_cell type lvc_t_scol, " Cell color
end of ty_BKPF.
 
* Structures
data : wa_BKPF type ty_BKPF,
wa_fieldcat type lvc_s_fcat,
is_layout type lvc_s_layo,
wa_color type lvc_s_scol.
 
* Internal table
data : it_BKPF type standard table of ty_BKPF,
       it_fieldcat type standard table of lvc_s_fcat,
       it_color type table of lvc_s_scol.
 
* Variables
data : okcode like sy-ucomm,
       w_alv_grid type ref to cl_gui_alv_grid,
       w_docking_container type ref to cl_gui_docking_container.
 
 
parameters : p_column as checkbox DEFAULT 'X',
             p_line as checkbox DEFAULT 'X',
             p_cell as checkbox DEFAULT 'X'.
 
 
at selection-screen output.
 
  perform get_data.
  perform fill_catalog.
 
  if w_docking_container is initial.
    perform create_objects.
  endif.
 
*&amp;amp;--------------------------------------------------------------*
*&amp;amp; Form create_objects
*&amp;amp;--------------------------------------------------------------*
form create_objects.
 
  create object w_docking_container
  exporting
  ratio = 40
  exceptions
  cntl_error = 1
  cntl_system_error = 2
  create_error = 3
  lifetime_error = 4
  lifetime_dynpro_dynpro_link = 5
  others = 6.
 
  create object w_alv_grid
  exporting
  i_parent = w_docking_container.
 
* Field that identify color line in internal table
  move 'COLOR_LINE' to is_layout-info_fname.
 
* Field that identify cell color in inetrnal table
  move 'COLOR_CELL' to is_layout-ctab_fname.
 
  call method w_alv_grid-&amp;gt;set_table_for_first_display
  exporting
  is_layout = is_layout
  changing
  it_outtab = it_BKPF
  it_fieldcatalog = it_fieldcat
  exceptions
  invalid_parameter_combination = 1
  program_error = 2
  too_many_lines = 3
  others = 4.
 
endform.
*&amp;amp;--------------------------------------------------------------*
*&amp;amp; Form get_data
*&amp;amp;--------------------------------------------------------------*
form get_data.
 "Check this code for colour
  select * from BKPF up to 50 rows.
    clear : wa_BKPF-color_line, wa_BKPF-color_cell.
 
    move-corresponding BKPF to wa_BKPF.
    add 1 to wa_BKPF-counter.
 
    if wa_BKPF-COUNTER = '2' AND p_line = 'X'.
* Color line
      move 'C610' to wa_BKPF-color_line.
    elseif wa_BKPF-counter = '0004'
    and p_cell = 'X'.
* Color cell
      move 'BELNR' to wa_color-fname.
      move '1' to wa_color-color-col.
      move '1' to wa_color-color-int.
      move '1' to wa_color-color-inv.
      append wa_color to it_color.
      wa_BKPF-color_cell[] = it_color[].
    endif.
 
    append wa_BKPF to it_BKPF.
  endselect.
 
endform.
*&amp;amp;--------------------------------------------------------------*
*&amp;amp; Form fill_catalog
*&amp;amp;--------------------------------------------------------------*
form fill_catalog.
 
*****************************************************************
* Colour code : *
* Colour is a 4-char field where : *
* - 1st char = C (color property) *
* - 2nd char = color code (from 0 to 7) *
* 0 = background color *
* 1 = blue *
* 2 = gray *
* 3 = yellow *
* 4 = blue/gray *
* 5 = green *
* 6 = red *
* 7 = orange *
* - 3rd char = intensified (0=off, 1=on) *
* - 4th char = inverse display (0=off, 1=on) *
* *
* Colour overwriting priority : *
* 1. Line *
* 2. Cell *
* 3. Column *
*****************************************************************
  data : w_position type i value '1'.
 "In field catalog filling coulour
  clear wa_fieldcat.
  move w_position to wa_fieldcat-col_pos.
  move 'BELNR' to wa_fieldcat-fieldname.
  move 'BKPF' to wa_fieldcat-ref_table.
  move 'BELNR' to wa_fieldcat-ref_field.
  append wa_fieldcat to it_fieldcat.
 
  add 1 to w_position.
 
  clear wa_fieldcat.
  move w_position to wa_fieldcat-col_pos.
  move 'BUKRS' to wa_fieldcat-fieldname.
  move 'BKPF' to wa_fieldcat-ref_table.
  move 'BUKRS' to wa_fieldcat-ref_field.
* Color column
  if p_column = 'X'.
    move 'C510' to wa_fieldcat-emphasize.
  endif.
  append wa_fieldcat to it_fieldcat.
 
  add 1 to w_position.
 
  clear wa_fieldcat.
  move w_position to wa_fieldcat-col_pos.
  move 'COUNTER' to wa_fieldcat-fieldname.
  move 'N' to wa_fieldcat-inttype.
  move '4' to wa_fieldcat-intlen.
  move 'Counter' to wa_fieldcat-coltext.
  append wa_fieldcat to it_fieldcat.
 
  add 1 to w_position.
 
*  clear wa_fieldcat.
*  move w_position to wa_fieldcat-col_pos.
*  move 'FREE_TEXT' to wa_fieldcat-fieldname.
*  move 'C' to wa_fieldcat-inttype.
*  move '20' to wa_fieldcat-intlen.
*  move 'Text' to wa_fieldcat-coltext.
*  append wa_fieldcat to it_fieldcat.
ENDFORM.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2008 11:44:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-through-oops-and-function-module/m-p/4083603#M976420</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-26T11:44:08Z</dc:date>
    </item>
  </channel>
</rss>

