当前位置:网站首页>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. 效果

边栏推荐
- Elimination games
- Tomb. Weekly update of Finance (February 7 - February 13)
- Audio audiorecord binder communication mechanism
- 【paddle】加载模型权重后预测报错AttributeError: ‘Model‘ object has no attribute ‘_place‘
- Tidb ecological tools (backup, migration, import / export) collation
- Software design principles
- jsscript
- What is the investment value of iFLYTEK, which does not make money?
- Princeton University, Peking University & UIUC | offline reinforcement learning with realizability and single strategy concentration
- 原型图设计
猜你喜欢

【Unity3D】GUI控件

华为、H3C、思科命令对比,思维导图形式从基础、交换、路由三大方向介绍【转自微信公众号网络技术联盟站】

I sorted out a classic interview question for my job hopping friends

Linear programming matlab

MySQL advanced notes

Taobao focus map layout practice

【若依(ruoyi)】启用迷你导航栏

【 kubernets series】 a Literature Study on the Safe exposure Applications of kubernets Service

Codeforces 5 questions par jour (1700 chacune) - jour 6

【概念】Web 基础概念认知
随机推荐
Self made CA certificate and SSL certificate using OpenSSL
How does yyds dry inventory deal with repeated messages in the consumption process?
Prototype design
Codeforces 5 questions par jour (1700 chacune) - jour 6
SD卡報錯“error -110 whilst initialising SD card
MySQL learning notes-10-tablespace recycling
JS regular filtering and adding image prefixes in rich text
My C language learning records (blue bridge) -- files and file input and output
codeforces每日5题(均1700)-第六天
电机控制反Park变换和反Clarke变换公式推导
IPv6 jobs
适合程序员学习的国外网站推荐
MySQL advanced notes
如何做好功能测试
Erreur de la carte SD "erreur - 110 whilst initialisation de la carte SD
继承day01
Precautions for single chip microcomputer anti reverse connection circuit
How to choose PLC and MCU?
【若依(ruoyi)】ztree 自定义图标(iconSkin 属性)
Taobao focus map layout practice