Coloring of a (specific) row in ALV report-How?
Hi Experts,
Am looking to assign a color for a (specific)row in ALV report.......so, pls. let me know How to get it done?
thanq
TABLES:LFA1.
SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.
DATA:BEGIN OF ITAB OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
LAND1 LIKE LFA1-LAND1,
ORT01 LIKE LFA1-ORT01,
REGIO LIKE LFA1-REGIO,
SORTL LIKE LFA1-SORTL,
CFIELD(4) TYPE C,
END OF ITAB.
data:col(4).
data:num value '1'.
SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR
IN LIFNR.
LOOP AT ITAB.
concatenate 'C' num '10' into col .
ITAB-CFIELD = col.
num = num + 1.
if num = '8'.
num = '1'.
endif.
MODIFY ITAB.
ENDLOOP.
TYPE-POOLS:SLIS.
DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.
LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
LAYOUT-WINDOW_TITLEBAR = 'VENDORS DETAILS SCREEN'.
LAYOUT-EDIT = 'X'.
LAYOUT-info_fieldname = 'CFIELD'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
this is for coloring cols
REPORT ZBHCOLOR_COLS.
TABLES:LFA1.
SELECT-OPTIONS:C_LIFNR FOR LFA1-LIFNR. " FOR GRID ONLY
PARAMETERS:LIST RADIOBUTTON GROUP ALV DEFAULT 'X',
GRID RADIOBUTTON GROUP ALV.
DATA:BEGIN OF ITAB OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
LAND1 LIKE LFA1-LAND1,
ORT01 LIKE LFA1-ORT01,
SORTL LIKE LFA1-SORTL,
REGIO LIKE LFA1-REGIO,
COL TYPE LVC_T_SCOL,
END OF ITAB.
DATA:COLR TYPE LVC_S_SCOL.
SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB.
LOOP AT ITAB.
IF ITAB-LIFNR IN C_LIFNR.
COLR-FNAME = 'NAME1'.
COLR-COLOR-COL = '5'.
COLR-COLOR-INT = '1'.
COLR-COLOR-INV = '0'.
COLR-NOKEYCOL = 'X'.
APPEND COLR TO ITAB-COL.
COLR-FNAME = 'LIFNR'.
APPEND COLR TO ITAB-COL.
MODIFY ITAB.
ENDIF.
ENDLOOP.
TYPE-POOLS:SLIS.
DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
LAYOUT-ZEBRA = 'X'.
layout-coltab_fieldname = 'COL'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = FCAT.
IF LIST = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
ELSEIF GRID = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
ENDIF.
Reward points if useful.
Similar Messages
-
How to select multiple row in ALV report
Hi friends,
1. How to select multiple row in ALV report
( How to set tab in ALV report and want to select multiple line.)
Thanking you.
SubashHi Sahoo,
If you are using the class CL_GUI_ALV_GRID. In methods SET_TABLE_FOR_FIRST_DISPLAY.
in layout structure you will find field SEL_MODE
pass :
LS_LAYOUT-SEL_MODE = 'A'.
In PAI.
CALL METHOD GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = T_ROWS
ET_ROW_NO = T_ROWID.
Hope these will solve your problem.
Regards,
Kumar M. -
Set specific rows in ALV grid ready for input
Hi everyone,
I have a question about how to set specific rows in ALV grid ready for input.
I know that I can make some columns ready for input before the ALV displayed,but I have no idea how to make specific rows displayed in the ALV ready for input.Hello Aaron
For editable columns we can use the fieldcatalog (LVC_S_FCAT-EDIT = 'X') but for rows you need to define editability on cell level.
The required steps are documented in sample report BCALV_EDIT_02. Below I point out a few crucial points:
*§1.Extend your output table for a field, e.g., CELLTAB, that holds
* information about the edit status of each cell for the
* corresponding row (the table type is SORTED!).
DATA: BEGIN OF gt_outtab occurs 0. "with header line
include structure sflight.
DATA: celltab type LVC_T_STYL.
DATA: END OF gt_outtab.
*§3.Provide the fieldname of the celltab field by using field
* STYLEFNAME of the layout structure.
gs_layout-stylefname = 'CELLTAB'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING it_outtab = gt_outtab[].
Note: in the sample report only field SEATSMAX is editable. In your case you need
to fill CELLTAB for all fields in a row.
*§2.After selecting data, set edit status for each row in a loop
* according to field SEATSMAX.
LOOP AT gt_outtab.
l_index = sy-tabix.
refresh lt_celltab.
if gt_outtab-seatsmax ge 300.
perform fill_celltab using 'RW'
changing lt_celltab.
else.
perform fill_celltab using 'RO'
changing lt_celltab.
endif.
*§2c.Copy your celltab to the celltab of the current row of gt_outtab.
INSERT LINES OF lt_celltab INTO TABLE gt_outtab-celltab.
MODIFY gt_outtab INDEX l_index.
ENDLOOP.
ENDFORM. " SELECT_DATA_AND_INIT_STYLE
NOTE: LVC_T_STYL is a SORTED table type. Thus, take care that you are using the
INSERT ... INTO TABLE statement and not APPEND (because then nothing is appended
to the CELLTAB itab).
IF p_mode EQ 'RW'.
*§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
* to status "editable".
l_mode = cl_gui_alv_grid=>mc_style_enabled.
ELSE. "p_mode eq 'RO'
*§2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
* to status "non-editable".
l_mode = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
ls_celltab-fieldname = 'SEATSMAX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
Regards
Uwe -
Hi experts...
I want single row in alv report.
I have use loop for fatch data into internal table using loop when i am passing data in alv report then the data comes according loop. i want onlu one data in alv row.
how can i do such, plz help me.decleare two internal table.
read table itab into wa index 1.
append wa to itab2.
pass itab2 only one record display. -
Control User Specific button in ALV report
Hi,
Can anybody please suggest me how to control "USER SPECIFIC" button in ALV report layout using authorization object. I mean if you can tell me which authorization object is responsible to control the "USER SPECIFIC" button.additional info to what Lakshmi already said:-
normally the restrictions for saving layouts/display variants are done at 2 levels:
1) The developer of an ALV list first predetermines the authorization in the 'i_save' parameter within the code.
I_SAVE = ' ' -
layouts cannot be saved
I_SAVE = 'A' -
user-specific and cross-user layouts can be saved
I_SAVE = 'X' --- cross-user layouts can be saved
I_SAVE = 'U' --- user-specific layouts can be saved
2) The second level comes to us restriciting the S_ALV_LAYO which gives access to users to save global layouts if I_SAVE for that particular transaction is A or X.
for example, a report has I_SAVE= 'A', which means
it will allow to save User-specific layouts without any restrictions.
and if user has S_ALV_LAYO then he can save both User-Specific and Global Layouts(variants).
it would be better to keep this object separate. -
Deleting rows in alv report.
Hi Experts,
I want to delete a row in alv report output, It is duplicating records in the report and 'GRAND TOTAL' also be displayed . In under the report . <<removed_by_moderator>>
Thanks,
Dinesh.B
Edited by: Vijay Babu Dudla on May 11, 2009 9:15 AMHi,
use the following code for deleting duplicate and adjacent records from itab
delete ADJACENT DUPLICATES FROM itab.
or
sort itab by pernr.
delete ADJACENT DUPLICATE FROM itab COMPARING pernr.
Also, for grand total you can use fieldcat-do_sum = 'X' with the field catalog. It will give you total for the required column.
Hope this solves your problem.
Regards,
Ibrar Munsif. -
To add/delete the rows in ALV report outpout
Hi,
Is there any way by which we can add/delete the rows in ALV report output.
Thanks
AnkulHi,
Try out this way:
data: i_modified TYPE STANDARD TABLE OF mara,"For getting modified rows
w_modified TYPE mara.
CASE e_ucomm.
WHEN 'EDIT'.
perform save_database.
CALL METHOD ref_GRID->REFRESH_TABLE_DISPLAY.
ENDCASE.
FORM SAVE_DATABASE .
data: i_selected_rows TYPE lvc_t_row, "Selected Rows
w_selected_rows TYPE lvc_s_row.
* Getting the selected rows index
CALL METHOD ref_grid->get_selected_rows
IMPORTING et_index_rows = i_selected_rows.
* Through the index capturing the values of selected rows
LOOP AT i_selected_rows INTO w_selected_rows.
READ TABLE it_tab INTO wa_it_tab INDEX w_selected_rows-index.
IF sy-subrc EQ 0.
MOVE-CORRESPONDING wa_it_tab TO w_modified.
APPEND w_modified TO i_modified.
ENDIF.
ENDLOOP.
MODIFY mara FROM TABLE i_modified.
Thanks,
Krishna -
How to apply List box for multiple selection of rows in ALV report ?
Hi Exprots,
1: How to apply List box for multiple selection of rows in ALV report ?
Thanking you.
Subashhi,
check the below program.
REPORT zalv_dropdowns.
*Type pools declarations for ALV
TYPE-POOLS : slis.
*data declarations for ALV container,ALV grid, Fieldcatalogues & layout
DATA: g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.*INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
wa_outtab TYPE t517a.
START-OF-SELECTION.*Call to ALV
CALL SCREEN 600.*On this statement double click it takes you to the screen painter SE51.
*Create a Custom container and name it CCONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.
PBO of the actual screen , Here we can give a title and customized menus
Here we also call the subroutine for ALV output.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
PERFORM alv_output.
ENDMODULE. "pbo OUTPUT
MODULE PAI INPUT *
MODULE pai INPUT.
ENDMODULE. "pai INPUT
*& Form BUILD_FIELDCAT
FORM build_fieldcat.
DATA ls_fcat TYPE lvc_s_fcat.
*Build the field catalogue
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'T517A'
CHANGING
ct_fieldcat = gt_fieldcat.
To assign dropdown in the fieldcataogue
LOOP AT gt_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'SLART'.
*is the first list box
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
is the second list box
WHEN 'ABART'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
ENDCASE.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form ALV_OUTPUT
FORM alv_output .*Create object for container
CREATE OBJECT g_custom_container
EXPORTING container_name = 'CCONT'.
*create object for grid
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
Build fieldcat and set column
*Assign a handle for the dropdown listbox.
PERFORM build_fieldcat.
*Build layout
PERFORM build_layout.
Define a drop down table.
PERFORM dropdown_table.
*fetch values from the T517A table
SELECT * FROM t517a INTO TABLE gt_outtab.
*Display ALV output
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab.ENDFORM. "ALV_OUTPUT
*& Form dropdown_table
text
--> p1 text
<-- p2 text
FORM dropdown_table.*Declarations for drop down lists in ALV.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
First SLART listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Primary school'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '1'.
ls_dropdown-value = '02 Lower Secondary'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '1'.
ls_dropdown-value = '03 Upper Secondary'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '04 Professional School'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '05 College'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '06 University'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '09 Other Establishment'.
APPEND ls_dropdown TO lt_dropdown.* Second ABART listbox (handle '2'). ls_dropdown-handle = '2'.
ls_dropdown-value = '10 Primary School certificate'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '20 Lower secondary/Junior high'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '30 High school diploma(B-levels)'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '31 Vocational'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '32 Matriculation'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '40 Specialist vocational certificate'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '50 College degree Level1'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '51 College degree Level2'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '52 Masters degree'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '60 Univ Degree level1'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '61 Bachelors degree'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '62 Masters degree'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '63 Licenciate'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '64 Doctors Degree Ph.D'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '89 None'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '90 Unknown'.
APPEND ls_dropdown TO lt_dropdown.*method to display the dropdown in ALV
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.ENDFORM. " dropdown_table
*& Form build_layout
text
*layout for ALV output
FORM build_layout . gs_layout-cwidth_opt = 'X'.
gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
gs_layout-no_toolbar = 'X'.ENDFORM. " build_layout
endform.
Edited by: S.r.v.r.Kumar on Jun 1, 2009 2:48 PM -
In alv report , how to reserve 20 lines from beginning of page
hi experts
in alv report , how to reserve 20 lines from beginning of page.
regards
subhasis.If by reserve you mean should not move on scrolling then make them KEY from fieldcatalog.
But I think maximum of 10-12 can be handled by that.
Regards,
Amit
Reward all helpful replies. -
Check boxes in ALV Report how to do ?
ALV report how to keep check box in the first field?
thanks in advance..
chalapathihi,
Check this small code.. U will get clear idea.
Report.
data : begin of it occurs 0,
MATNR TYPE MATNR,
c1 , " CHECK BOX FIELDS
c2,
end of it.
type-pools : slis.
data itlog type slis_t_fieldcat_alv.
data walog type slis_fieldcat_alv.
SELECT MATNR
FROM MARA
INTO TABLE IT .
****INSERTING CHECKBOX IN CHANGE MODE
WALOG-FIELDNAME = 'C1'.
WALOG-TABNAME = 'IT'.
WALOG-SELTEXT_M = 'CHECKBOX1'.
walog-CHECKBOX = 'X'.
WALOG-EDIT = 'X'.
APPEND WALOG TO ITLOG.
****INSERTING CHECKBOX IN DISPLAY MODE
WALOG-FIELDNAME = 'C2'.
WALOG-TABNAME = 'IT'.
WALOG-SELTEXT_M = 'CHECKBOX2'.
walog-CHECKBOX = 'X'.
WALOG-EDIT = ''.
APPEND WALOG TO ITLOG.
WALOG-FIELDNAME = 'MATNR'.
WALOG-TABNAME = 'IT'.
WALOG-SELTEXT_M = 'MATERIAL'.
walog-CHECKBOX = ''.
WALOG-EDIT = 'X'.
WALOG-NO_ZERO = 'X'. " LEFT ZEROS WILL CUT
APPEND WALOG TO ITLOG.
*WALOG-FIELDNAME = 'ICON'.
*WALOG-TABNAME = 'IT'.
*WALOG-SELTEXT_M = 'ICON'. "IN FIELDCATALOG ADDING THAT ICON
*walog-ICON = 'X'.
*walog-just = 'R'. " RIGHT JUSTIFICATION OR LEFT
**WALOG-EDIT = ''.
*APPEND WALOG TO ITLOG.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'ZALV_SIMPLE1'
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = ITLOG
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT
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.
Thanks and Regards,
surya -
In ALV reports how can we capture separate data in 3 internal table
HI
In ALV reports how can we capture data in 3 Internal tables and combine them in another internal table to display........Hello Sudhanshu
Another option would be to display all three itabs together which is a piece of cake using OO-based ALV lists. Please refer to thread
Re: Alv
for a sample report.
Regards
Uwe -
In ALV reports how double click event works?
in ALV reports how double click event works? Explain in detail.....
hi,
last lines is used for clicking
*& Report Z_SWAS_FUNCTIONAL
report z_swas_functional.
tables: qmel,viqmel,iloa,afko.
-- global data declerations--
data: ok_code like sy-ucomm,
gt_itab type table of zfunctional,
t_output type table of zfunctional,
g_container type scrfname value 'CUSTOM_CONTROL',
grid1 type ref to cl_gui_alv_grid,
g_custom_container type ref to cl_gui_custom_container,
e_row type lvc_s_row,
e_column type lvc_s_col,
es_row_no type lvc_s_roid.
*CLASS DECLARATION
class z_functional definition.
public section.
class-methods : handle_double_click
for event double_click of cl_gui_alv_grid
importing e_row e_column.
endclass.
*CLASS IMPLEMENTATION
class z_functional implementation.
method handle_double_click.
perform handle_double_click using e_row e_column es_row_no.
endmethod.
endclass.
*CODE FOR SELECTION SCREEN
selection-screen begin of block 84433 with frame title text-t01.
parameters : n_number like viqmel-qmnum,
n_type like qmel-qmart,
f_loca like iloa-tplnr,
name like qmel-qmnam.
selection-screen end of block 84433.
screen validation event *
at selection-screen on n_number.
select single *
from viqmel
where qmnum eq n_number.
if sy-subrc ne 0.
MESSAGE 'NOTIFICATION NUMBER DOESNOT EXIST' TYPE 'E'.
endif.
select qmart from qmel into qmel where qmart eq N_TYPE.
endselect.
if sy-subrc ne 0.
MESSAGE 'NOTIFICATION TYPE DOES NOT EXIST' TYPE 'E'.
endif.
*START OF SELECTION EVENT
start-of-selection.
perform fetchdata.
end-of-selection.
*Call screen event
call screen 100.
*PERFORM DISPLAY.
*& Form FETCHDATA
text
--> p1 text
<-- p2 text
form fetchdata .
*SELECT VIQMEL~QMNUM VIQMEL~QMTXT VIQMEL~QMDAT VIQMEL~LTRMN VIQMEL~PRIOK
VIQMELBEZDT VIQMELAUFNR VIQMELTPLNR AFKOGLTRP into corresponding fields of table GT_ITAB
FROM VIQMEL INNER JOIN AFKO ON VIQMELAUFNR = AFKOAUFNR
WHERE VIQMELQMNUM IN N_NUMBER and VIQMELQMART IN N_TYPE AND VIQMEL~QMNAM IN NAME.
call function 'ZSWAS_TEST'
exporting
qmnum = n_number
qmart = n_type
tplnr = f_loca
qmnam = name
tables
output = gt_itab
if sy-subrc ne 0.
message e000(z84433_msg_class).
endif.
endform. " FETCHDATA
*& Module STATUS_0100 OUTPUT
text
module status_0100 output.
set pf-status 'MAIN'.
SET TITLEBAR 'xxx'.
*creating custom container and grid instance
if g_custom_container is initial.
create object g_custom_container
exporting container_name = g_container.
create object grid1
exporting i_parent = g_custom_container.
call method grid1->set_table_for_first_display
exporting
i_structure_name = 'ZFUNCTIONAL'
changing
it_outtab = gt_itab.
*set handler events
set handler z_functional=>handle_double_click for grid1.
endif.
endmodule. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
module user_command_0100 input.
case ok_code.
when 'EXIT'.
perform exit_program.
endcase.
clear ok_code.
endmodule. " USER_COMMAND_0100 INPUT
*& Form EXIT_PROGRAM
text
--> p1 text
<-- p2 text
form exit_program .
leave program.
endform. " EXIT_PROGRAM
*& Form handle_double_click
text
-->P_E_ROW text
-->P_E_COLUMN text
-->P_ES_ROW_NO text
form handle_double_click using e_row type lvc_s_row
e_column type lvc_s_col
es_row_no type lvc_s_roid.
data: t_output type zfunctional.
read table gt_itab into t_output index e_row-index .
if sy-subrc = 0 and e_column-fieldname eq 'QMNUM'.
set parameter id 'K01' field t_output-qmnum.
call transaction 'ZSMART' and skip first screen .
endif.
endform. " handle_double_click
regards,
swaroop. -
How to change the color of specific row in ALV tree
Hi,
I m using method set_table_for_first_display of a class CL_GUI_ALV_TREE.
The req is to change the color of specific row. Now can anybody tell me how to change the color of ALV tree. As in ALV tree and in this method 'set_table_for_first_display', there is no parameter IS_Layout.
Pls suggest...hi
hope this code will help you.
Reward if help.
REPORT zsharad_test1.
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.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = '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
*& Form BUILD_LAYOUT
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).
Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_ekko
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. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
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 -
Adding color to few rows in ALV report output
Hi,
I have developed a ALV report program which displays the project details of the employees.In the output the rows containing the employees who have been part of the project should be displayed in different color.I have used necessary code for this but still the rows are not displayed in different color.
Given below is my program.Please suggest me possible solution for this.
REPORT ZPROJ_ALL_DETAILS.
TYPE-POOLS: SLIS.
Tables: zheempl,zhealoc,zheproj,zheskil.
types: begin of ty_zheempl,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
end of ty_zheempl.
types: begin of ty_zhealoc,
project like zhealoc-project,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
role like zhealoc-role,
end of ty_zhealoc.
types: begin of ty_output,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
role like zhealoc-role,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
cellcolor(4) type c,
end of ty_output.
data: t_zheempl type standard table of ty_zheempl,
t_zhealoc type standard table of ty_zhealoc,
t_output type standard table of ty_output with header line.
data: wa_zheempl type ty_zheempl,
wa_zhealoc type ty_zhealoc,
wa_output type ty_output.
DATA : T_FIELDCAT TYPE slis_t_fieldcat_alv.
Data : wa_fieldcat type slis_fieldcat_alv.
Data: it_top TYPE slis_t_listheader,
wa_top TYPE slis_listheader.
Data: t_cellcolor TYPE lvc_t_scol WITH HEADER LINE,
wa_cellcolor TYPE lvc_s_scol.
Data: t_layout TYPE slis_layout_alv.
*selection-screen
selection-screen: begin of block b1 with frame title text-001.
select-options: s_proj for wa_zhealoc-project,
s_empid for wa_zheempl-empid.
parameters: p_date like sy-datum obligatory.
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
parameters: p_prtosr radiobutton group g1 default 'X',
p_prusly radiobutton group g1.
selection-screen: end of block b2.
selection-screen: begin of block b3 with frame title text-003.
parameters: p_dwtodk as checkbox default 'X'.
selection-screen: end of block b3.
selection-screen: begin of block b4 with frame title text-004.
parameters: p_shwhis as checkbox default 'X'.
selection-screen: end of block b4.
Start-of-selection
IF p_shwhis = 'X'.
SELECT l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
where project IN s_proj
AND endat < p_date
OR endat > p_date.
t_output-cellcolor = 'C310'.
MODIFY t_output transporting cellcolor where endat < p_date.
ELSE.
select l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
WHERE project in s_proj
AND endat > p_date.
ENDIF.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'EMPID'.
wa_fieldcat-seltext_m = 'Employee ID'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_m = 'Name 1'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ROLE'.
wa_fieldcat-seltext_m = 'Role of employee in the project'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'STDAT'.
wa_fieldcat-seltext_m = 'Start Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ENDAT'.
wa_fieldcat-seltext_m = 'End Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '6'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'GRADE'.
wa_fieldcat-seltext_m = 'Salary Level'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '7'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'PU'.
wa_fieldcat-seltext_m = 'Department Number'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '8'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'LOCATION'.
wa_fieldcat-seltext_m = 'Work Location'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
t_layout-no_input = 'X'.
t_layout-colwidth_optimize = 'x'.
t_layout-info_fieldname = 'LINE_COLOR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
i_callback_top_of_page = 'TOP'
is_layout = t_layout
IT_FIELDCAT = T_FIELDCAT
i_save = 'X'
TABLES
t_outtab = T_OUTPUT
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.
Form top.
Refresh it_top.
wa_top-typ = 'S'.
wa_top-key = 'Requestor'.
wa_top-info = sy-uname.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Program'.
wa_top-info = sy-repid.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Page'.
wa_top-info = sy-pagno.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Date'.
wa_top-info = sy-datum.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'H'.
wa_top-info = 'Project Details'.
APPEND wa_top to it_top.
CLEAR wa_top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_top.
ENDFORM.{ REPORT ZPROJ_ALL_DETAILS.
TYPE-POOLS: SLIS.
Tables: zheempl,zhealoc,zheproj,zheskil.
types: begin of ty_zheempl,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
end of ty_zheempl.
types: begin of ty_zhealoc,
project like zhealoc-project,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
role like zhealoc-role,
end of ty_zhealoc.
types: begin of ty_output,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
role like zhealoc-role,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
cellcolor(4) type c,
end of ty_output.
data: t_zheempl type standard table of ty_zheempl,
t_zhealoc type standard table of ty_zhealoc,
t_output type standard table of ty_output with header line,
t_output1 type standard table of ty_output with header line.
data: wa_zheempl type ty_zheempl,
wa_zhealoc type ty_zhealoc,
wa_output type ty_output,
wa_output1 type ty_output.
DATA : T_FIELDCAT TYPE slis_t_fieldcat_alv.
Data : wa_fieldcat type slis_fieldcat_alv.
Data: it_top TYPE slis_t_listheader,
wa_top TYPE slis_listheader.
Data: t_cellcolor TYPE lvc_t_scol WITH HEADER LINE,
wa_cellcolor TYPE lvc_s_scol.
Data: t_layout TYPE slis_layout_alv.
*selection-screen
selection-screen: begin of block b1 with frame title text-001.
select-options: s_proj for wa_zhealoc-project,
s_empid for wa_zheempl-empid.
parameters: p_date like sy-datum obligatory.
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
parameters: p_prtosr radiobutton group g1 default 'X',
p_prusly radiobutton group g1.
selection-screen: end of block b2.
selection-screen: begin of block b3 with frame title text-003.
parameters: p_dwtodk as checkbox default 'X'.
selection-screen: end of block b3.
selection-screen: begin of block b4 with frame title text-004.
parameters: p_shwhis as checkbox default 'X'.
selection-screen: end of block b4.
Start-of-selection
IF p_shwhis = 'X'.
SELECT l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
where project IN s_proj
AND endat < p_date
OR endat > p_date.
t_output-cellcolor = 'C310'.
MODIFY t_output transporting cellcolor where endat < p_date.
ELSE.
select l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
WHERE project in s_proj
AND endat > p_date.
ENDIF.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'EMPID'.
wa_fieldcat-seltext_m = 'Employee ID'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_m = 'Name 1'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ROLE'.
wa_fieldcat-seltext_m = 'Role of employee in the project'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'STDAT'.
wa_fieldcat-seltext_m = 'Start Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ENDAT'.
wa_fieldcat-seltext_m = 'End Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '6'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'GRADE'.
wa_fieldcat-seltext_m = 'Salary Level'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '7'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'PU'.
wa_fieldcat-seltext_m = 'Department Number'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '8'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'LOCATION'.
wa_fieldcat-seltext_m = 'Work Location'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
t_layout-no_input = 'X'.
t_layout-colwidth_optimize = 'x'.
t_layout-info_fieldname = 'LINE_COLOR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
i_callback_top_of_page = 'TOP'
is_layout = t_layout
IT_FIELDCAT = T_FIELDCAT
i_save = 'X'
TABLES
t_outtab = T_OUTPUT
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.
Form top.
Refresh it_top.
wa_top-typ = 'S'.
wa_top-key = 'Requestor'.
wa_top-info = sy-uname.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Program'.
wa_top-info = sy-repid.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Page'.
wa_top-info = sy-pagno.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Date'.
wa_top-info = sy-datum.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'H'.
wa_top-info = 'Project Details'.
APPEND wa_top to it_top.
CLEAR wa_top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_top.
ENDFORM.} -
How to color row in ALV report?
hi
I am creating an ALV report using factory method.
my report is based on itab which contain 3 coulms, 1 column is ERROR_TYPE . how can i color all the rows which contain E in error_type ???
thanks
AmiTABLES:LFA1.
SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.
DATA:BEGIN OF ITAB OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
LAND1 LIKE LFA1-LAND1,
ORT01 LIKE LFA1-ORT01,
REGIO LIKE LFA1-REGIO,
SORTL LIKE LFA1-SORTL,
CFIELD(4) TYPE C,
END OF ITAB.
data:col(4).
data:num value '1'.
SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR
IN LIFNR.
LOOP AT ITAB.
concatenate 'C' num '10' into col .
ITAB-CFIELD = col.
num = num + 1.
if num = '8'.
num = '1'.
endif.
MODIFY ITAB.
ENDLOOP.
TYPE-POOLS:SLIS.
DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.
LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
LAYOUT-WINDOW_TITLEBAR = 'VENDORS DETAILS SCREEN'.
LAYOUT-EDIT = 'X'.
LAYOUT-info_fieldname = 'CFIELD'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
this is for coloring cols
REPORT ZBHCOLOR_COLS.
TABLES:LFA1.
SELECT-OPTIONS:C_LIFNR FOR LFA1-LIFNR. " FOR GRID ONLY
PARAMETERS:LIST RADIOBUTTON GROUP ALV DEFAULT 'X',
GRID RADIOBUTTON GROUP ALV.
DATA:BEGIN OF ITAB OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
LAND1 LIKE LFA1-LAND1,
ORT01 LIKE LFA1-ORT01,
SORTL LIKE LFA1-SORTL,
REGIO LIKE LFA1-REGIO,
COL TYPE LVC_T_SCOL,
END OF ITAB.
DATA:COLR TYPE LVC_S_SCOL.
SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB.
LOOP AT ITAB.
IF ITAB-LIFNR IN C_LIFNR.
COLR-FNAME = 'NAME1'.
COLR-COLOR-COL = '5'.
COLR-COLOR-INT = '1'.
COLR-COLOR-INV = '0'.
COLR-NOKEYCOL = 'X'.
APPEND COLR TO ITAB-COL.
COLR-FNAME = 'LIFNR'.
APPEND COLR TO ITAB-COL.
MODIFY ITAB.
ENDIF.
ENDLOOP.
TYPE-POOLS:SLIS.
DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
LAYOUT-ZEBRA = 'X'.
layout-coltab_fieldname = 'COL'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = FCAT.
IF LIST = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
ELSEIF GRID = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
ENDIF.
Reward points if useful.
Maybe you are looking for
-
Can I upgrade from CS3 directly to CS5 or 5.5?
Or do I need to buy CS4?
-
Where can i download a driver for HP PC 1400 that will install on my mac
I can download a package from HP that says it will install the software needed to install on my mac (running ver 10.8.2) but even when I override the allow package to be installed from anyone, it doesn't work. anybody know abou
-
Hp laserjet 4m printer, the greatest printer in the world vs 10.5
I have an old HP laserjet 4m printer. This is the best investment I ever made for my business. It has been a great workhorse, always reliable. Now with Leopard it does not work. The print driver sees the printer and allows about 2 seconds of connecti
-
Large thumbnail previews in Finder?
Is there any way I can select LARGE thumbnail previews for images on my hard drives in the 'Finder' window? I.e. like in Windows Explorer; where you can actually see the image? I have 1000's of photos, & if I'm searching for a specific image I really
-
Is there such a thing as a 3D flash file?
I have heard this term thrown around but was sceptical if there was such a thing as a 3D flash file. So....is there? TIA Dean