Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to provide signal lights in ALV output

Former Member
0 Kudos

Hi Experts,

i have one requirement. i am developing one object oriented alv report based on standard report(RFREISCN).i have one requirement in the output provide signal lights(RED(for inactive) AND YELLOW(for account assignment locks)) and to provide custom button 'RELEASE' using object oriented ALV class. how to add please provide me solution.

Thanks,

Venkat.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Copy the program and Check your requirements

Dont' forget to give points please (atlease 2 as the Rule of he SDN Forum)

&----


*& 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.

      • 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.

*

      • 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

Manju

5 REPLIES 5

sarath_k
Participant
0 Kudos

Hi ,

please try with this code . it would be helpful for traffic lights display.

TYPES: BEGIN OF X1,

XX TYPE Y,

YY TYPE X,

traffic_light(1) ,

END OF X1.

DATA: X1 TYPE ITAB OCCURS 0 WITH HEADER LINE.

DATA: ls_layout TYPE slis_layout_alv.

traffic light color display depends on your condition.

itab-traffic_light = 1 or 2 or 3.

ls_layout-lights_fieldname = 'TRAFFIC_LIGHT'.

ls_layout-lights_condense = 'X'.

ls_layout-lights_rollname = 'ZECEP'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'YOUR_PRG_NAME'

is_layout = ls_layout

it_fieldcat = it_fieldcat

i_callback_top_of_page = 'TOP_OF_PAGE'

TABLES

t_outtab = ITAB.

Regards,

Sarath

Former Member
0 Kudos

Hi Sarat,

can u explian in OBJECT ORIENTED ALV point of view?

Former Member
0 Kudos

See the example BCALV_GRID_04 in your system.

Regards,

Ravi

Former Member
0 Kudos

Hi Venkat,

In the field that will decide whether you have to display RED , Yellow etc. set that variable value 1 ( for RED ) and 2 ( For Yellow ).

Now in the layout of the ALV , pass this field's name in the field EXCEP_FNAME .

Then pass this layout 's name to the method SET_TABLE_FOR_FIRST_DISPLAY.

System will display RED light for 1 , YELLOW for 2 and GREEN for 3 ( if you want this. Otherwise this can be ignored ).

Please try the above and get back if some more help is required.

Thanks and Regards

Gurpreet Singh

Former Member
0 Kudos

Copy the program and Check your requirements

Dont' forget to give points please (atlease 2 as the Rule of he SDN Forum)

&----


*& 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.

      • 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.

*

      • 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

Manju