Application Development 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: 

background color in reports

Former Member
0 Kudos

Hello there,

In the code below:


 DATA: lv_key TYPE i.
 format color lv_key intensified no-gap on.

I keep getting the error

<b>

"COLOR LV_KEY" is not expected; only 1 to 7 or the relevant color IDs

</b>

May I know is there anyway I could get around that? Unfortunately I can not hard-code the color in this case.

Thanks a lot!

Regards,

Anyi

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can do something like this.




DATA: lv_key TYPE i  VALUE 5. .


<b>FORMAT INTENSIFIED ON COLOR = lv_key .</b> 


Regards,

Rich HEilman

7 REPLIES 7

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please chcek this link for sample code.

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba1ae35c111d1829f0000e829fbfe/content.htm

Regards,

Ferry Lianto

Former Member
0 Kudos

Hi,

The options COLOR, INTENSIFIED, and INVERSE of the FORMATstatement influence the colors of the output list.

To set colors in the program, use:

Syntax

<b>FORMAT COLOR n [ON] INTENSIFIED [ON|OFF] INVERSE [ON|OFF].</b>

To set colors at runtime, use:

Syntax

<b>FORMAT COLOR = c INTENSIFIED = int INVERSE = inv.</b>

for this runtime, you can decalre the variables and use your algorithams and pass when you are writing FORMAT COLOR statment

Regards

Sudheer

Message was edited by: Sudheer Junnuthula

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can do something like this.




DATA: lv_key TYPE i  VALUE 5. .


<b>FORMAT INTENSIFIED ON COLOR = lv_key .</b> 


Regards,

Rich HEilman

0 Kudos

Hello Rich,

Thanks for your reply.

Unfortunately this lv_key stands for the local variable color which is initialized through some other algorithms. Therefore I can not assign lv_key as a constant.

Any other suggestions?

Regards,

Anyi

0 Kudos

????? I'm a little confused.

You want to assign the color from a variable, right?

report zrich_0002 .


data: lv_key type i.


do 7 times.
  lv_key = lv_key + 1.
  format color = lv_key intensified on.
  write:/ 'This is the color'.
enddo.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Anyi,

You can only specify a VALUE or COLOR CODE to COLOR attribute.

So try with this logic.

Use CASE...ENDCASE statements to resolve this issue.

CASS LV_KEY.

WHEN '1'.

FORMAT COLOR 1 INTENSIFIED ON.

WHEN '2'.

FORMAT COLOR 2 INTENSIFIED ON.

.....

WHEN '7'.

FORMAT COLOR 7 INTENSIFIED ON.

ENDCASE.

Thanks,

Vinay

ferry_lianto
Active Contributor
0 Kudos

Hi Anyi,

Did you check sample program from above link?

REPORT demo_list_format_color_1.

DATA lv_key TYPE i.

DATA col(15) TYPE c.

...

WHILE lv_key < 8.

CASE lv_key.

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) lv_key, AT 7 sy-vline,

col, sy-vline,

col INTENSIFIED OFF, sy-vline,

col INVERSE.

i = i + 1.

ENDWHILE.

Regards,

Ferry Lianto