Google Search - Blog...........

ABAP - ALV Report Program - Colors- Using REUSE_ALV_GRID_DISPLAY_LVC

REPORT ZTESTALV.

*&---------------------------------------------------------------------*
* type pools
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS.

*&---------------------------------------------------------------------*
* declarations for alv and internal tables
*----------------------------------------------------------------------*
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
WA_FIELDCAT TYPE LVC_S_FCAT,
WA_LAYOUT TYPE LVC_S_LAYO,
V_POSITION TYPE I ,
LS_CELLCOLOR TYPE LVC_S_SCOL,
L_INDEX TYPE SY-TABIX.

DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
CELLCOLOR TYPE LVC_T_SCOL,
END OF IT_VBAP.

*&---------------------------------------------------------------------*
* start of selection
*----------------------------------------------------------------------*
start-of-selection .

*---get data from db table
perform get_data .

*---build layout for alv
perform build_layout .

*---build fieldcat for alv
perform build_fieldcat .

*---modify fieldcat for colors in alv
Perform modify_fieldcat .

*---display alv
perform display_alv .

*&---------------------------------------------------------------------*
*& Form get_data
*----------------------------------------------------------------------*
FORM get_data .

SELECT VBELN
POSNR
UP TO 25 ROWS
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
FROM VBAP.

ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form build_fieldcat
*----------------------------------------------------------------------*
FORM build_fieldcat .

WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-REPTEXT = 'VBELN'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.

WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-REPTEXT = 'POSNR'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.

ENDFORM. " build_fieldcat
*&---------------------------------------------------------------------*
*& Form build_layout
*----------------------------------------------------------------------*
FORM build_layout .

WA_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
WA_LAYOUT-ZEBRA = 'X'.

ENDFORM. " build_layout
*&---------------------------------------------------------------------*
*& Form modify_fieldcat
*----------------------------------------------------------------------*
FORM modify_fieldcat .

LOOP AT IT_VBAP.

L_INDEX = SY-TABIX.
if l_index = 5 or l_index = 15.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '1'.
APPEND LS_CELLCOLOR TO IT_VBAP-CELLCOLOR.
MODIFY IT_VBAP INDEX L_INDEX TRANSPORTING CELLCOLOR.
endif.

if l_index = 10 or l_index = 20.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '4'.
LS_CELLCOLOR-COLOR-INT = '1'.
APPEND LS_CELLCOLOR TO IT_VBAP-CELLCOLOR.
MODIFY IT_VBAP INDEX L_INDEX TRANSPORTING CELLCOLOR.
endif.

if it_vbap-VBELN is initial .
delete it_vbap.
endif.

ENDLOOP.


ENDFORM. " modify_fieldcat
*&---------------------------------------------------------------------*
*& Form display_alv
*----------------------------------------------------------------------*
FORM display_alv .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
TABLES
T_OUTTAB = IT_VBAP .


ENDFORM. " display_alv


ALSO READ:


- ALV Report With User Defined Buttons In It's Toolbar.

- ALV Report Program - Colors- Using REUSE_ALV_GRID_DISPLAY_LVC.

- Displaying Percentage In ALV List / Grid Display.

- Handling An ALV Grid With Check Box Using A Method.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.


No comments:

Post a Comment