当前位置:网站首页>SAP ALV单元格级别设置颜色
SAP ALV单元格级别设置颜色
2022-07-06 03:12:00 【rogerix4】
=>Reference:SAP ALV颜色代码对应颜色(整理)
1. 代码
TYPES: BEGIN OF ty_alv,
id TYPE i,
color_code TYPE numc3,
color TYPE lvc_t_scol,
END OF ty_alv.
DATA: gt_alv TYPE TABLE OF ty_alv,
gs_layout TYPE lvc_s_layo,
gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
DEFINE fieldcat.
gt_fieldcat-fieldname = &1 . " 需要输出的内表的字段名
gt_fieldcat-ref_field = &2 .
gt_fieldcat-ref_table = &3 .
gt_fieldcat-scrtext_s = &4 .
APPEND gt_fieldcat.
CLEAR gt_fieldcat.
END-OF-DEFINITION.
INITIALIZATION.
START-OF-SELECTION.
PERFORM frm_fill_layout.
PERFORM frm_fill_fieldcat.
PERFORM frm_get_data.
PERFORM frm_fill_color.
END-OF-SELECTION.
PERFORM frm_display_data.
*--------------------------------------------------*
FORM frm_fill_layout .
gs_layout-cwidth_opt = abap_true . " 自动优化列宽
gs_layout-ctab_fname = 'COLOR'.
ENDFORM.
FORM frm_fill_fieldcat .
fieldcat: 'ID' '' '' '计数',
'COLOR_CODE' '' '' '颜色代码'.
ENDFORM.
FORM frm_display_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fieldcat[]
TABLES
t_outtab = gt_alv
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
FORM frm_get_data .
gt_alv = VALUE #( ( id = 1 color_code = '100' )
( id = 2 color_code = '200' )
( id = 3 color_code = '300' )
( id = 4 color_code = '400' )
( id = 5 color_code = '500' )
( id = 6 color_code = '600' )
( id = 7 color_code = '700' )
( id = 8 color_code = '101' )
( id = 9 color_code = '201' )
( id = 10 color_code = '301' )
( id = 11 color_code = '401' )
( id = 12 color_code = '501' )
( id = 13 color_code = '601' )
( id = 14 color_code = '701' )
( id = 15 color_code = '110' )
( id = 16 color_code = '210' )
( id = 17 color_code = '310' )
( id = 18 color_code = '410' )
( id = 19 color_code = '510' )
( id = 20 color_code = '610' )
( id = 21 color_code = '710' )
( id = 22 color_code = '111' )
( id = 23 color_code = '211' )
( id = 24 color_code = '311' )
( id = 25 color_code = '411' )
( id = 26 color_code = '511' )
( id = 27 color_code = '611' )
( id = 28 color_code = '711' ) ).
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_FILL_COLOR
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_fill_color.
DATA: ls_color TYPE lvc_s_scol.
LOOP AT gt_alv ASSIGNING FIELD-SYMBOL(<fs_alv>).
ls_color-fname = 'COLOR_CODE'.
MOVE <fs_alv>-color_code+(1) TO ls_color-color-col.
MOVE <fs_alv>-color_code+1(1) TO ls_color-color-int.
MOVE <fs_alv>-color_code+2(1) TO ls_color-color-inv.
APPEND ls_color TO <fs_alv>-color.
CLEAR ls_color.
ENDLOOP.
ENDFORM.
2. 效果
边栏推荐
- Custom attribute access__ getattribute__/ Settings__ setattr__/ Delete__ delattr__ method
- Some problem records of AGP gradle
- Item 10: Prefer scoped enums to unscoped enums.
- tcpdump: no suitable device found
- Advanced learning of MySQL -- Fundamentals -- isolation level of transactions
- Buuctf question brushing notes - [geek challenge 2019] easysql 1
- SD card reports an error "error -110 whilst initializing SD card
- Tidb ecological tools (backup, migration, import / export) collation
- 下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
- OCR文字識別方法綜述
猜你喜欢
[ruoyi] set theme style
Era5 reanalysis data download strategy
Recommended foreign websites for programmers to learn
Software design principles
Who is the winner of PTA
XSS challenges绕过防护策略进行 XSS 注入
Eight super classic pointer interview questions (3000 words in detail)
[Chongqing Guangdong education] higher mathematics I reference materials of Southwest Petroleum University
OCR文字識別方法綜述
NR modulation 1
随机推荐
Software design principles
Linear programming matlab
真机无法访问虚拟机的靶场,真机无法ping通虚拟机
Deep parsing pointer and array written test questions
Safety science to | travel, you must read a guide
Explore pointers and pointer types in depth
Jenkins basic knowledge ----- detailed explanation of 03pipeline code
How does yyds dry inventory deal with repeated messages in the consumption process?
【paddle】加载模型权重后预测报错AttributeError: ‘Model‘ object has no attribute ‘_place‘
Redis cache breakdown, cache penetration, cache avalanche
ASU & OSU | model based regularized off-line meta reinforcement learning
[Yu Yue education] basic reference materials of digital electronic technology of Xi'an University of Technology
Advanced learning of MySQL -- Fundamentals -- isolation level of transactions
Who is the winner of PTA
. Net 6 and Net core learning notes: Important issues of net core
深度解析指针与数组笔试题
C # create self host webservice
SD card reports an error "error -110 whilst initializing SD card
Single instance mode of encapsulating PDO with PHP in spare time
Crazy, thousands of netizens are exploding the company's salary