5

如何使用颜色值变量?例如,这对我有用:

write:/10  'test' COLOR COL_HEADING.

我认为颜色是整数,所以我尝试了:

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

第二个代码给了我一个错误:“颜色 gv_mycolor 不是预期的;只允许 1 到 7 或相关的颜色 ID。声明

FORMAT COLOR = gv_mycolor.

对我有用,我只是写语句有问题。

有人可以帮忙吗?

4

2 回答 2

8
DATA colour TYPE i VALUE 2.

WRITE:/10  'test' COLOR = colour .

你必须使用等号,这就是它的全部内容...... ABAP,这是有趣的陈述:P

于 2013-04-24T05:51:34.020 回答
0

Edit: First part of the answer is hidden as it is incorrect - see Vlad's comment & answer

Short answer to your question: The syntax does not allow you to do this as per the compiler message. The best you can do is to combine the FORMAT and WRITE statements in a macro, but this is very old-school, and will probably not teach you too much that is relevant.

Have a look at package SLIS where there are many examples (BCALV_GRID*) of how to implement ALV lists and grids. These are used much more frequently, even in Web Dynpro. The CL_SALV* classes also provides a nice simplified (and supported) interface to implement ALV grids. (See this answer for a full example).

于 2013-04-22T20:58:02.217 回答