ABAP: using colors as variables in a record

How to insert a color value into a variable?

for instance

this works for me:

write:/10 'test' COLOR COL_HEADING. 

I want the colors to be integer, so I tried:

 data: gv_mycolor type I. gv_mycolor = 5. write:/10 'test' COLOR gv_mycolor. 

the second code gives me an error: "The color gv_mycolor is not expected, only 1 to 7 or the corresponding color identifiers are allowed.

Operator use

 FORMAT COLOR = gv_mycolor. 

works for me. I have a problem with recording only. Can anyone help? thanks Thomas

+4
source share
2 answers
 DATA colour TYPE i VALUE 2. WRITE:/10 'test' COLOR = colour . 

You MUST use the equal sign, and all he needs ... ABAP and these are funny statements: P

+6
source

Edit: the first part of the answer is hidden, because it is incorrect - see the comment of the Owner and the answer

Short answer to your question: The syntax does not allow doing this according to the compiler message. The best you can do is combine the FORMAT and WRITE instructions in macro, but this is a very old school and probably will not teach you this is too important.

Take a look at the SLIS package, where there are many examples ( BCALV_GRID* ) on how to implement ALV lists and grids. They are used much more often, even in Web Dynpro. The CL_SALV* classes also provide a convenient, simplified (and supported) interface for implementing ALV grids. (See this answer for a complete example).

+1
source

All Articles