2008 Feb 28 9:52 AM
Hi.
I'm using function module REUSE_ALV_GRID_DISPLAY to display an ALV list. I want to display a column say 'STATUS'
traffic lights or some tick mark icon depending on a condition of a column.How to do this?
2008 Feb 28 10:01 AM
hi
try the following
riday, November 9, 2007
ALV LIST USING OO STYLE SAMPLE CODE
1. Create a Control (for Custom and Split Containers only)
2. Instantiate a Container Object (in case of Custom and Split Containers, specify the control which is created by us in Screen painter) CREATE OBJECT
3. Instantiate an Object of the kind of report that has to be displayed (List, Grid or Tree). CREATE OBJECT . Here we need to specify the Parent Container as the so that it sits in that container.
4. Call appropriate methods to display the report on the screen. CALL METHOD ->
Example:
DATA : g_dock TYPE REF TO cl_gui_docking_container,
g_split TYPE REF TO cl_gui_easy_splitter_container,
g_cont1 TYPE REF TO cl_gui_container,
g_cont2 TYPE REF TO cl_gui_container,
g_grid1 TYPE REF TO cl_gui_alv_grid,
g_grid2 TYPE REF TO cl_gui_alv_grid.
i_mara is an internal table of structure MARA
SELECT * FROM mara INTO TABLE i_mara.
i_kna1 is an internal table of structure KNA1
SELECT * FROM kna1 INTO TABLE i_kna1.
To create an Object of type Docking Container
CREATE OBJECT g_dock
EXPORTING
side = cl_gui_docking_container=>dock_at_top
extension = 200 .
To Create an Object of Type Split Container. Here we can see that the Docking *Container Created above has been used as a parent .
CREATE OBJECT g_split
EXPORTING
parent = g_dock
orientation = 1 .
Easy Split container splits one Control into 2 manageable controls, each of them is used * to handle one GUI Container each
g_cont1 = g_split->top_left_container.
g_cont2 = g_split->bottom_right_container.
To Create an Object of type Grid . Here we can see that the Left Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid1
EXPORTING
i_parent = g_cont1 .
To Create an Object of type Grid . Here we can see that the Right Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid2
EXPORTING
i_parent = g_cont2 .
The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'MARA'
CHANGING
it_outtab = i_mara[] .
The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNA1'
CHANGING
it_outtab = i_kna1[] .
RELATED POSTS
ALV INTERACTIVE REPORT SAMPLE CODE
INTERACTIVE REPORT SAMPLE CODE 2
ALV SAMPLE CODE OUTPUT TO EXCEL SHEET
ALV SAMPLE CODE COLOURING
ALV SIMPLE REPORT SAMPLE CODE
ALV DOUBLE CLICK SAMPLE CODE
ALV INTERACTIVE REPORT SAMPLE CODE
ALV FOR CHECK BOXES SAMPLE CODE
ALV BLOCK REPORT SAMPLE CODE
ALV LAYOUT DISPLAY SAMPLE CODE
ALV LIST DISPLAY SAMPLE CODE
ALV HIRARCHICAL REPORT SAMPLE CODE
EXECUTABLE REPORT ON ALV
REPLACE COMMENTARY WITH ALV REPORT
SAMPLE CODE FOR DATA BASE ACCESSING FROM UNIX FILE
ALV SAMPLE CODE CONTACT RENUAL DETAILS
ALV BASICS
ALV GRID CONTROL
ALV COMPLETE DOCUMENTATION
ABAP CROSS APPLICATIONS DEFINATIONS
ALV DOCS
hope it will help you
regards
sreelatha gullapalli
Hi.
I'm using function module REUSE_ALV_GRID_DISPLAY to display an ALV list. I want to display a column say 'STATUS'
traffic lights or some tick mark icon depending on a condition of a column.How to do this?
2008 Feb 28 10:01 AM
hi
try the following
riday, November 9, 2007
ALV LIST USING OO STYLE SAMPLE CODE
1. Create a Control (for Custom and Split Containers only)
2. Instantiate a Container Object (in case of Custom and Split Containers, specify the control which is created by us in Screen painter) CREATE OBJECT
3. Instantiate an Object of the kind of report that has to be displayed (List, Grid or Tree). CREATE OBJECT . Here we need to specify the Parent Container as the so that it sits in that container.
4. Call appropriate methods to display the report on the screen. CALL METHOD ->
Example:
DATA : g_dock TYPE REF TO cl_gui_docking_container,
g_split TYPE REF TO cl_gui_easy_splitter_container,
g_cont1 TYPE REF TO cl_gui_container,
g_cont2 TYPE REF TO cl_gui_container,
g_grid1 TYPE REF TO cl_gui_alv_grid,
g_grid2 TYPE REF TO cl_gui_alv_grid.
i_mara is an internal table of structure MARA
SELECT * FROM mara INTO TABLE i_mara.
i_kna1 is an internal table of structure KNA1
SELECT * FROM kna1 INTO TABLE i_kna1.
To create an Object of type Docking Container
CREATE OBJECT g_dock
EXPORTING
side = cl_gui_docking_container=>dock_at_top
extension = 200 .
To Create an Object of Type Split Container. Here we can see that the Docking *Container Created above has been used as a parent .
CREATE OBJECT g_split
EXPORTING
parent = g_dock
orientation = 1 .
Easy Split container splits one Control into 2 manageable controls, each of them is used * to handle one GUI Container each
g_cont1 = g_split->top_left_container.
g_cont2 = g_split->bottom_right_container.
To Create an Object of type Grid . Here we can see that the Left Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid1
EXPORTING
i_parent = g_cont1 .
To Create an Object of type Grid . Here we can see that the Right Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid2
EXPORTING
i_parent = g_cont2 .
The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'MARA'
CHANGING
it_outtab = i_mara[] .
The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNA1'
CHANGING
it_outtab = i_kna1[] .
RELATED POSTS
ALV INTERACTIVE REPORT SAMPLE CODE
INTERACTIVE REPORT SAMPLE CODE 2
ALV SAMPLE CODE OUTPUT TO EXCEL SHEET
ALV SAMPLE CODE COLOURING
ALV SIMPLE REPORT SAMPLE CODE
ALV DOUBLE CLICK SAMPLE CODE
ALV INTERACTIVE REPORT SAMPLE CODE
ALV FOR CHECK BOXES SAMPLE CODE
ALV BLOCK REPORT SAMPLE CODE
ALV LAYOUT DISPLAY SAMPLE CODE
ALV LIST DISPLAY SAMPLE CODE
ALV HIRARCHICAL REPORT SAMPLE CODE
EXECUTABLE REPORT ON ALV
REPLACE COMMENTARY WITH ALV REPORT
SAMPLE CODE FOR DATA BASE ACCESSING FROM UNIX FILE
ALV SAMPLE CODE CONTACT RENUAL DETAILS
ALV BASICS
ALV GRID CONTROL
ALV COMPLETE DOCUMENTATION
ABAP CROSS APPLICATIONS DEFINATIONS
ALV DOCS
hope it will help you
regards
sreelatha gullapalli
2008 Feb 28 10:14 AM
But the approach given by you is for ALV GRID using Object orirnted methods.
I want to use function module REUSE_ALV_GRID_DISPLAY
which is for lists.
2008 Feb 28 10:33 AM
Hi Gautam,
Have a look at this demo program which uses the traffic lights BCALV_DEMO_TOOLTIP.
Christina
2008 Feb 28 10:29 AM
Hi,
Use this code for Demo
&----
*& Report ZMDEMO_ALV_04
*&
&----
*&Make an Exception field ( = Traffic lights)
*&There can be defined a column in the grid for display of traffic lights. This field is of type Char 1, and can contain the following values:
*& 1 Red
*& 2 Yellow
*& 3 Green
*&The name of the traffic light field is supplied inh the gs_layout-excp_fname used by method set_table_for_first_display.
*&
&----
report zmdemo_alv_04.
tables: sflight.
type-pools: icon.
types: begin of ty_sflight.
include structure sflight.
types: traffic_light type c,
lights LIKE icon_xml_doc,
lights(4),
icon type icon-id.
types: end of ty_sflight.
*----
G L O B A L I N T E R N A L T A B L E S
*----
data: t_sflight type standard table of ty_sflight.
*----
G L O B A L D A T A
*----
data: ok_code like sy-ucomm,
wa_sflight type ty_sflight.
Declare reference variables to the ALV grid and the container
data:
go_grid type ref to cl_gui_alv_grid,
go_custom_container type ref to cl_gui_custom_container.
data:
t_fcat type lvc_t_fcat,
wa_layout type lvc_s_layo.
*----
S T A R T - O F - S E L E C T I O N.
*----
start-of-selection.
perform build_fieldcat.
perform build_layout.
set screen '100'.
&----
*& Module USER_COMMAND_0100 INPUT
&----
module user_command_0100 input.
case ok_code.
when 'EXIT'.
leave to screen 0.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
&----
*& Module STATUS_0100 OUTPUT
&----
module status_0100 output.
Create objects
if go_custom_container is initial.
create object go_custom_container
exporting container_name = 'ALV_CONTAINER'.
create object go_grid
exporting
i_parent = go_custom_container.
perform load_data_into_grid.
endif.
endmodule. " STATUS_0100 OUTPUT
&----
*& Form load_data_into_grid
&----
form load_data_into_grid.
data l_light type c value '1'.
Read data from table SFLIGHT
select *
from sflight
into table t_sflight.
*
o
+ Condition placing to the traffic_light Field
LOOP AT t_sflight INTO wa_sflight.
wa_sflight-traffic_light = l_light.
MODIFY t_sflight FROM wa_sflight.
*
IF l_light = '3'.
l_light = '1'.
*
ELSE.
l_light = l_light + 1.
ENDIF.
ENDLOOP.
*
*
o
+ Setting the Icon based on the traffic_light field value.
LOOP AT t_sflight INTO wa_sflight.
CASE wa_sflight-traffic_light.
WHEN '1'.
wa_sflight-lights = icon_red_light.
WHEN '2'.
wa_sflight-lights = icon_yellow_light.
WHEN '3'.
wa_sflight-lights = icon_green_light.
ENDCASE.
MODIFY t_sflight FROM wa_sflight.
ENDLOOP.
loop at t_sflight into wa_sflight.
case l_light.
when '1'.
wa_sflight-lights = icon_red_light.
when '2'.
wa_sflight-lights = icon_yellow_light.
when '3'.
wa_sflight-lights = icon_green_light.
endcase.
if l_light = '3'.
l_light = '1'.
else.
l_light = l_light + 1.
endif.
modify t_sflight from wa_sflight.
endloop.
Load data into the grid and display them
call method go_grid->set_table_for_first_display
exporting
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
i_structure_name = 'SFLIGHT'
IS_VARIANT =
i_save = 'A'
I_DEFAULT = 'X'
is_layout = wa_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
changing
it_outtab = t_sflight[]
it_fieldcatalog = t_fcat
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
endform. " load_data_into_grid
&----
*& Form build_fieldcat
&----
text
--> p1 text
<-- p2 text
form build_fieldcat .
data: w_fcat type lvc_s_fcat.
define macro_fcat.
w_fcat-fieldname = &1.
w_fcat-col_pos = &2.
w_fcat-coltext = &3.
append w_fcat to t_fcat.
clear w_fcat.
end-of-definition.
macro_fcat 'CARRID' 1 text-c01 .
macro_fcat 'CONNID' 2 text-c02 .
macro_fcat 'FLDATE' 3 text-c03 .
macro_fcat 'PRICE' 4 text-c04 .
macro_fcat 'SEATSMAX' 5 text-c05 .
macro_fcat 'SEATSOCC' 6 text-c06 .
macro_fcat 'LIGHTS' 7 text-c07 .
endform. " build_fieldcat
&----
*& Form build_layout
&----
text
--> p1 text
<-- p2 text
form build_layout .
wa_layout-cwidth_opt = 'X'.
wa_layout-excp_fname = 'TRAFFIC_LIGHT'.
wa_layout-excp_group = '1'.
endform. " build_layout
Regards,
Dhruv Shah
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |