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

Colors

Former Member
0 Likes
1,500

Hi. I try to do sth like that

LOOP AT itab.
  IF itab-belnr1 = itab-belnr2.
    c = 5.  
  ELSE.
    c = 4.
  ENDIF.
  
  WRITE: / sy-vline,
         (10) itab-belnr1 COLOR c, 
         (10) itab-datum1 ,  
         sy-vline,
         (10) itab-belnr2 , 
         (10) itab-datum2 .
ENDLOOP.

But I receive <i>"COLOR 'c'" is not expected; only 1 to 7 or the relevant color IDs

(COL_...) are allowed.</i> . How to determine colors during program flow? Greetings. P.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,453

Hi

the Command COLOR doesn't accept any variables along with it

It is a must to use the numbers 1 to 7 along with it.

Reward points for useful Answers

Regards

Anji

Hi. I try to do sth like that

LOOP AT itab.
  IF itab-belnr1 = itab-belnr2.
    c = 5.  
  ELSE.
    c = 4.
  ENDIF.
  
  WRITE: / sy-vline,
         (10) itab-belnr1 COLOR c, 
         (10) itab-datum1 ,  
         sy-vline,
         (10) itab-belnr2 , 
         (10) itab-datum2 .
ENDLOOP.

But I receive <i>"COLOR 'c'" is not expected; only 1 to 7 or the relevant color IDs

(COL_...) are allowed.</i> . How to determine colors during program flow? Greetings. P.

11 REPLIES 11
Read only

Former Member
0 Likes
1,453

hi,

U need to give as

COLOR 6.

U should give numbers after giving color.

0 COL_BACKGROUND

1 COL_HEADING

2 COL_NORMAL

3 COL_TOTAL

4 COL_KEY

5 COL_POSITIVE

6 COL_NEGATIVE

7 COL_GROUP

Message was edited by:

Roja Velagapudi

Read only

Former Member
0 Likes
1,453

Hi,

Check this,

DATA col TYPE i VALUE 0.

DO 8 TIMES.

col = sy-index - 1.

FORMAT COLOR = col.

WRITE: / col COLOR OFF,

'INTENSIFIED ON' INTENSIFIED ON,

'INTENSIFIED OFF' INTENSIFIED OFF,

'INVERSE ON' INVERSE ON.

ENDDO.

Reward if useful!

Read only

Former Member
0 Likes
1,454

Hi

the Command COLOR doesn't accept any variables along with it

It is a must to use the numbers 1 to 7 along with it.

Reward points for useful Answers

Regards

Anji

Read only

Former Member
0 Likes
1,453

hi,

plz check if "c" the variable used is defined as integer and not as type N.

kiran.

Read only

Former Member
0 Likes
1,453

You need to remember the color codes. Here is the list

Just mention the number beside the statement COLOR.

0 COL_BACKGROUND

1 COL_HEADING

2 COL_NORMAL

3 COL_TOTAL

4 COL_KEY

5 COL_POSITIVE

6 COL_NEGATIVE

7 COL_GROUP

Regards,

Pavan P.

Read only

Former Member
0 Likes
1,453

REPORT ychatest.

DATA : itab TYPE TABLE OF mara WITH HEADER LINE.

data : c type i.

LOOP AT itab.

IF itab-matnr = itab-matnr.

c = 5.

ELSE.

c = 4.

ENDIF.

WRITE: / sy-vline.

<b>format color = c.</b>

write: (10) itab-matnr.

<b>format color off.</b>

WRITE: (10) itab-matnr ,

sy-vline,

(10) itab-matnr ,

(10) itab-matnr .

ENDLOOP.

Read only

Former Member
0 Likes
1,453

Example 1 :

DATA col TYPE i VALUE 0.

DO 8 TIMES.

col = sy-index - 1.

FORMAT COLOR = col.

WRITE: / col COLOR OFF,

'INTENSIFIED ON' INTENSIFIED ON,

'INTENSIFIED OFF' INTENSIFIED OFF,

'INVERSE ON' INVERSE ON.

ENDDO.[/code] Example 2

IF SUIT = 'D' OR SUIT = 'H'.
          WRITE: PILE_SUIT NO-GAP COLOR 6 INTENSIFIED INVERSE HOTSPOT,
                 PILE_CARD COLOR 6 INTENSIFIED INVERSE HOTSPOT.
        ELSE.
          WRITE: PILE_SUIT NO-GAP COLOR OFF INTENSIFIED OFF HOTSPOT,
                 PILE_CARD COLOR OFF INTENSIFIED OFF HOTSPOT.
        ENDIF.

reward points if it is usefull

Girish

Read only

Former Member
0 Likes
1,453

LOOP AT itab.

IF itab-belnr1 = itab-belnr2.

c = 5.

ELSE.

c = 4.

ENDIF.

WRITE: / sy-vline.

format color = c.

write (10) itab-belnr1.

format color off.

write: (10) itab-datum1 ,

sy-vline,

(10) itab-belnr2 ,

(10) itab-datum2 .

ENDLOOP.

Message was edited by:

Tripat Pal Singh

Read only

Former Member
0 Likes
1,453

HI.

We cant give variable or char instead of number (from 1 to 7),but we can pass value by variables.

check this code ,it will help you.

Check this,

DATA col TYPE i VALUE 0.

DO 8 TIMES.

col = sy-index - 1.

FORMAT COLOR = col.

WRITE: / col COLOR OFF,

'INTENSIFIED ON' INTENSIFIED ON,

'INTENSIFIED OFF' INTENSIFIED OFF,

'INVERSE ON' INVERSE ON.

ENDDO.

Reward all helpfull answers.

Regards.

Jay

Read only

Former Member
0 Likes
1,453

hI piotr,

U should assigne values to 'c' betweeen 1-7 because there are 7 colors in abap directory.

1-Bluish

2-light gray

3-yellow

4-Dark grey

5-green

6-red

7-golden

U should use only these colors.

I think ur problem is solved.

Thanks

Sanket.

Read only

Former Member
0 Likes
1,453

hi,

The options COLOR of the FORMAT statement influence the colors of the output list.

To set colors in the program, use:

Syntax

FORMAT COLOR <n>.

<b>To set colors at runtime, use:</b>

Syntax

<b>FORMAT COLOR = <c>.</b>

These formatting options do not apply to horizontal lines created by ULINE. They have the following functions:

COLOR sets the color of the line background.

For <n> you can set either a color number or a color specification. Instead of color number 0, however, you must use OFF.

If you set the color numbers at runtime, all values of <c> that are less than zero or greater than seven, lead to undefined results. The following table summarizes the different possibilities:

analyse the sample program, it will solve your problem.

REPORT demo_list_format_color_1.

DATA i TYPE i VALUE 0.
DATA col(15) TYPE c.

WHILE i < 8.

  CASE i.
    WHEN 0. col = 'COL_BACKGROUND '.
    WHEN 1. col = 'COL_HEADING    '.
    WHEN 2. col = 'COL_NORMAL     '.
    WHEN 3. col = 'COL_TOTAL      '.
    WHEN 4. col = 'COL_KEY        '.
    WHEN 5. col = 'COL_POSITIVE   '.
    WHEN 6. col = 'COL_NEGATIVE   '.
    WHEN 7. col = 'COL_GROUP      '.
  ENDCASE.

  FORMAT INTENSIFIED COLOR = i.
  WRITE: /(4) i, AT 7            sy-vline,
            col,                 sy-vline,
            col INTENSIFIED OFF, sy-vline,
            col INVERSE.

  i = i + 1.

ENDWHILE.

In the FORMAT statement, the COLOR option for the subsequent WRITE statements is set at runtime. The other options are set individually for each WRITE statement in the program.

regards,

Ashok Reddy