alv read only cell attribe change

本文详细介绍了如何在SAP ALV网格中使用颜色,包括行、单元格和列的颜色设置。通过内部表和结构的定义,实现了不同条件下的颜色显示,如特定行的背景色、特定单元格的文本色以及特定列的强调色。

&---------------------------------------------------------------------
*& Report Z_ALV_TEST_002
*&
&---------------------------------------------------------------------
*&
*&
&---------------------------------------------------------------------

REPORT Z_ALV_TEST_002.
*&---------------------------------------------------------------------
**& Report ZLM_010
*&---------------------------------------------------------------------
**& http://scn.sap.com/message/1640274#1640274
*&---------------------------------------------------------------------
*REPORT zlm_010.

*REPORT zrich_0002 .


  • Use of colours in ALV grid (cell, line and column) *

  • Table
    TABLES : mara.

  • Type
    TYPES : BEGIN OF ty_mara,
    matnr LIKE mara-matnr,
    matkl LIKE mara-matkl,
    counter(4) TYPE n,
    free_text(15) TYPE c,
    color_line(4) TYPE c, " Line color
    color_cell TYPE lvc_t_scol, " Cell color
    END OF ty_mara.

  • Structures
    DATA : wa_mara TYPE ty_mara,
    wa_fieldcat TYPE lvc_s_fcat,
    is_layout TYPE lvc_s_layo,
    wa_color TYPE lvc_s_scol.

  • Internal table
    DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
    it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
    it_color TYPE TABLE OF lvc_s_scol.

  • Variables
    DATA : okcode LIKE sy-ucomm,
    w_alv_grid TYPE REF TO cl_gui_alv_grid,
    w_docking_container TYPE REF TO cl_gui_docking_container.

PARAMETERS : p_column AS CHECKBOX,
p_line AS CHECKBOX,
p_cell AS CHECKBOX.

AT SELECTION-SCREEN OUTPUT.

PERFORM get_data.
PERFORM fill_catalog.

IF w_docking_container IS INITIAL.
PERFORM create_objects.
ENDIF.

&--------------------------------------------------------------
*& Form create_objects
&--------------------------------------------------------------
FORM create_objects.

CREATE OBJECT w_docking_container
EXPORTING
ratio = 60
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.

CREATE OBJECT w_alv_grid
EXPORTING
i_parent = w_docking_container.

  • Field that identify color line in internal table
    MOVE ‘COLOR_LINE’ TO is_layout-info_fname.

  • Field that identify cell color in inetrnal table
    MOVE ‘COLOR_CELL’ TO is_layout-ctab_fname.

    CALL METHOD w_alv_grid->set_table_for_first_display
    EXPORTING
    is_layout = is_layout
    CHANGING
    it_outtab = it_mara
    it_fieldcatalog = it_fieldcat
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.

ENDFORM.
&--------------------------------------------------------------
*& Form get_data
&--------------------------------------------------------------
FORM get_data.

SELECT * FROM mara UP TO 5 ROWS.
CLEAR : wa_mara-color_line, wa_mara-color_cell.

MOVE-CORRESPONDING mara TO wa_mara.
ADD 1 TO wa_mara-counter.
MOVE ‘Blabla’ TO wa_mara-free_text.

IF wa_mara-counter = ‘0002’
AND p_line = ‘X’.

  • Color line
    MOVE ‘C410’ TO wa_mara-color_line.
    ELSEIF wa_mara-counter = ‘0004’
    AND p_cell = ‘X’.

  • Color cell
    MOVE ‘FREE_TEXT’ TO wa_color-fname.
    MOVE ‘6’ TO wa_color-color-col.
    MOVE ‘1’ TO wa_color-color-int.
    MOVE ‘1’ TO wa_color-color-inv.
    APPEND wa_color TO it_color.
    wa_mara-color_cell[] = it_color[].
    ENDIF.

    APPEND wa_mara TO it_mara.
    ENDSELECT.

ENDFORM.
&--------------------------------------------------------------
*& Form fill_catalog
&--------------------------------------------------------------
FORM fill_catalog.


  • Colour code : *
  • Colour is a 4-char field where : *
  •          - 1st char = C (color property)                  *
    
  •          - 2nd char = color code (from 0 to 7)            *
    
  •                              0 = background color         *
    
  •                              1 = blue                     *
    
  •                              2 = gray                     *
    
  •                              3 = yellow                   *
    
  •                              4 = blue/gray                *
    
  •                              5 = green                    *
    
  •                              6 = red                      *
    
  •                              7 = orange                   *
    
  •          - 3rd char = intensified (0=off, 1=on)           *
    
  •          - 4th char = inverse display (0=off, 1=on)       *
    
  •                                                           *
    
  • Colour overwriting priority : *
    1. Line *
    1. Cell *
    1. Column *

DATA : w_position TYPE i VALUE ‘1’.

CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE ‘MATNR’ TO wa_fieldcat-fieldname.
MOVE ‘MARA’ TO wa_fieldcat-ref_table.
MOVE ‘MATNR’ TO wa_fieldcat-ref_field.
APPEND wa_fieldcat TO it_fieldcat.

ADD 1 TO w_position.

CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE ‘MATKL’ TO wa_fieldcat-fieldname.
MOVE ‘MARA’ TO wa_fieldcat-ref_table.
MOVE ‘MATKL’ TO wa_fieldcat-ref_field.

  • Color column
    IF p_column = ‘X’.
    MOVE ‘C610’ TO wa_fieldcat-emphasize.
    ENDIF.
    APPEND wa_fieldcat TO it_fieldcat.

    ADD 1 TO w_position.

    CLEAR wa_fieldcat.
    MOVE w_position TO wa_fieldcat-col_pos.
    MOVE ‘COUNTER’ TO wa_fieldcat-fieldname.
    MOVE ‘N’ TO wa_fieldcat-inttype.
    MOVE ‘4’ TO wa_fieldcat-intlen.
    MOVE ‘Counter’ TO wa_fieldcat-coltext.
    APPEND wa_fieldcat TO it_fieldcat.

    ADD 1 TO w_position.

    CLEAR wa_fieldcat.
    MOVE w_position TO wa_fieldcat-col_pos.
    MOVE ‘FREE_TEXT’ TO wa_fieldcat-fieldname.
    MOVE ‘C’ TO wa_fieldcat-inttype.
    MOVE ‘20’ TO wa_fieldcat-intlen.
    MOVE ‘Text’ TO wa_fieldcat-coltext.
    APPEND wa_fieldcat TO it_fieldcat.

ENDFORM.

【事件触发一致性】研究多智能体网络如何通过分布式事件驱动控制实现有限时间内的共识(Matlab代码实现)内容概要:本文围绕多智能体网络中的事件触发一致性问题,研究如何通过分布式事件驱动控制实现有限时间内的共识,并提供了相应的Matlab代码实现方案。文中探讨了事件触发机制在降低通信负担、提升系统效率方面的优势,重点分析了多智能体系统在有限时间收敛的一致性控制策略,涉及系统模型构建、触发条件设计、稳定性与收敛性分析等核心技术环节。此外,文档还展示了该技术在航空航天、电力系统、机器人协同、无人机编队等多个前沿领域的潜在应用,体现了其跨学科的研究价值和工程实用性。; 适合人群:具备一定控制理论基础和Matlab编程能力的研究生、科研人员及从事自动化、智能系统、多智能体协同控制等相关领域的工程技术人员。; 使用场景及目标:①用于理解和实现多智能体系统在有限时间内达成一致的分布式控制方法;②为事件触发控制、分布式优化、协同控制等课题提供算法设计与仿真验证的技术参考;③支撑科研项目开发、学术论文复现及工程原型系统搭建; 阅读建议:建议结合文中提供的Matlab代码进行实践操作,重点关注事件触发条件的设计逻辑与系统收敛性证明之间的关系,同时可延伸至其他应用场景进行二次开发与性能优化。
【四旋翼无人机】具备螺旋桨倾斜机构的全驱动四旋翼无人机:建模与控制研究(Matlab代码、Simulink仿真实现)内容概要:本文围绕具备螺旋桨倾斜机构的全驱动四旋翼无人机展开,重点研究其动力学建模与控制系统设计。通过Matlab代码与Simulink仿真实现,详细阐述了该类无人机的运动学与动力学模型构建过程,分析了螺旋桨倾斜机构如何提升无人机的全向机动能力与姿态控制性能,并设计相应的控制策略以实现稳定飞行与精确轨迹跟踪。文中涵盖了从系统建模、控制器设计到仿真验证的完整流程,突出了全驱动结构相较于传统四旋翼在欠驱动问题上的优势。; 适合人群:具备一定控制理论基础和Matlab/Simulink使用经验的自动化、航空航天及相关专业的研究生、科研人员或无人机开发工程师。; 使用场景及目标:①学习全驱动四旋翼无人机的动力学建模方法;②掌握基于Matlab/Simulink的无人机控制系统设计与仿真技术;③深入理解螺旋桨倾斜机构对飞行性能的影响及其控制实现;④为相关课题研究或工程开发提供可复现的技术参考与代码支持。; 阅读建议:建议读者结合提供的Matlab代码与Simulink模型,逐步跟进文档中的建模与控制设计步骤,动手实践仿真过程,以加深对全驱动无人机控制原理的理解,并可根据实际需求对模型与控制器进行修改与优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值