2009 Mar 25 3:25 AM
hi experts,
as per the rules i have checked lot of post but there is no relavent post for my query or problem.
my doubt is i want to have a specific clour for a column in dynamic alv.
so how do i do it????
reply asap.
with regrads,
janani.
hi experts,
as per the rules i have checked lot of post but there is no relavent post for my query or problem.
my doubt is i want to have a specific clour for a column in dynamic alv.
so how do i do it????
reply asap.
with regrads,
janani.
2009 Mar 25 3:32 AM
2009 Mar 25 3:39 AM
Hi,
While maintainig your field catalog,
you can use EMPHASIZE = Color Code
for the field catalog column you want to get displayed with specific color.
Emphasize (highlight columns in color): As name suggests, this field parameter is used to highlight certain field with chosen colors.
Value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off ,'1'=on).
'X' = column is colored with the default column highlight color.
'Cxyz' = column is colored with a coded color:
- C: Color (coding must begin with C)
- X: color number
- Y: bold
- Z: inverse
Regards
Mansi
2009 Mar 25 5:40 AM
thank you for your reply but it5 is not helpnig me...
i have a quantity to be dispalyed in last line of the report and i want to changes the colour of only that line....
but its says
'filed symbol not assigned'...
with regards
janani
2009 Mar 25 5:44 AM
2009 Mar 25 3:41 AM
Hi,
Refer wiki:
Individual cell coloring in dynamic alv
https://wiki.sdn.sap.com/wiki/display/ABAP/Individual%20cell%20coloring%20in%20dynamic%20alv
Refer wiki code to color in alv:
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/coloring%252ba%252brow%252band%252bc
Hope this helps you.
Regards,
Tarun
Edited by: Tarun Gambhir on Mar 25, 2009 9:14 AM
2009 Mar 25 6:19 AM
2009 Mar 25 6:19 AM
2009 Mar 25 6:52 AM
REPORT Z_ALV_COLOR.
* Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
TYPE-POOLS: slis. " ALV Global types
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '30' OBLIGATORY. "#EC *
SELECTION-SCREEN END OF LINE.
TYPES :
BEGIN OF ty_data,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
netwr TYPE vbak-netwr, " Net Value of the Sales Order
END OF ty_data,
* Data displayed
BEGIN OF ty_vbak,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
netwr TYPE vbak-netwr, " Net Value of the Sales Order
tabcolor TYPE lvc_t_scol, " Cell Color
END OF ty_vbak.
DATA:
gt_data TYPE TABLE OF ty_data,
* Data displayed
gt_vbak TYPE TABLE OF ty_vbak.
*---------------------------------------------------------------------*
INITIALIZATION.
v_1 = 'Maximum of records to read'. "#EC NOTEXT
*---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_fill_color.
PERFORM f_display_data.
*---------------------------------------------------------------------*
* Form f_read_data_vbak
*---------------------------------------------------------------------*
FORM f_read_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM vbak UP TO p_max ROWS.
ENDFORM. " F_READ_DATA
*--------------------------------------------------------------------*
* Form f_fill_color
*--------------------------------------------------------------------*
FORM f_fill_color.
DATA :
ls_data TYPE ty_data,
ls_vbak TYPE ty_vbak.
LOOP AT gt_data INTO ls_data.
CLEAR ls_vbak.
MOVE-CORRESPONDING ls_data TO ls_vbak.
PERFORM f_modify_color USING 'NETWR' CHANGING ls_vbak.
PERFORM f_modify_color USING 'VBELN' CHANGING ls_vbak.
* Fill gt_vbak
APPEND ls_vbak TO gt_vbak.
ENDLOOP.
ENDFORM. " F_FILL_COLOR
*---------------------------------------------------------------------*
* Form F_modify_color
*---------------------------------------------------------------------*
FORM f_modify_color USING u_fieldname TYPE lvc_fname
CHANGING us_vbak TYPE ty_vbak.
DATA :
l_rnd_value TYPE 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 us_vbak-tabcolor.
ENDFORM. " F_MODIFY_COLOR
*---------------------------------------------------------------------*
* Form f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.
DATA:
ls_layout TYPE slis_layout_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'VKORG' 'VBAK'.
m_fieldcat 'KUNNR' 'VBAK'.
m_fieldcat 'VBELN' 'VBAK'.
m_fieldcat 'NETWR' 'VBAK'.
* Fill Layout
ls_layout-coltab_fieldname = 'TABCOLOR'.
* Display the list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA