Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV styles

Former Member
0 Likes
6,183

can some one tell about the styles used in ALV ? Any samples?

Thanks and Regards

Chalam

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,094

To include different ALV styles for fieldcatalogue, we use

*Include for ALV styles

INCLUDE <cl_alv_control>.

and declare a fieldcatalogue:

data it_fcat TYPE lvc_t_fcat.

*Field symbols declarations for style

FIELD-SYMBOLS : <wa_fcat> TYPE lvc_s_fcat.

  • Setting the styles for the ALV grid control

  • using field-symbols

LOOP AT it_fcat ASSIGNING <wa_fcat>.

*For Each and every line of the fieldcat

CASE sy-tabix.

*Color Styles

*Background/Font/Group/positive/negative

WHEN '1'.

<wa_fcat>-style = alv_style_color_inv_positive.

WHEN '2'.

<wa_fcat>-style = alv_style_color_int_negative.

WHEN '3'.

<wa_fcat>-style = alv_style_color_inv_negative.

WHEN '4'.

<wa_fcat>-style = alv_style_color_int_positive.

WHEN '5'.

<wa_fcat>-style = alv_style_color_background.

<wa_fcat>-style = alv_style_color_inv_background.

WHEN '6'.

<wa_fcat>-style = alv_style_color_group.

<wa_fcat>-style = alv_style_color_int_background.

*Style for F4

WHEN '7'.

<wa_fcat>-style = alv_style_f4.

*Style for Alignment(others are also possible)

WHEN '8'.

<wa_fcat>-style = alv_style_align_left_bottom.

*Style for Font Underlined/Bold and Italic are possible

WHEN '9'.

<wa_fcat>-style = alv_style_font_underlined.

*Style for button type

WHEN '10'.

<wa_fcat>-style = alv_style_button.

*Style for Font Symbol

WHEN '11'.

<wa_fcat>-style = alv_style_font_symbol.

*Style for Radiobutton

WHEN '12'.

<wa_fcat>-style = alv_style_radio_checked.

*Style for checkbox

WHEN '13'.

<wa_fcat>-style = alv_style_checkbox_checked.

*Style for column style characteristics(highlighting the col)

WHEN '14'.

<wa_fcat>-style = alv_col_style_characteristic.

*Styles for Enabling the column

WHEN '15'.

<wa_fcat>-style = alv_style_enabled.

ENDCASE.

ENDLOOP.

The 1 , 2,3 till 15 refers to the 15 fields(columns in ALV) in the fieldcatalogue.

Refer

http://www.saptechnical.com/Tutorials/ALV/Styles/demo.htm

for complete code.

Thanks

Swarna

3 REPLIES 3
Read only

Former Member
0 Likes
3,094

I found this site helpful when I was first doing styles for ALV OO

http://www.abap4.it/download/ALV.pdf

This is an example of the definition


DATA: BEGIN OF gt_outtab OCCURS 0.
        INCLUDE STRUCTURE zscemp_wk.
DATA: cellstyles    TYPE lvc_t_styl.
DATA: END OF gt_outtab.

And this, the code using one


*&---------------------------------------------------------------------*
*&      Form  adjust_editables
*&---------------------------------------------------------------------*
FORM adjust_editables USING    pt_list LIKE gt_outtab[].
  DATA: ls_listrow  LIKE LINE OF pt_list.
  DATA: ls_stylerow TYPE lvc_s_styl.
  DATA: ls_styletab TYPE lvc_t_styl.

  LOOP AT pt_list INTO ls_listrow.
    REFRESH ls_listrow-cellstyles.
    REFRESH ls_styletab.

    IF edit_mode EQ 'D'.
      ls_stylerow-fieldname = 'BRANCH'.
      ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
      APPEND ls_stylerow TO ls_styletab.
    ENDIF.

    ls_stylerow-fieldname = 'EMPNO'.
    IF  ls_listrow-empno IS INITIAL
    AND edit_mode EQ 'E'.
      ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.
    ELSE.
      ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
    ENDIF.
    APPEND ls_stylerow TO ls_styletab.

    INSERT LINES OF ls_styletab INTO TABLE ls_listrow-cellstyles.

    MODIFY pt_list FROM ls_listrow.
  ENDLOOP.

ENDFORM.                    " adjust_editables

Edited by: Paul Chapman on May 6, 2008 8:39 AM

Read only

Former Member
0 Likes
3,095

To include different ALV styles for fieldcatalogue, we use

*Include for ALV styles

INCLUDE <cl_alv_control>.

and declare a fieldcatalogue:

data it_fcat TYPE lvc_t_fcat.

*Field symbols declarations for style

FIELD-SYMBOLS : <wa_fcat> TYPE lvc_s_fcat.

  • Setting the styles for the ALV grid control

  • using field-symbols

LOOP AT it_fcat ASSIGNING <wa_fcat>.

*For Each and every line of the fieldcat

CASE sy-tabix.

*Color Styles

*Background/Font/Group/positive/negative

WHEN '1'.

<wa_fcat>-style = alv_style_color_inv_positive.

WHEN '2'.

<wa_fcat>-style = alv_style_color_int_negative.

WHEN '3'.

<wa_fcat>-style = alv_style_color_inv_negative.

WHEN '4'.

<wa_fcat>-style = alv_style_color_int_positive.

WHEN '5'.

<wa_fcat>-style = alv_style_color_background.

<wa_fcat>-style = alv_style_color_inv_background.

WHEN '6'.

<wa_fcat>-style = alv_style_color_group.

<wa_fcat>-style = alv_style_color_int_background.

*Style for F4

WHEN '7'.

<wa_fcat>-style = alv_style_f4.

*Style for Alignment(others are also possible)

WHEN '8'.

<wa_fcat>-style = alv_style_align_left_bottom.

*Style for Font Underlined/Bold and Italic are possible

WHEN '9'.

<wa_fcat>-style = alv_style_font_underlined.

*Style for button type

WHEN '10'.

<wa_fcat>-style = alv_style_button.

*Style for Font Symbol

WHEN '11'.

<wa_fcat>-style = alv_style_font_symbol.

*Style for Radiobutton

WHEN '12'.

<wa_fcat>-style = alv_style_radio_checked.

*Style for checkbox

WHEN '13'.

<wa_fcat>-style = alv_style_checkbox_checked.

*Style for column style characteristics(highlighting the col)

WHEN '14'.

<wa_fcat>-style = alv_col_style_characteristic.

*Styles for Enabling the column

WHEN '15'.

<wa_fcat>-style = alv_style_enabled.

ENDCASE.

ENDLOOP.

The 1 , 2,3 till 15 refers to the 15 fields(columns in ALV) in the fieldcatalogue.

Refer

http://www.saptechnical.com/Tutorials/ALV/Styles/demo.htm

for complete code.

Thanks

Swarna

Read only

Former Member
0 Likes
3,094

Hi,

pls see the below link

https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=stylesusedinALV&adv=false&sortby=cm_rnd_rankvalue

http://abapprogramming.blogspot.com/2007/11/alv-list-using-oo-style-sample-code.html

thanks

abdul

reward me if usefull

Edited by: shaik abdul on May 6, 2008 2:41 PM