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: 

ALV

Former Member
0 Kudos
114

Dear All,

I have one output internal table with fields vbeln,posnr,land1,reservation(in days), accuracy(in days),waiting(in days).along with these fields there are two other fields STATUS and SCM_STATUS for traffic signals.

Here the condition is if reservation<=10 days AND 0<= accuracy <= 5 days then STATUS traffic signal is green other wise red.

if WAITING > 3 days then SCM_STATUS is red.

Now i want display this one using ALV grid.

Please let me know how to use traffice signal in the alv.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
82

Hi

see the sample program to display RED ICON

and do accordingly

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.

<b>Reward points for useful Answers</b>

Regards

Anji

4 REPLIES 4

Former Member
0 Kudos
83

Hi

see the sample program to display RED ICON

and do accordingly

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.

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member

Former Member
0 Kudos
82

Hi,

Refer to the following standard program:

BCALV_GRID_04

Hope this helps.

Reward if helpful.

Regards,

Sipra

Former Member
0 Kudos
82

If you are using OOALV, following will be of some help to you

Define the layout structure of type <b>LVC_S_LAYO :

DATA gs_layout TYPE LVC_S_LAYO .</b>

Add a variable of type C to your output table, as shown in the following example:

<b>DATA: BEGIN OF GT_OUTTAB OCCURS 0.

INCLUDE STRUCTURE <DDIC-Struktur>.

DATA: light TYPE C</b>. "to display exceptions

<b>DATA: END OF GT_OUTTAB.</b>

Set field <b>EXCP_FNAME</b> of the layout structure to the field name of the exception:

<b>gs_layout-excp_fname = 'LIGHT'.</b>

If you want to display the exception as an LED, you must set field EXCP_LED of the layout structure.

Read one row of the output table at a time in a loop, and query the fields that are related to the exception. Set your variable for the exception display format (which is LIGHT in our example) to '1', '2' or '3' (see above), depending on the threshold value you have chosen.

Pass the layout structure and the output table using method <b>set_table_for_first_display.</b>