‎2007 Jul 09 6:02 AM
hi,
in alv interactive report ,i display vendor masterdetails LIFNR ,NAME1,ORT01 fields in basic list.now i want display the LIFNR field only in any one of the color ex red,greeen,blue,....how it is possible pls send related code.
‎2007 Jul 09 6:06 AM
hi,
this might healp you out
FCAT-COL_POS = '4'.
FCAT-FIELDNAME = 'ERNAM'.
FCAT-TABNAME = 'IT_VBAK'.
FCAT-OUTPUTLEN = '20'.
FCAT-SELTEXT_L = 'NAME OF ENTRY'.
FCAT-EMPHASIZE = 'C610'.
APPEND FCAT.
CLEAR FCAT.
LAYOUT2-info_fieldname = 'ANY'.
LOOP AT IT_MARA.
IF IT_MARA-MATNR < 1050 .
IT_MARA-ANY = 'C510'.
MODIFY IT_MARA.
CLEAR IT_MARA.
ENDIF.
‎2007 Jul 09 6:07 AM
Hi
See this and do accordingly
1. add one more field to ur final internal table say COLOR(4)
2. in layout wa_layout-style_fname = 'COLOR'. " if its grid
wa_layout-style_fieldname = 'COLOR'. "if its list
3. read table itab index 3.
itab-color = 'C410'.
modify itab index 3
4. see program SHOWCOLO for all color codes
1. Add a field of data type CHAR(3) to the internal output table.
2. Enter the color code in the appropriate field of the row to be colored in the internal
output table:
Code: 'Cxy'
C = Color (all codes begin with 'C')
x = color number ('1' - '9')
y = highlight ('0' = off, '1' = on)
3. Assign the internal output table color code field name to the IS_LAYOUT importing
structure IS_LAYOUT-INFO_FIELDNAME field and pass this structure in the ALV call
interface.
To enable row coloring, you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row. So, lets modify declaration of our list data table gt_list.
you should fill the color code to this field. Its format will be the same as explained before at section C.6.3. But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field INFO_FNAME of the layout structure.
e.g.
ps_layout-info_fname = <field_name_containing_color_codes>. e.g. ROWCOLOR
You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.
You can color an entire row as described in the next section. However, this method is less time consuming.
Coloring Individual Cells
This is the last point about coloring procedures for the ALV Grid. The procedure is similar to coloring an entire row. However, since an individual cell can be addressed with two parameters we will need something more. What is meant by more is a table type structure to be included into the structure of the list data table. It seems strange, because including it will make our list data structure deep. But anyhow ALV Grid control handles this.
The structure that should be included must be of type LVC_T_SCOL. If you want to color the entire row, this inner table should contain only one row with field fname is set to space, some color value at field col, 0 or 1 at fields int (intensified) and inv (inverse).
If you want to color individual cells, then for each cell column, append a line to this inner table which also contains the column name at field fname. It is obvious that you can color an entire column by filling this inner table with a row for that column for each row in the list data table.
<b>
Reward points for useful Answers</b>
Regards
Anji
‎2007 Jul 09 6:09 AM
hi,
REPORT zmm_rept_po_in_alv_cg01 NO STANDARD PAGE HEADING
MESSAGE-ID zmsg_cg LINE-COUNT 36(3).
*-----Type-Pools Declaration
TYPE-POOLS : slis.
*-----Tables Declaration
TABLES : ekko.
*-----Structure Declaration
TYPES : BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln, "PO Number
bukrs TYPE ekko-bukrs, "Company Code
bsart TYPE ekko-bsart, "Puchasing Document Type
spras TYPE ekko-spras, "Language Key
zterm TYPE ekko-zterm, "Terms of Payment Key
END OF ty_ekko,
BEGIN OF ty_ebeln,
ebeln TYPE ekko-ebeln, "PO Number
END OF ty_ebeln,
BEGIN OF ty_ekpo,
ebeln TYPE ekpo-ebeln, "Purchase Document
ebelp TYPE ekpo-ebelp, "Purchase Document item
werks TYPE ekpo-werks, "Plant
matnr TYPE ekpo-matnr, "Material Number
matkl TYPE ekpo-matkl, "Material group
END OF ty_ekpo.
----
DATA DEFINITION
----
*-----Internal Tables Declaration
DATA : it_ekko TYPE TABLE OF ty_ekko,
it_ekko1 TYPE TABLE OF ty_ekko,
it_ekpo TYPE TABLE OF ty_ekpo,
it_ebeln TYPE TABLE OF ty_ebeln,
it_fieldcat_ekko TYPE slis_t_fieldcat_alv,
it_fieldcat_ekpo TYPE slis_t_fieldcat_alv,
it_slis_layout TYPE slis_layout_alv,
it_header TYPE slis_t_listheader,
it_print TYPE slis_print_alv,
*-----Work Area Declaration
x_ekko TYPE ty_ekko,
x_fieldcat_ekko TYPE slis_fieldcat_alv,
x_fieldcat_ekpo TYPE slis_fieldcat_alv,
x_header TYPE slis_listheader,
*-----Variable Declaration
v_repid TYPE sy-repid,
v_lines(10) TYPE c.
*-----Selection Screen Design
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS s_ebeln FOR ekko-ebeln.
PARAMETER p_pos TYPE i.
SELECTION-SCREEN END OF BLOCK b1.
----
AT SELECTION-SCREEN
----
AT SELECTION-SCREEN.
*-----Validating the selection screen
SELECT ebeln
FROM ekko
INTO TABLE it_ebeln
WHERE ebeln IN s_ebeln. "#EC *
IF sy-subrc <> 0.
MESSAGE e012(zmsg_cg). "No records For this Selection
ENDIF.
*-----Checking if Number of PO field is empty
IF p_pos IS INITIAL.
p_pos = sy-dbcnt.
ELSEIF p_pos > sy-dbcnt .
MESSAGE w003 WITH sy-dbcnt. "Existing Records are & &
ENDIF.
----
INITIALIZATION
----
INITIALIZATION.
v_repid = sy-repid.
----
START-OF-SELECTION.
----
START-OF-SELECTION.
*-----Building Fieldcatalog
PERFORM builtcat_ekko.
*-----Layout for the Basic List
PERFORM layout_ekko.
*-----Retreive the Records
PERFORM get_data_ekko.
*-----Displaying the Result
PERFORM alv_display_ekko.
--
FORM get_data_ekko.
*-----Retreive the Records
SELECT ebeln bukrs bsart spras zterm
FROM ekko
INTO TABLE it_ekko
WHERE ebeln IN s_ebeln.
*-----Retreive the Records Corresponding to Selection made
DO p_pos TIMES.
READ TABLE it_ekko INTO x_ekko INDEX sy-index.
APPEND x_ekko TO it_ekko1.
ENDDO.
ENDFORM. "get_data_ekko
--
FORM builtcat_ekko.
CLEAR : x_fieldcat_ekko, it_fieldcat_ekko.
x_fieldcat_ekko-col_pos = '1'.
x_fieldcat_ekko-fieldname = 'EBELN'.
x_fieldcat_ekko-seltext_l = 'PURCHASE DOCUMENT'.
x_fieldcat_ekko-tabname = 'IT_EKKO1'.
x_fieldcat_ekko-outputlen = 22.
x_fieldcat_ekko-emphasize = 'C400'.
APPEND x_fieldcat_ekko TO it_fieldcat_ekko.
CLEAR x_fieldcat_ekko.
x_fieldcat_ekko-col_pos = '2'.
x_fieldcat_ekko-fieldname = 'BUKRS'.
x_fieldcat_ekko-seltext_l = 'COMPANY CODE'.
x_fieldcat_ekko-tabname = 'IT_EKKO1'.
x_fieldcat_ekko-outputlen = 20.
x_fieldcat_ekko-emphasize = 'C300'.
APPEND x_fieldcat_ekko TO it_fieldcat_ekko.
CLEAR x_fieldcat_ekko.
x_fieldcat_ekko-col_pos ='3'.
x_fieldcat_ekko-fieldname = 'BSART'.
x_fieldcat_ekko-seltext_l = 'PURCHASING DOCUMENT TYPE'.
x_fieldcat_ekko-tabname = 'IT_EKKO1'.
x_fieldcat_ekko-outputlen = 30.
x_fieldcat_ekko-emphasize = 'C600'.
APPEND x_fieldcat_ekko TO it_fieldcat_ekko.
CLEAR x_fieldcat_ekko.
x_fieldcat_ekko-col_pos ='4'.
x_fieldcat_ekko-fieldname = 'SPRAS'.
x_fieldcat_ekko-seltext_l = 'LANGUAGE KEY'.
x_fieldcat_ekko-tabname = 'IT_EKKO1'.
x_fieldcat_ekko-outputlen = 25.
x_fieldcat_ekko-emphasize = ''.
APPEND x_fieldcat_ekko TO it_fieldcat_ekko.
CLEAR x_fieldcat_ekko.
x_fieldcat_ekko-col_pos = '5'.
x_fieldcat_ekko-fieldname = 'ZTERM'.
x_fieldcat_ekko-seltext_l = 'TERMS OF PAYMENT KEY'.
x_fieldcat_ekko-tabname = 'IT_EKKO1'.
x_fieldcat_ekko-outputlen = 30.
x_fieldcat_ekko-emphasize = 'C700'.
APPEND x_fieldcat_ekko TO it_fieldcat_ekko.
CLEAR x_fieldcat_ekko.
ENDFORM. "builtcat_ekko
--
FORM layout_ekko.
it_slis_layout-zebra = 'X'.
ENDFORM. "layout
----
Form print
----
FORM print.
it_print-print(1) = 'X'.
ENDFORM. "print
--
FORM alv_display_ekko.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_pf_status_set = 'STATUS'
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = it_slis_layout
it_fieldcat = it_fieldcat_ekko
is_print = it_print
TABLES
t_outtab = it_ekko1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "alv_ekko_display
--
FORM top-of-page. "#EC CALLED
*----Title
x_header-typ = 'H'.
x_header-info = text-101.
APPEND x_header TO it_header.
CLEAR: x_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header
i_logo = 'ENJOYSAP_LOGO'.
CLEAR it_header[].
ENDFORM. "top-of-page
--
FORM user_command USING v_ucomm LIKE sy-ucomm
v_selfield TYPE slis_selfield. "#EC CALLED
*-----User Action
CASE v_ucomm.
*-----On Double Click
WHEN '&IC1'.
READ TABLE it_ekko INTO x_ekko INDEX v_selfield-tabindex.
IF sy-subrc = 0.
*-----Retreiving Item Details corresponding to PO Selected
SELECT ebeln ebelp werks matnr matkl
FROM ekpo
INTO TABLE it_ekpo
WHERE ebeln = x_ekko-ebeln.
IF sy-subrc <> 0.
MESSAGE e010(zmsg_cg). "NO Item Details For Selected Sales Order No.
ENDIF.
PERFORM builtcat_ekpo.
PERFORM alv_display_ekpo.
CLEAR : x_ekko,v_selfield.
ENDIF.
ENDCASE.
ENDFORM. "user_command
--
FORM builtcat_ekpo.
CLEAR : x_fieldcat_ekpo, it_fieldcat_ekpo.
x_fieldcat_ekpo-col_pos = '1'.
x_fieldcat_ekpo-fieldname = 'EBELN'.
x_fieldcat_ekpo-seltext_l = 'PURCHASE DOCUMENT'.
x_fieldcat_ekpo-tabname = 'IT_ekpo'.
x_fieldcat_ekpo-outputlen = 25.
x_fieldcat_ekpo-emphasize = 'C300'.
APPEND x_fieldcat_ekpo TO it_fieldcat_ekpo.
CLEAR x_fieldcat_ekpo.
x_fieldcat_ekpo-col_pos = '2'.
x_fieldcat_ekpo-fieldname = 'EBELP'.
x_fieldcat_ekpo-seltext_l = 'PURCHASE DOCUMENT ITEM'.
x_fieldcat_ekpo-tabname = 'IT_ekpo'.
x_fieldcat_ekpo-outputlen = 35.
x_fieldcat_ekpo-emphasize = 'C301'.
APPEND x_fieldcat_ekpo TO it_fieldcat_ekpo.
CLEAR x_fieldcat_ekpo.
x_fieldcat_ekpo-col_pos ='3'.
x_fieldcat_ekpo-fieldname = 'WERKS'.
x_fieldcat_ekpo-seltext_l = 'PLANT'.
x_fieldcat_ekpo-tabname = 'IT_ekpo'.
x_fieldcat_ekpo-outputlen = 20.
x_fieldcat_ekpo-emphasize = 'C202'.
APPEND x_fieldcat_ekpo TO it_fieldcat_ekpo.
CLEAR x_fieldcat_ekpo.
x_fieldcat_ekpo-col_pos ='4'.
x_fieldcat_ekpo-fieldname = 'MATNR'.
x_fieldcat_ekpo-seltext_l = 'MATERIAL NUMBER'.
x_fieldcat_ekpo-tabname = 'IT_ekpo'.
x_fieldcat_ekpo-outputlen = 30.
x_fieldcat_ekpo-emphasize = 'C403'.
APPEND x_fieldcat_ekpo TO it_fieldcat_ekpo.
CLEAR x_fieldcat_ekpo.
x_fieldcat_ekpo-col_pos ='5'.
x_fieldcat_ekpo-fieldname = 'MATKL'.
x_fieldcat_ekpo-seltext_l = 'MATERIAL GROUP'.
x_fieldcat_ekpo-tabname = 'IT_ekpo'.
x_fieldcat_ekpo-outputlen = 25.
x_fieldcat_ekpo-emphasize = 'C504'.
APPEND x_fieldcat_ekpo TO it_fieldcat_ekpo.
CLEAR x_fieldcat_ekpo.
ENDFORM. "builtcat_ekpo
--
FORM alv_display_ekpo.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP-OF-PAGE1'
is_layout = it_slis_layout
it_fieldcat = it_fieldcat_ekpo
TABLES
t_outtab = it_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "ekpo_ALV_DISPLAY
--
FORM status USING v_extab TYPE slis_t_extab. "#EC CALLED
SET PF-STATUS 'AAAA' EXCLUDING v_extab.
ENDFORM. "STATUS
--
FORM top-of-page1. "#EC CALLED
*----Title
x_header-typ = 'H'.
x_header-info = text-102.
APPEND x_header TO it_header.
CLEAR: x_header.
*----Total No. of Records Selected
DESCRIBE TABLE it_ekpo LINES v_lines.
x_header-typ = 'S'.
CONCATENATE text-103 v_lines INTO x_header-info.
APPEND x_header TO it_header.
CLEAR: x_header.
*----Function to Display Title
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header
i_logo = 'ENJOYSAP_LOGO'.
CLEAR it_header.
ENDFORM. "top-of-page
&----
*& Module USER_COMMAND_9000 INPUT
&----
module USER_COMMAND_9000 input.
CALL SCREEN 9000.
IF sy-ucomm = 'PRINT'.
PERFORM print.
ENDIF.
endmodule.
‎2007 Jul 09 6:10 AM
Hi Kln ,
From what i understand from your post is thet you want to assign a color to the feild LIFNR ,, in the alv.
If you want to assign a single color to all the rows then you can use the EMPHASIZE field in the field catalog.
Regards
Arun
‎2007 Jul 09 6:13 AM
HI,
1. declare one field say color in the output table of type
SLIS_T_SPECIALCOL_ALV.
2. Also declare a table color like
DATA COLOR TYPE SLIS_T_SPECIALCOL_ALV WITH HEADER LINE.
3. After you have filled the field catalog do like this,
LOOP AT IT_ALV_DATA.
IF SY-TABIX = 2.
COLOR-FIELDNAME = 'POSNR'.
COLOR-COLOR-COL = 6.
COLOR-COLOR-INT = 0.
APPEND COLOR.
IT_ALV_DATA-COLOR = COLOR[].
MODIFY IT_ALV_DATA.
ENDIF.
ENDLOOP.
please click the link below
<a href="http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm">http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm</a>
rewards if useful,
regards,
nazee