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

Adding colour

radhushankar
Participant
0 Likes
955

Hi

Can any one tell me how to add colour to text which is hardcoded in the program??

Thanks

5 REPLIES 5
Read only

Former Member
0 Likes
747

Hi,

Use inverse on & inverse off to provide colour to your text.

Regards,

Smit

Read only

GauthamV
Active Contributor
0 Likes
747

hi,

check this sample code.

&----


*& Report ZGM_COLOR *

*& *

&----


*&

&----


REPORT ZGM_COLOR .

TYPE-POOLS: SLIS, ICON.

DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: BEGIN OF IMARA OCCURS 0,

LIGHT(4) TYPE C,

MATNR TYPE MARA-MATNR,

MTART TYPE MARA-MTART,

MAKTX TYPE MAKT-MAKTX,

COLOR_LINE(4) TYPE C,

TCOLOR TYPE SLIS_T_SPECIALCOL_ALV, "cell

END OF IMARA.

DATA: XCOLOR TYPE SLIS_SPECIALCOL_ALV.

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM WRITE_REPORT.

************************************************************************

  • Get_Data

************************************************************************

FORM GET_DATA.

WRITE ICON_GREEN_LIGHT AS ICON TO IMARA-LIGHT.

IMARA-MATNR = 'ABC'.

IMARA-MTART = 'ZCFG'.

IMARA-MAKTX = 'This is description for ABC'.

APPEND IMARA.

WRITE ICON_YELLOW_LIGHT AS ICON TO IMARA-LIGHT.

IMARA-MATNR = 'DEF'.

IMARA-MTART = 'ZCFG'.

IMARA-MAKTX = 'This is description for DEF'.

APPEND IMARA.

WRITE ICON_RED_LIGHT AS ICON TO IMARA-LIGHT.

IMARA-MATNR = 'GHI'.

IMARA-MTART = 'ZCFG'.

IMARA-MAKTX = 'This is description for GHI'.

APPEND IMARA.

LOOP AT IMARA.

IF SY-TABIX = 1.

IMARA-COLOR_LINE = 'C410'. " color line

ENDIF.

IF SY-TABIX = 2. " color CELL

CLEAR XCOLOR.

XCOLOR-FIELDNAME = 'MTART'.

XCOLOR-COLOR-COL = '3'.

XCOLOR-COLOR-INT = '1'. " Intensified on/off

XCOLOR-COLOR-INV = '0'.

APPEND XCOLOR TO IMARA-TCOLOR.

ENDIF.

MODIFY IMARA.

ENDLOOP.

ENDFORM. "get_data

************************************************************************

  • WRITE_REPORT

************************************************************************

FORM WRITE_REPORT.

DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.

LAYOUT-COLTAB_FIELDNAME = 'TCOLOR'.

LAYOUT-INFO_FIELDNAME = 'COLOR_LINE'.

PERFORM BUILD_FIELD_CATALOG.

  • CALL ABAP LIST VIEWER (ALV)

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FIELDCAT

TABLES

T_OUTTAB = IMARA.

ENDFORM. "write_report

************************************************************************

  • BUILD_FIELD_CATALOG

************************************************************************

FORM BUILD_FIELD_CATALOG.

DATA: FC_TMP TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

CLEAR: FIELDCAT. REFRESH: FIELDCAT.

CLEAR: FC_TMP.

FC_TMP-REPTEXT_DDIC = 'Status'.

FC_TMP-FIELDNAME = 'LIGHT'.

FC_TMP-TABNAME = 'IMARA'.

FC_TMP-OUTPUTLEN = '4'.

FC_TMP-ICON = 'X'.

APPEND FC_TMP TO FIELDCAT.

CLEAR: FC_TMP.

FC_TMP-REPTEXT_DDIC = 'Material Number'.

FC_TMP-FIELDNAME = 'MATNR'.

FC_TMP-TABNAME = 'IMARA'.

FC_TMP-OUTPUTLEN = '18'.

APPEND FC_TMP TO FIELDCAT.

CLEAR: FC_TMP.

FC_TMP-REPTEXT_DDIC = 'Material Type'.

FC_TMP-FIELDNAME = 'MTART'.

FC_TMP-TABNAME = 'IMARA'.

FC_TMP-OUTPUTLEN = '10'.

APPEND FC_TMP TO FIELDCAT.

CLEAR: FC_TMP.

FC_TMP-REPTEXT_DDIC = 'Material'.

FC_TMP-FIELDNAME = 'MAKTX'.

FC_TMP-TABNAME = 'IMARA'.

FC_TMP-OUTPUTLEN = '40'.

FC_TMP-EMPHASIZE = 'C610'. " color column

APPEND FC_TMP TO FIELDCAT.

ENDFORM. "build_field_catalog

Read only

Former Member
0 Likes
747

Plz use below code

FORMAT COLOR COL_HEADING

Write :'Test'.

FORMAT COLOR OFF

Following are few SAP standard Colors

1 COL_HEADING Headers (grayish blue)

2 COL_NORMAL List body (bright gray)

3 COL_TOTAL Totals (yellow)

4 COL_KEY Key columns (bluish green)

5 COL_POSITIVE Positive threshold value (green)

6 COL_NEGATIVE Negative threshold value (red)

7 COL_GROUP Control levels (violet)

rgds

rajesh

Edited by: RAJESH KUMAR on Aug 8, 2008 10:54 AM

Read only

Former Member
0 Likes
747

Hi,

1. INVERSE ON 
Or  
INVERSE OFF

Inverse - affects the background and foreground colors.

Each color exists in an inverse form. ... INVERSE takes the current color from the "inverse" palette and uses it as the foreground (font) color. The background (COL_BACKGROUND) then has no color. ... INVERSE OFF switches off the inverse display.

2

.COLOR n [ON] 
   Or 
   COLOR OFF

Color of line background. n can have the following values:

OFF or COL_BACKGROUND

Background (GUI-specific)

1 or COL_HEADING

Headers (grayish blue)

2 or COL_NORMAL

List body (bright gray)

3 or COL_TOTAL

Totals (yellow)

4 or COL_KEY

Key columns (bluish green)

5 or COL_POSITIVE

Positive threshold value (green)

6 or COL_NEGATIVE

Negative threshold value (red)

7 or COL_GROUP

Control levels (violet)

3

INTENSIFIED ON 
Or
 INTENSIFIED OFF

Intensified - affects the background color.

Each color exists in a normal (desaturated) and in an intensified (saturated) form. ... INTENSIFIED takes the current background color from the "intensified" palette, while the ... INTENSIFIED OFF uses the "normal" palette.

Hope this helps.

thanx,

dhanashri.

Edited by: Dhanashri Pawar on Aug 8, 2008 7:35 AM

Read only

Former Member
0 Likes
747

Hi Radhu.

I would like to suggest my opinion,

Sample Codes,


WRITE:/5   'Carrier id'       COLOR 1 INTENSIFIED,
            25  'Connect id'    COLOR 2 INTENSIFIED,
            45  'Flight date'    COLOR 3 INTENSIFIED,
            65  'Price'            COLOR 4 INTENSIFIED,
            85  'Max Seats'    COLOR 5 INTENSIFIED,
            105 'Occp Seats'  COLOR 6 INTENSIFIED.

The possible options with colors are,

1. Intensified.

2. Inverse

3. Simply use color without any additions.

There are different color codes - 1 to 7 for different colors.

Hope that's usefull.

Good Luck & Regards.

Harsh Dave

Edited by: Harsh Dave on Aug 8, 2008 11:02 AM