Skip to Content
0
Former Member
Dec 28, 2007 at 06:20 AM

How to highlight rows in the following code.

33 Views

Hi,

I am using the following logic to display 2 lists at a time.

I want to highlight the last 2 rows of both the lists that I am displaying.how to do it.

Kindly help.

TYPE-POOLS : slis.

TABLES : mara,

makt.

SELECT-OPTIONS : mat FOR mara-matnr.

DATA : BEGIN OF itab OCCURS 0,

matnr LIKE mara-matnr,

maktx LIKE makt-maktx,

matkl LIKE mara-matkl,

mtart LIKE mara-mtart,

END OF itab.

DATA : BEGIN OF itab1 OCCURS 0,

mtart LIKE mara-mtart,

count TYPE i,

END OF itab1.

DATA : BEGIN OF itab1_col OCCURS 0,

mtart LIKE mara-mtart,

count TYPE i,

END OF itab1_col.

DATA : t_fcat1 TYPE slis_t_fieldcat_alv,

t_fcat2 TYPE slis_t_fieldcat_alv,

wa_fcat TYPE slis_fieldcat_alv,

t_eve TYPE slis_t_event,

wa_eve TYPE slis_alv_event,

t_layout TYPE slis_layout_alv.

DATA : v_repid LIKE sy-repid,

t_mat LIKE mara-matnr.

DEFINE create_fcat.

clear wa_fcat.

wa_fcat-fieldname = &1.

wa_fcat-seltext_l = &2.

wa_fcat-outputlen = &3.

append wa_fcat to t_fcat1.

END-OF-DEFINITION.

START-OF-SELECTION.

PERFORM get_data.

PERFORM dis_data.

&----


*& Form get_data

&----


text

-


FORM get_data.

SELECT amatnr bmaktx amtart amatkl INTO CORRESPONDING FIELDS OF TABLE itab

FROM mara AS a INNER JOIN makt AS b ON

amatnr = bmatnr

WHERE a~matnr IN mat.

LOOP AT itab.

itab1-mtart = itab-mtart.

itab1-count = 1.

APPEND itab1.

ENDLOOP.

SORT itab1 BY mtart.

LOOP AT itab1.

MOVE-CORRESPONDING itab1 TO itab1_col.

COLLECT itab1_col.

ENDLOOP.

ENDFORM. "get_data

&----


*& Form dis_data

&----


text

-


FORM dis_data.

v_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = v_repid.

REFRESH t_fcat1.

CLEAR t_fcat1.

REFRESH t_eve.

wa_eve-name = 'TOP_OF_PAGE'.

wa_eve-form = 'TOP_OF_PAGE1'.

APPEND wa_eve TO t_eve.

create_fcat:

'MATNR' 'Material' '10',

'MAKTX' 'Material Description' '40',

'MTART' 'Type' '10',

'MATKL' 'Group' '10'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = t_layout

it_fieldcat = t_fcat1

i_tabname = 'ITAB'

it_events = t_eve

TABLES

t_outtab = itab.

REFRESH t_fcat1.

CLEAR t_fcat1.

REFRESH t_eve.

wa_eve-name = 'TOP_OF_PAGE'.

wa_eve-form = 'TOP_OF_PAGE2'.

APPEND wa_eve TO t_eve.

create_fcat:

'MTART' 'Type' '10',

'COUNT' 'Total' '5'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = t_layout

it_fieldcat = t_fcat1

i_tabname = 'ITAB1_COL'

it_events = t_eve

TABLES

t_outtab = itab1_col.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

ENDFORM. "dis_data

&----


*& Form top_of_page1

&----


text

-


FORM top_of_page1.

FORMAT COLOR COL_POSITIVE.

WRITE:/ 'First Block'.

FORMAT COLOR OFF.

ENDFORM. "top_of_page

&----


*& Form top_of_page2

&----


text

-


FORM top_of_page2.

FORMAT COLOR COL_NEGATIVE.

WRITE /5 'Second Block'.

FORMAT COLOR OFF.

ENDFORM. "top_of_page