Chapter 084
ALV Color sample program
Source : http://abapjoy.blogspot.com
When creating ALV report program, the one we should implement is to set
the color in line and text. This post offers a sample program and alv color
code.
REPORT
ZALVCOLOR.
TYPE-POOLS: SLIS.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: BEGIN OF I_OUTPUT OCCURS 0,
I_TEXT(30) TYPE C,
I_COLOR(4),
END OF
I_OUTPUT.
DATA: I_NUM(1) TYPE N.
DATA: I_INT(1) TYPE N.
DATA: I_4(1)
TYPE N.
DO 28 TIMES.
I_4 = 0.
IF SY-INDEX =
1.
I_NUM = 1.
I_INT = 1.
ELSE.
I_NUM = I_NUM
+ 1.
IF I_NUM = 8.
I_NUM = 1.
I_INT = 0.
ENDIF.
ENDIF.
IF SY-INDEX
> 14.
I_4 = 1.
ENDIF.
IF SY-INDEX
> 21.
I_INT = 1.
ENDIF.
CONCATENATE 'C'
I_NUM I_INT I_4 INTO I_OUTPUT-I_COLOR.
CONCATENATE
'COLOR ' I_OUTPUT-I_COLOR INTO I_OUTPUT-I_TEXT SEPARATED BY SPACE.
APPEND
I_OUTPUT.
CLEAR I_OUTPUT.
ENDDO.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'I_TEXT'.
LS_FIELDCAT-SELTEXT_L = 'ALV COLOR VIEW'.
LS_FIELDCAT-KEY = 'X'.
LS_FIELDCAT-OUTPUTLEN = '30'.
APPEND LS_FIELDCAT TO FIELDCAT.
LAYOUT-INFO_FIELDNAME = 'I_COLOR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'Z_SET_COLOR_IN_ALV_OUTPUT'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDCAT[]
TABLES
T_OUTTAB = I_OUTPUT[].
|
No comments:
Post a Comment