<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ABAP Tutorials &#187; ALV grid</title>
	<atom:link href="http://www.abap-tutorials.com/tag/alv-grid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.abap-tutorials.com</link>
	<description>ABAP Tutorials, Guides, Training, Manuals</description>
	<lastBuildDate>Thu, 17 Nov 2011 07:43:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Saving Custom Layouts in SAP ALV</title>
		<link>http://www.abap-tutorials.com/2010/04/17/saving-custom-layouts-in-sap-alv/</link>
		<comments>http://www.abap-tutorials.com/2010/04/17/saving-custom-layouts-in-sap-alv/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 06:07:35 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[Formatting]]></category>
		<category><![CDATA[Quick Reference]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[ALV]]></category>
		<category><![CDATA[ALV grid]]></category>
		<category><![CDATA[custom layout]]></category>
		<category><![CDATA[layout in ALV]]></category>
		<category><![CDATA[saving layout]]></category>

		<guid isPermaLink="false">http://www.abap-tutorials.com/?p=1471</guid>
		<description><![CDATA[When using a progam or report dealing in ALV, user sometimes does not get the proper display at the time of output in ALV. The reason is non-customising of the layout by the user or the default layout set by other user. Following process will help you to store your own customized layout.  When displaying the ALV result, adjust the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">When using a progam or report dealing in ALV, user sometimes does not get the proper display at the time of output in ALV. The reason is non-customising of the layout by the user or the default layout set by other user.</p>
<div style="width: 100%; float: left;">
<p style="text-align: justify;"><a href="http://www.abap-tutorials.com/wp-content/uploads/2010/04/alv_grid.png"><img class="aligncenter size-full wp-image-1472" title="ALV Grid" src="http://www.abap-tutorials.com/wp-content/uploads/2010/04/alv_grid.png" alt="" width="410" height="314" /></a></p>
</div>
<p style="text-align: justify;">Following process will help you to store your own customized layout.</p>
<p style="text-align: justify;"><span id="more-1471"></span></p>
<p style="text-align: justify;"> When displaying the ALV result, adjust the layout according to your need. Now save the layout by navigating to Settings -&gt; Layout -&gt; Savings.</p>
<div style="width: 100%; float: left;">
<p style="text-align: center;"><a href="http://www.abap-tutorials.com/wp-content/uploads/2010/04/saving_custom_layout.jpg"><img class="aligncenter size-full wp-image-1473" title="save Layout" src="http://www.abap-tutorials.com/wp-content/uploads/2010/04/saving_custom_layout.jpg" alt="" width="423" height="317" /></a></p>
</div>
<p style="text-align: justify;"> </p>
<p style="text-align: justify;">Enter the layout Code and layout Name name that you want to save. Check the checkbox &#8216;User-Specific&#8217; to make the layout specific to your login. You can also set one of the layout as your default layout by checking the checkbox &#8216;Default Setting&#8217;.</p>
<div style="width:100%;float:left">
<p style="text-align: center;"> <a href="http://www.abap-tutorials.com/wp-content/uploads/2010/04/saving_custom_layout2.jpg"><img class="aligncenter size-full wp-image-1477" title="Save Custom Layout" src="http://www.abap-tutorials.com/wp-content/uploads/2010/04/saving_custom_layout2.jpg" alt="" width="349" height="284" /></a></p>
</div>
<p style="text-align: justify;">
<p style="text-align: justify;">
<strong>Points to remember:</strong><br />
1. The name of your layout must not start with a number, because this type of name is reserved for the standard layouts delivered by SAP.<br />
2. Non-user-specific layouts (client-specific standard layouts) must begin with &#8220;/&#8221;.</p>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/07/17/assign-a-t-code-to-maintenance-view/' rel='bookmark' title='Assign a T-code to Maintenance View in SAP'>Assign a T-code to Maintenance View in SAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/20/abap-editor-create-custom-pattern/' rel='bookmark' title='ABAP Editor: Create custom Pattern'>ABAP Editor: Create custom Pattern</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/11/add-custom-button-onto-alv-grid/' rel='bookmark' title='Add custom button onto ALV Grid in SAP'>Add custom button onto ALV Grid in SAP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2010/04/17/saving-custom-layouts-in-sap-alv/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ABAP Program to add Colors in ALV Grid</title>
		<link>http://www.abap-tutorials.com/2009/09/17/abap-program-to-add-colors-in-alv-grid/</link>
		<comments>http://www.abap-tutorials.com/2009/09/17/abap-program-to-add-colors-in-alv-grid/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 11:01:33 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[ALV]]></category>
		<category><![CDATA[Formatting]]></category>
		<category><![CDATA[Report]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[ALV grid]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[SAP]]></category>

		<guid isPermaLink="false">http://www.abap-tutorials.com/?p=976</guid>
		<description><![CDATA[Normally, there are requirements to display set of rows differently based to certain conditions in ALV. To distinguish them easily, in a one go, we can add colors to the rows(based on condition of course). The following program adds strokes of different color to your ALV Grid.    Program Code *&#038;---------------------------------------------------------------------* *&#038; Report ZCOLOR_IN_ALV *&#038; [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Normally, there are requirements to display set of rows differently based to certain conditions in ALV. To distinguish them easily, in a one go, we can add colors to the rows(based on condition of course).<br />
The following program adds strokes of different color to your ALV Grid.</p>
<p style="text-align: center;"> </p>
<div style="float: left; width: 100%;"><img class="aligncenter size-full wp-image-977" title="Add Color in ALV" src="http://www.abap-tutorials.com/wp-content/uploads/2009/09/color_in_alv.jpg" alt="Add Color in ALV" width="517" height="263" /></div>
<p><span style="color: #00ff00;"><span id="more-976"></span></span></p>
<p><span style="color: #00ff00;"> <strong><span style="color: #339966;">Program Code</span></strong></span></p>
<pre lang="ABAP">
*&#038;---------------------------------------------------------------------*
*&#038; Report  ZCOLOR_IN_ALV
*&#038;
*&#038;---------------------------------------------------------------------*
*&#038;
*&#038;
*&#038;---------------------------------------------------------------------*

REPORT  ZCOLOR_IN_ALV.

TABLES: ekko.

type-pools: slis. "ALV Declarations
*Data Declaration*----------------
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) type c, "Used to store row color attributes
END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.

*Start-of-selection.
START-OF-SELECTION.

  perform data_retrieval.

  perform build_fieldcatalog.

  perform build_layout.

  perform display_alv_report.

*&#038;---------------------------------------------------------------------
**&#038; Form BUILD_FIELDCATALOG
*&#038;---------------------------------------------------------------------
** Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.

  fieldcatalog-fieldname = 'EBELN'.
  fieldcatalog-seltext_m = 'Purchase Order'.
  fieldcatalog-col_pos = 0.
  fieldcatalog-outputlen = 10.
  fieldcatalog-emphasize = 'X'.
  fieldcatalog-key = 'X'.
  append fieldcatalog to fieldcatalog.
  clear fieldcatalog.

  fieldcatalog-fieldname = 'EBELP'.
  fieldcatalog-seltext_m = 'PO Item'.
  fieldcatalog-col_pos = 1.
  append fieldcatalog to fieldcatalog.
  clear fieldcatalog.

  fieldcatalog-fieldname = 'STATU'.
  fieldcatalog-seltext_m = 'Status'.
  fieldcatalog-col_pos = 2.
  append fieldcatalog to fieldcatalog.
  clear fieldcatalog.

  fieldcatalog-fieldname = 'AEDAT'.
  fieldcatalog-seltext_m = 'Item change date'.
  fieldcatalog-col_pos = 3.
  append fieldcatalog to fieldcatalog.
  clear fieldcatalog.

  fieldcatalog-fieldname = 'MATNR'.
  fieldcatalog-seltext_m = 'Material Number'.
  fieldcatalog-col_pos = 4.
  append fieldcatalog to fieldcatalog.
  clear fieldcatalog.

  fieldcatalog-fieldname = 'MENGE'.
  fieldcatalog-seltext_m = 'PO quantity'.
  fieldcatalog-col_pos = 5.
  append fieldcatalog to fieldcatalog.
  clear fieldcatalog.

  fieldcatalog-fieldname = 'MEINS'.
  fieldcatalog-seltext_m = 'Order Unit'.
  fieldcatalog-col_pos = 6.
  append fieldcatalog to fieldcatalog.
  clear fieldcatalog.

  fieldcatalog-fieldname = 'NETPR'.
  fieldcatalog-seltext_m = 'Net Price'.
  fieldcatalog-col_pos = 7.
  fieldcatalog-outputlen = 15.
  fieldcatalog-datatype = 'CURR'.
  append fieldcatalog to fieldcatalog.
  clear fieldcatalog.

  fieldcatalog-fieldname = 'PEINH'.
  fieldcatalog-seltext_m = 'Price Unit'.
  fieldcatalog-col_pos = 8.
  append fieldcatalog to fieldcatalog.
  clear fieldcatalog.
endform. " BUILD_FIELDCATALOG

*&#038;---------------------------------------------------------------------
**&#038; Form BUILD_LAYOUT
*&#038;---------------------------------------------------------------------
** Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
  gd_layout-no_input          = 'X'.
  gd_layout-colwidth_optimize = 'X'.
  gd_layout-totals_text       = 'Totals'(201).
  gd_layout-info_fieldname    = 'LINE_COLOR'.

endform. " BUILD_LAYOUT

*&#038;---------------------------------------------------------------------
**&#038; Form DISPLAY_ALV_REPORT
*&#038;---------------------------------------------------------------------
** Display report using ALV grid
*----------------------------------------------------------------------*
form display_alv_report.
  gd_repid = sy-repid.
  call function 'REUSE_ALV_GRID_DISPLAY'
  exporting
  i_callback_program = gd_repid
  is_layout          = gd_layout
  it_fieldcat        = fieldcatalog[]
  i_save             = 'X'
*is_variant = z_template
  tables
  t_outtab          = it_ekko .

endform. " DISPLAY_ALV_REPORT
*&#038;---------------------------------------------------------------------
**&#038; Form DATA_RETRIEVAL
*&#038;---------------------------------------------------------------------
** Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------
form data_retrieval.
  data: ld_color(1) type c.

  select ebeln
  ebelp
  statu
  aedat
  matnr
  menge
  meins
  netpr
  peinh
  up to 10 rows
  from ekpo
  into table it_ekko.

*Populate field with color attributes
  loop at it_ekko into wa_ekko.
* Populate color variable with colour properties
* Char 1 = C (This is a color property)
* Char 2 = 3 (Color codes: 1 - 7)
* Char 3 = Intensified on/off ( 1 or 0 )
* Char 4 = Inverse display on/off ( 1 or 0 )
* i.e. wa_ekko-line_color = 'C410'
    ld_color = ld_color + 1.
* Only 7 colours so need to reset color value
    if ld_color = 8.
      ld_color = 1.
    endif.

    concatenate 'C' ld_color '10' into wa_ekko-line_color.
* wa_ekko-line_color = 'C410'.
    modify it_ekko from wa_ekko.
  endloop.

endform. " DATA_RETRIEVAL
</pre>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/09/10/displaying-icons-in-alv-abap/' rel='bookmark' title='Displaying Icons in ALV Grid using ABAP'>Displaying Icons in ALV Grid using ABAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/08/06/search-for-smartforms-in-your-language/' rel='bookmark' title='ABAP Program to Search For SMARTFORMS in your Language'>ABAP Program to Search For SMARTFORMS in your Language</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/09/alv-grid-the-oops-way/' rel='bookmark' title='ABAP Program for ALV Grid, the OOPS way'>ABAP Program for ALV Grid, the OOPS way</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2009/09/17/abap-program-to-add-colors-in-alv-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Displaying Icons in ALV Grid using ABAP</title>
		<link>http://www.abap-tutorials.com/2009/09/10/displaying-icons-in-alv-abap/</link>
		<comments>http://www.abap-tutorials.com/2009/09/10/displaying-icons-in-alv-abap/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 12:25:24 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[ALV]]></category>
		<category><![CDATA[Formatting]]></category>
		<category><![CDATA[Function Modules]]></category>
		<category><![CDATA[Report]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[ALV grid]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[icons in ALV]]></category>
		<category><![CDATA[SAP]]></category>

		<guid isPermaLink="false">http://www.abap-tutorials.com/?p=930</guid>
		<description><![CDATA[The following code adds an icon  (exclamation) to the ALV grid/list. It also includes the code for adding hot-spot to ALV column. Program Code REPORT ZICON_IN_ALV. ************************************************************************ * Include Programs ************************************************************************ *INCLUDE . ************************************************************************ * Database Tables ************************************************************************ TABLES: kna1. "Customer Master ************************************************************************ * Types ************************************************************************ TYPE-POOLS: kkblo. ************************************************************************ * Structures ************************************************************************ * Structure to [...]]]></description>
			<content:encoded><![CDATA[<p>The following code adds an icon  (exclamation) to the ALV grid/list. It also includes the code for adding hot-spot to ALV column.</p>
<div style="width:100%;float:left">
<p style="text-align: center;"><img src="http://www.abap-tutorials.com/wp-content/uploads/2009/09/icons_in_alv.jpg" alt="icons_in_alv" width="550" height="312" /></p>
</div>
<p style="text-align: center;">
<p style="text-align: center;">
<p><span id="more-930"></span></p>
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;">
<p><strong><span style="color: #339966;">Program Code</span></strong></p>
<pre lang="ABAP">REPORT  ZICON_IN_ALV.

************************************************************************

* Include Programs

************************************************************************

*INCLUDE .

************************************************************************

* Database Tables

************************************************************************

TABLES: kna1. "Customer Master

************************************************************************

* Types

************************************************************************

TYPE-POOLS: kkblo.

************************************************************************

* Structures

************************************************************************

* Structure to hold the Color Information

DATA: BEGIN OF st_color,

color(3) TYPE c,

END OF st_color.

* Structure to hold the Icon Information

DATA: BEGIN OF st_icon,

icon(4) TYPE c,

END OF st_icon.

* ALV Field Catalog Structure

DATA: st_fieldcat TYPE slis_fieldcat_alv.

* ALV Layout Structure

DATA: st_layout TYPE slis_layout_alv.

************************************************************************

* Internal Tables

************************************************************************

* Output Table

DATA: BEGIN OF tbl_kna1 OCCURS 0.

INCLUDE STRUCTURE st_icon. "Icon Structure

INCLUDE STRUCTURE kna1. "Customer Master Structure

INCLUDE STRUCTURE st_color. "Color Structure

DATA: END OF tbl_kna1.

* ALV Field Catalog Table

DATA: tbl_fieldcat TYPE slis_t_fieldcat_alv.

************************************************************************

* Variables

************************************************************************

DATA: fieldname(30) TYPE c,

g_repid LIKE sy-repid.

************************************************************************

* Start of Selection

************************************************************************

START-OF-SELECTION.

g_repid = sy-repid.

PERFORM get_data.

************************************************************************

* End of Selection

************************************************************************

END-OF-SELECTION.

PERFORM do_fancy_stuff.

PERFORM get_layout.

PERFORM get_fieldcat.

PERFORM create_report.

*&amp;---------------------------------------------------------------------*

*&amp; Form CREATE_REPORT

*&amp;---------------------------------------------------------------------*

* Learn to read the subroutine name!

*----------------------------------------------------------------------*

FORM create_report.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_interface_check = ' '

i_callback_program = g_repid

i_callback_user_command = 'PROCESS_USER_COMMANDS'

it_fieldcat = tbl_fieldcat

i_default = 'X'

i_save = ' '

is_layout = st_layout

TABLES

t_outtab = tbl_kna1

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc &lt;&gt; 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " CREATE_REPORT

*&amp;---------------------------------------------------------------------*

*&amp; Form GET_FIELDCAT

*&amp;---------------------------------------------------------------------*

* Build the Field Catalog

*----------------------------------------------------------------------*

FORM get_fieldcat.

* Here the field catalog is created. To display more fields simply

* 'uncomment' the additional lines and add the field name. Also note

* that the field catalog is much more powerful than this. You can

* intensify fields, change the colour, assign reference fields, etc.

* Look at type slis_fieldcat_alv for more options.

PERFORM write_fieldcat USING 'ICON' 'TBL_KNA1' ' ' 'X' 1 '2' 'X'

' '.

PERFORM write_fieldcat USING 'KUNNR' 'TBL_KNA1' 'KNA1' 'X' 2 ' ' ' '

' '.

PERFORM write_fieldcat USING 'NAME1' 'TBL_KNA1' 'KNA1' ' ' 3 '10' ' '

'X'.

PERFORM write_fieldcat USING 'STRAS' 'TBL_KNA1' 'KNA1' ' ' 4 ' ' ' '

' '.

PERFORM write_fieldcat USING 'TELF1' 'TBL_KNA1' 'KNA1' ' ' 5 ' ' ' '

' '.

PERFORM write_fieldcat USING 'ORT01' 'TBL_KNA1' 'KNA1' ' ' 6 ' ' ' '

' '.

PERFORM write_fieldcat USING 'PSTLZ' 'TBL_KNA1' 'KNA1' ' ' 7 ' ' ' '

' '.

PERFORM write_fieldcat USING 'SORTL' 'TBL_KNA1' 'KNA1' ' ' 8 ' ' ' '

' '.

PERFORM write_fieldcat USING 'ERNAM' 'TBL_KNA1' 'KNA1' ' ' 9 ' ' ' '

' '.

PERFORM write_fieldcat USING 'SPRAS' 'TBL_KNA1' 'KNA1' ' ' 10 ' ' ' '

' '.

* perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 10 ' '.

* perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 11 ' '.

* perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 12 ' '.

ENDFORM. " GET_FIELDCAT

*&amp;---------------------------------------------------------------------*

*&amp; Form WRITE_FIELDCAT

*&amp;---------------------------------------------------------------------*

* Write the Field Catalog data to the Field Catalog Table

*----------------------------------------------------------------------*

* --&gt;name Field name

* --&gt;tab Table name

* --&gt;st Structure Name

* --&gt;key Is this field a Key?

* --&gt;pos Position Number

* --&gt;length Field Length

* --&gt;icon Display as Icon

* --&gt;hot Hotspot

*----------------------------------------------------------------------*

FORM write_fieldcat USING name tab st key pos length icon hot.

st_fieldcat-fieldname = name.

st_fieldcat-tabname = tab.

st_fieldcat-ref_tabname = st.

st_fieldcat-key = key.

st_fieldcat-col_pos = pos.

st_fieldcat-outputlen = length.

st_fieldcat-icon = icon.

st_fieldcat-hotspot = hot.

APPEND st_fieldcat TO tbl_fieldcat.

CLEAR st_fieldcat.

ENDFORM. " WRITE_FIELDCAT

*&amp;---------------------------------------------------------------------*

*&amp; Form PROCESS_USER_COMMANDS

*&amp;---------------------------------------------------------------------*

* Interactive Reporting Commands

*----------------------------------------------------------------------*

FORM process_user_commands USING syst-ucomm LIKE syst-ucomm

selfield TYPE slis_selfield.

* This subroutine is called when there is user interaction in the output

* In this case if the user double clicks the Customer Number then the

* program will call transaction XD03 and display the Customer Master

* Data

CASE syst-ucomm.

WHEN '&amp;IC1'.

* get cursor field fieldname.

READ TABLE tbl_kna1 INDEX selfield-tabindex.

SET PARAMETER ID 'KUN' FIELD tbl_kna1-kunnr.

CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.

ENDCASE.

ENDFORM. " PROCESS_USER_COMMANDS

*&amp;---------------------------------------------------------------------*

*&amp; Form GET_LAYOUT

*&amp;---------------------------------------------------------------------*

* set the layout of the ALV.

* add color to the row?

*----------------------------------------------------------------------*

FORM get_layout.

st_layout-info_fieldname = 'COLOR'.

st_layout-colwidth_optimize = 'X'.

st_layout-get_selinfos = 'X'.

ENDFORM. " GET_LAYOUT

*&amp;---------------------------------------------------------------------*

*&amp; Form get_data

*&amp;---------------------------------------------------------------------*

* Get some data to play with

*----------------------------------------------------------------------*

FORM get_data.

SELECT * FROM kna1 INTO CORRESPONDING FIELDS OF TABLE tbl_kna1

UP TO 30 ROWS.

ENDFORM. " get_data

*&amp;---------------------------------------------------------------------*

*&amp; Form do_fancy_stuff

*&amp;---------------------------------------------------------------------*

* Do some fancy pants stuff for example changing the color of

* lines and adding icons

*----------------------------------------------------------------------*

FORM do_fancy_stuff.

* Here we will demonstrate changing the color of ALV Record lines as

* well as displaying Icons

LOOP AT tbl_kna1.

* All records where NAME1 begins with 'M', will be displayed in Bluish

* Green

IF tbl_kna1-name1(1) EQ 'M'.

tbl_kna1-color = 'C41'. "Bluish Green

MODIFY tbl_kna1 TRANSPORTING color.

ENDIF.

* All records with no TELF1 will be displayed in White and have a

* Warning Icon

IF tbl_kna1-telf1 IS INITIAL.

tbl_kna1-color = 'C00'. "White

tbl_kna1-icon = '@AH@'. "Warning Icon

MODIFY tbl_kna1 TRANSPORTING icon color.

ENDIF.

ENDLOOP.

ENDFORM. " do_fancy_stuff</pre>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/09/17/abap-program-to-add-colors-in-alv-grid/' rel='bookmark' title='ABAP Program to add Colors in ALV Grid'>ABAP Program to add Colors in ALV Grid</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/09/alv-grid-the-oops-way/' rel='bookmark' title='ABAP Program for ALV Grid, the OOPS way'>ABAP Program for ALV Grid, the OOPS way</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/28/edit-alv-grid-contents/' rel='bookmark' title='ABAP Program with Editable ALV Grid Contents'>ABAP Program with Editable ALV Grid Contents</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2009/09/10/displaying-icons-in-alv-abap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ABAP Program for Creating an ALV Grid in 3 lines</title>
		<link>http://www.abap-tutorials.com/2009/07/17/creating-an-alv-grid-in-3-lines/</link>
		<comments>http://www.abap-tutorials.com/2009/07/17/creating-an-alv-grid-in-3-lines/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 05:01:13 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[Abap Objects]]></category>
		<category><![CDATA[ALV]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[3 lines]]></category>
		<category><![CDATA[ALV grid]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[SAP]]></category>

		<guid isPermaLink="false">http://naveenvishal.wordpress.com/?p=228</guid>
		<description><![CDATA[Now you can create an ALV Grid very fast; you don&#8217;t need to define a layout, a fieldcatalog, a container and all the other small things we usually define in an ALV Grid. If we don&#8217;t need to finetune the ALV Grid and just want to display a list on the screen or to the [...]]]></description>
			<content:encoded><![CDATA[<p>Now you can create an ALV Grid very fast; you don&#8217;t need to define a layout, a fieldcatalog, a container and all the other small things we usually define in an ALV Grid. If we don&#8217;t need to finetune the ALV Grid and just want to display a list on the screen or to the printer, here is a very simple way to proceed.</p>
<p><img class="aligncenter size-medium wp-image-230" title="ALV Grid Output" src="http://naveenvishal.files.wordpress.com/2009/07/alv_in3_lines.jpg?w=300" alt="ALV Grid Output" width="300" height="217" /></p>
<p><span id="more-228"></span></p>
<p>Sample Code looks like:</p>
<p><!-- SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L1S31 { font-style: italic; color: #808080; } .L1S32 { color: #3399FF; } .L1S33 { color: #4DA619; } .L1S52 { color: #0000FF; } --> DATA: l_alv      TYPE REF TO   cl_gui_alv_grid,<br />
      lt_MARA TYPE TABLE OF MARA.<br />
  SELECT * FROM MARA INTO TABLE lt_MARA UP TO 10 ROWS.<br />
<span style="color:#3366ff;">* Creation of the ALV object, when we use cl_gui_container=&gt;screen0 as parent, the ALVGrid control will</span><span style="color:#3366ff;"><br />
</span> <span style="color:#3366ff;">* automatically use the full screen to display the grid, NO CONTAINER DEFINITION IS REQUIRED !</span><br />
CREATE OBJECT l_alv<br />
  EXPORTING<br />
    i_parent = cl_gui_container=&gt;screen0.</p>
<p><span style="color:#3366ff;">* calling the display of the grid, the system will automatically create the fieldcatalog based<br />
* on the table name you pass in parameter</span><br />
CALL METHOD l_alv-&gt;set_table_for_first_display<br />
  EXPORTING<br />
    i_structure_name = &#8217;MARA&#8217;<br />
  CHANGING<br />
    it_outtab        = lt_MARA.</p>
<p><span style="color:#3366ff;">* Define a &#8216;empty&#8217; selection screen, for ALV to be based on</span><br />
SELECTION-SCREEN BEGIN OF SCREEN 1001.</p>
<p>SELECTION-SCREEN END OF SCREEN 1001.</p>
<p>CALL SELECTION-SCREEN 1001.</p>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/09/17/abap-program-to-add-colors-in-alv-grid/' rel='bookmark' title='ABAP Program to add Colors in ALV Grid'>ABAP Program to add Colors in ALV Grid</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/28/edit-alv-grid-contents/' rel='bookmark' title='ABAP Program with Editable ALV Grid Contents'>ABAP Program with Editable ALV Grid Contents</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/09/alv-grid-the-oops-way/' rel='bookmark' title='ABAP Program for ALV Grid, the OOPS way'>ABAP Program for ALV Grid, the OOPS way</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2009/07/17/creating-an-alv-grid-in-3-lines/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Add custom button onto ALV Grid in SAP</title>
		<link>http://www.abap-tutorials.com/2009/07/11/add-custom-button-onto-alv-grid/</link>
		<comments>http://www.abap-tutorials.com/2009/07/11/add-custom-button-onto-alv-grid/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 01:37:08 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[ALV]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ALV grid]]></category>
		<category><![CDATA[custom button]]></category>
		<category><![CDATA[SAP]]></category>

		<guid isPermaLink="false">http://naveenvishal.wordpress.com/?p=90</guid>
		<description><![CDATA[As an ABAPer, you must have thought of adding your custom button to the standard ALV Grid called in your custom program. Here are the steps for achieving this goal. TO achieve this you should copy the &#8216;STANDARD&#8217; GUI status from program SAPLKKBL using transaction SE90 &#8211;&#62;Programming SubObjects&#8211;&#62; Gui Status. Steps: 1). Using SE80/SE41 you can copy [...]]]></description>
			<content:encoded><![CDATA[<p>As an ABAPer, you must have thought of adding your custom button to the standard ALV Grid called in your custom program. Here are the steps for achieving this goal.</p>
<p><img class="aligncenter size-medium wp-image-91" title="Custom button on ALV" src="http://naveenvishal.files.wordpress.com/2009/07/custom_button.jpg?w=300" alt="Custom button on ALV" width="476" height="63" /></p>
<p><span id="more-90"></span></p>
<p>TO achieve this you should copy the &#8216;STANDARD&#8217; GUI status from program SAPLKKBL using transaction SE90 &#8211;&gt;Programming SubObjects&#8211;&gt; Gui Status.</p>
<p>Steps:</p>
<p>1). Using SE80/SE41 you can copy a GUI status from one program to another. It mentions which one in the FM&#8217;s help.<br />
2). Create a form named like so:</p>
<p>Code:<br />
<span style="color:#3366ff;">*****************************************************************<br />
* Form Set_pf_status<br />
* Notes: Called by FM REUSE_ALV_GRID_DISPLAY<br />
*****************************************************************<br />
</span>FORM set_pf_status USING rt_extab TYPE slis_t_extab.<br />
  SET PF-STATUS &#8216;ZSTANDARD&#8217;.<br />
ENDFORM. &#8220;Set_pf_status<br />
 </p>
<p>In the above case the GUI status copied was named ZSTANDARD and adjusted accordingly, adding and removing the desired buttons. A button was added called &#8216;%DELETE&#8217;.</p>
<p>3). Create the following report:<br />
Code:<br />
<span style="color:#3366ff;">*****************************************************************<br />
* Form User_command<br />
* Notes: Called by FM REUSE_ALV_GRID_DISPLAY<br />
*        Detects whether the icon/button for<br />
*        &#8216;Return Tag Deletion&#8217; has been pressed. If it has then<br />
*        detect whether any rows have been highlighted and then<br />
*        set the delete flag.<br />
***************************************************************** </span><br />
FORM user_command USING r_ucomm     LIKE sy-ucomm<br />
                        rs_selfield TYPE slis_selfield.<br />
DATA: li_count TYPE I.<br />
IF r_ucomm EQ &#8216;%DELETE&#8217;.<br />
  LOOP AT %g00 WHERE mark EQ &#8216;X&#8217;.<br />
    ADD 1 TO li_count.<br />
  ENDLOOP.<br />
  IF li_count GT 0.<br />
    gc_delete_flag = &#8216;X&#8217;.<br />
    r_ucomm = &#8216;&amp;F03&#8242;. <span style="color:#3366ff;">&#8220;Back arraow<br />
</span>  ELSE.<br />
    MESSAGE W000 WITH &#8216;Please highlight the rows to be deleted!&#8217;.<br />
  ENDIF.<br />
ENDIF.<br />
ENDFORM.  <span style="color:#3366ff;">&#8220;User_command</span></p>
<p><span style="color:#3366ff;"><span style="color:#000000;">As I&#8217;ve added an extra button</span> </span>to indicate which records should be deleted I need to identify a form to be called to process when this button is chosen.</p>
<p>Then when you call the ALV function you to specify the following extra details:</p>
<p>Code:<br />
    call function &#8216;REUSE_ALV_GRID_DISPLAY&#8217;<br />
         exporting  i_callback_program = gc_repid<br />
                    I_CALLBACK_PF_STATUS_SET = &#8216;SET_PF_STATUS&#8217;<br />
                    I_CALLBACK_USER_COMMAND  = &#8216;USER_COMMAND&#8217;<br />
                    i_grid_title       = lc_grid_title<br />
                    is_layout          = lc_layout<br />
                    it_fieldcat        = gt_fieldcat<br />
                    it_sort            = sort<br />
                    i_save             = l_save<br />
                    is_reprep_id       = l_bbs_id<br />
                    is_variant         = l_variant<br />
         tables     t_outtab           = %g00<br />
         exceptions program_error      = 1<br />
                    others             = 2.</p>
<p>The parameters in capitals are the extra ones that need to be added.</p>
<p>That should be it!</p>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/09/17/abap-program-to-add-colors-in-alv-grid/' rel='bookmark' title='ABAP Program to add Colors in ALV Grid'>ABAP Program to add Colors in ALV Grid</a></li>
<li><a href='http://www.abap-tutorials.com/2009/09/10/displaying-icons-in-alv-abap/' rel='bookmark' title='Displaying Icons in ALV Grid using ABAP'>Displaying Icons in ALV Grid using ABAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/09/alv-grid-the-oops-way/' rel='bookmark' title='ABAP Program for ALV Grid, the OOPS way'>ABAP Program for ALV Grid, the OOPS way</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2009/07/11/add-custom-button-onto-alv-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

