Application Development and Automation 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: 
Read only

display icon using cl_gui_alv_grid - urgent

Former Member
0 Likes
3,792

i want ti display icon[traffic light ] using cl_gui_alv_grid

the field catalog type i m using is lvc_s_fcat

and i m setting the field ls_fieldcat-icon = 'X'.

but its not working.. i m getting dump saying

" In this case, the operand "<L_FIELD_VALUE>" has the type "ICON".

The current program is a Unicode program. In the Unicode context,

structures containing not only character-type components are regarded

as non-numeric."

plz help..

i want ti display icon[traffic light ] using cl_gui_alv_grid

the field catalog type i m using is lvc_s_fcat

and i m setting the field ls_fieldcat-icon = 'X'.

but its not working.. i m getting dump saying

" In this case, the operand "<L_FIELD_VALUE>" has the type "ICON".

The current program is a Unicode program. In the Unicode context,

structures containing not only character-type components are regarded

as non-numeric."

plz help..

3 REPLIES 3
Read only

Former Member
0 Likes
1,773

make sure you field output length is 5 as a start.

field that the light will be displayed from

crdquotel_light(5) TYPE c,

and putting the light in it

issue_rec-crdquotel_light = icon_green_light.

this line should be in the global area

INCLUDE <icon>.

Edited by: Paul Chapman on Jun 6, 2008 8:58 AM

Read only

Former Member
0 Likes
1,773

Neha,

Use Include < Symbols> in your Report.

This coding is only for Red light, Modify the code accordingly as per your requirement.

REPORT YMS_CHECKBOXALV.

TYPE-POOLS: slis.

DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.

DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

DATA: s_layout TYPE slis_layout_alv.

DATA: BEGIN OF itab OCCURS 0,

icon TYPE icon-id,

vbeln TYPE vbeln,

kunnr TYPE kunnr,

erdat TYPE erdat,

box TYPE c,

END OF itab.

DATA: v_repid TYPE syrepid.

START-OF-SELECTION.

  • Get the data.

SELECT vbeln kunnr erdat UP TO 100 ROWS

FROM vbak

INTO CORRESPONDING FIELDS OF TABLE itab.

IF sy-subrc 0.

MESSAGE s208(00) WITH 'No data found'.

LEAVE LIST-PROCESSING.

ENDIF.

  • Modify the record with red light.

itab-icon = '@0A@'.

MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.

v_repid = sy-repid.

  • Get the field catalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '1'.

s_fieldcatalog-fieldname = 'ICON'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-seltext_l = 'Status'.

s_fieldcatalog-icon = 'X'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '2'.

s_fieldcatalog-fieldname = 'VBELN'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'VBELN'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '3'.

s_fieldcatalog-fieldname = 'KUNNR'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'KUNNR'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '4'.

s_fieldcatalog-fieldname = 'ERDAT'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'ERDAT'.

APPEND s_fieldcatalog TO t_fieldcatalog.

  • Set the layout.

s_layout-box_fieldname = 'BOX'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

is_layout = s_layout

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

it_fieldcat = t_fieldcatalog[]

TABLES

t_outtab = itab.

-


  • FORM SET_PF_STATUS *

-


  • ........ *

-


  • --> EXTAB *

-


FORM set_pf_status USING extab TYPE slis_t_extab.

SET PF-STATUS 'TEST2'.

ENDFORM.

-


  • FORM user_command *

-


  • ........ *

-


  • --> UCOMM *

  • --> SELFIELD *

-


FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

  • Check the ucomm.

IF ucomm = 'DETAIL'.

LOOP AT itab WHERE box = 'X'.

itab-icon = '@08@'.

MODIFY itab TRANSPORTING icon.

ENDLOOP.

ENDIF.

selfield-refresh = 'X'.

ENDFORM.

Hope this resolves your query.

Reward all the helpful answers.

Amit

Read only

Former Member
0 Likes
1,773

Hi,

Check the reference code given below.

Please try the below Sample codes .It will be helpful in the traficc lights.

Sample 1

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.

-


Sample 2*

&----


*

*& Report ZALV_DEMO

&----


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