04-09-2008 5:35 AM
Hi all,
I have requirement like,
1. need to upload the file into Ztable ,if there is any error in updating into the table
it should display the record with red color in the GRID and with error text in GRID.
How to display the records which are in error with colors and how to get the error text why it is actually not update in table .
Regards,
Madhavi
04-09-2008 5:43 AM
The SAP sample program BCALV_GRID_04 will show you how to use "traffic lights" to highlight the status of a row in the grid, and the program BCALV_GRID_VERIFY has parameters for "Colors" which shows how you can shade a row, column, or cell.
Jonathan
04-09-2008 7:06 AM
Madhavi,
1.How are you going to update Ztable based on that you have to get error messages.
2. To get records colored, Just check the sample program.
Check the program and check the comments inside the program. You can come to know what to do to get the rows colored.
I hope that it helps u .
Regards,
Venkat.O
REPORT zvenkat_alv_color_row_col.
*&---------------------------------------------------------------------*
" Declaration
" To get color for row
" 1.Define color variable with length 3 type char in the final internal
" which is displayed
" 2.build layout structure type slis_layout_alv by specifying
" info_fieldname = 'COLOR' and pass layout structure thru FM REUSE*ALV*
" 3.Poplate Final internal with color values for the field COLOR.
*----------------------------------------------------------------------*
"types
TYPES:
BEGIN OF t_pa0001,
color(3) TYPE c, "1.Declare this
pernr TYPE pa0001-pernr,
ename TYPE pa0001-ename,
END OF t_pa0001.
"Work area
DATA:
w_pa0001 TYPE t_pa0001.
"Internal tables
DATA:
i_pa0001 TYPE STANDARD TABLE OF t_pa0001.
*&---------------------------------------------------------------------*
* ALV Declarations
*----------------------------------------------------------------------*
* Types Pools
TYPE-POOLS:
slis.
* Types
TYPES:
t_fieldcat TYPE slis_fieldcat_alv,
t_events TYPE slis_alv_event,
t_layout TYPE slis_layout_alv.
* Workareas
DATA:
w_fieldcat TYPE t_fieldcat,
w_events TYPE t_events,
w_layout TYPE t_layout.
* Internal Tables
DATA:
i_fieldcat TYPE STANDARD TABLE OF t_fieldcat,
i_events TYPE STANDARD TABLE OF t_events.
*&---------------------------------------------------------------------*
*&START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION .
PERFORM get_data.
PERFORM color_the_row. "Populate Color like this based on ur conditions
*&---------------------------------------------------------------------*
*&END-OF-SELECTION
*&---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM fieldcat.
PERFORM layout_build.
PERFORM dispaly .
*&---------------------------------------------------------------------*
" Form fieldcat
"emphasize ===== Set this to highlight column in color
" Value range: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)
" 'X' = The column is highlighted in the default color for color highlighting.
" 'Cxyz' = The column is highlighted in the coded color:
" C: Color (coding must start with C)
" x: Color number
" y: Intensified
" z: Inverse
*&---------------------------------------------------------------------*
FORM fieldcat .
CLEAR :
w_fieldcat,i_fieldcat[].
w_fieldcat-fieldname = 'PERNR'.
w_fieldcat-tabname = 'I_PA0001'.
w_fieldcat-emphasize = 'C71'.
w_fieldcat-seltext_m = 'Employee No'.
w_fieldcat-no_zero = 'PERNR'.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
w_fieldcat-fieldname = 'ENAME'.
w_fieldcat-tabname = 'I_PA0001'.
w_fieldcat-seltext_m = 'ENAME'.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " fieldcat
*&---------------------------------------------------------------------*
*& Form dispaly
*&---------------------------------------------------------------------*
FORM dispaly .
DATA :l_program TYPE sy-repid.
l_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_program
* i_callback_top_of_page = 'TOP_OF_PAGE'
i_callback_html_top_of_page = 'TOP_OF_PAGE'
* IT_EXCLUDING = i_extab
is_layout = w_layout
it_events = i_events
it_fieldcat = i_fieldcat
TABLES
t_outtab = i_pa0001.
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. " dispaly
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
FORM get_data .
DO 20 TIMES.
SELECT pernr ename
FROM pa0001
APPENDING CORRESPONDING FIELDS OF TABLE i_pa0001
UP TO 10 ROWS.
ENDDO.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form layout_build
*&---------------------------------------------------------------------*
FORM layout_build .
w_layout-info_fieldname = 'COLOR'. "Pass COLOR field name like this.
ENDFORM. " layout_build
*&---------------------------------------------------------------------*
*& Form color_the_row
*&---------------------------------------------------------------------*
FORM color_the_row .
LOOP AT i_pa0001 INTO w_pa0001.
IF sy-tabix > 3.
w_pa0001-color = 'C31'.
MODIFY i_pa0001 FROM w_pa0001 INDEX sy-tabix.
ENDIF.
ENDLOOP.
ENDFORM. " color_the_row
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
FORM top_of_page USING document TYPE REF TO cl_dd_document.
DATA:
l_text TYPE sdydo_text_element.
l_text = 'xyz'.
CALL METHOD document->add_text
EXPORTING
text = l_text
sap_emphasis = cl_dd_document=>strong
sap_style = cl_dd_document=>key.
CALL METHOD document->new_line.
l_text = 'lmn'.
CALL METHOD document->add_text
EXPORTING
text = l_text
sap_fontsize = cl_dd_document=>medium
sap_color = cl_dd_document=>list_positive
sap_style = cl_dd_document=>key.
CALL METHOD document->underline.
ENDFORM. "top_of_page
08-03-2011 1:19 PM