首页 > 其他分享 >ALV demo 05:cl_salv_table(Apply Styles to Cell)

ALV demo 05:cl_salv_table(Apply Styles to Cell)

时间:2022-10-14 20:37:52浏览次数:44  
标签:Styles cl demo CELLTYPE LS DATA TYPE SPFLI SALV



QQ群 :SAP干货铺,  群号:775662808
所有群管理严格,严格禁止一切外来链接、招聘、广告等垃圾信息!

效果:carrid 列的第二行 设置为热键,CONNID 第三行设置为button

ALV demo 05:cl_salv_table(Apply Styles to Cell)_微信


code:
*&---------------------------------------------------------------------*
*& Report ZLM_ALV004
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZLM_ALV004.

*
CLASS LCL_REPORT DEFINITION.
*
PUBLIC SECTION.


TYPES : BEGIN OF SPFLI_STRUC.
INCLUDE TYPE SPFLI.
TYPES : I_CELLTYPE TYPE SALV_T_INT4_COLUMN,
END OF SPFLI_STRUC.


DATA: GT_SPFLI TYPE STANDARD TABLE OF SPFLI_STRUC.

* ALV reference
DATA: O_ALV TYPE REF TO CL_SALV_TABLE.

METHODS:
GET_DATA, " data selection
GENERATE_OUTPUT. " Generating output
*
PRIVATE SECTION.
METHODS:
SET_COLUMNS. " Set columns
ENDCLASS. "lcl_report DEFINITION
*
*
START-OF-SELECTION.
DATA: LO_REPORT TYPE REF TO LCL_REPORT.
*
CREATE OBJECT LO_REPORT.
LO_REPORT->GET_DATA( ).
LO_REPORT->GENERATE_OUTPUT( ).


*
CLASS LCL_REPORT IMPLEMENTATION.
*
METHOD GET_DATA.
* data selection
SELECT *
FROM SPFLI
INTO CORRESPONDING FIELDS OF TABLE GT_SPFLI.


FIELD-SYMBOLS: <LFS_SPFLI> LIKE LINE OF GT_SPFLI.
DATA: LT_CELLTYPE TYPE SALV_T_INT4_COLUMN.
DATA: LS_CELLTYPE LIKE LINE OF LT_CELLTYPE.
LOOP AT GT_SPFLI ASSIGNING <LFS_SPFLI>.
CLEAR: LT_CELLTYPE.
* Only CARRID for 2nd record
IF SY-TABIX = 2.
LS_CELLTYPE-COLUMNNAME = 'CARRID'.
LS_CELLTYPE-VALUE = IF_SALV_C_CELL_TYPE=>HOTSPOT.
APPEND LS_CELLTYPE TO LT_CELLTYPE.
* Only CONNID for 3rd record
ELSEIF SY-TABIX = 3.
LS_CELLTYPE-COLUMNNAME = 'CONNID'.
LS_CELLTYPE-VALUE = IF_SALV_C_CELL_TYPE=>BUTTON.
APPEND LS_CELLTYPE TO LT_CELLTYPE.
* Entire 5th record
ELSEIF SY-TABIX = 5.
LS_CELLTYPE-COLUMNNAME = ".
LS_CELLTYPE-VALUE = IF_SALV_C_CELL_TYPE=>HOTSPOT.
APPEND LS_CELLTYPE TO LT_CELLTYPE.
ENDIF.
<LFS_SPFLI>-I_CELLTYPE = LT_CELLTYPE.
ENDLOOP.

ENDMETHOD. "get_data
*
METHOD GENERATE_OUTPUT.
* New ALV instance
DATA: LX_MSG TYPE REF TO CX_SALV_MSG.
TRY.
CL_SALV_TABLE=>FACTORY(
IMPORTING
R_SALV_TABLE = O_ALV
CHANGING
T_TABLE = GT_SPFLI ).
CATCH CX_SALV_MSG INTO LX_MSG.
ENDTRY.
*
* Setting up the Columns
ME->SET_COLUMNS( ).

* Displaying the ALV
O_ALV->DISPLAY( ).

ENDMETHOD. "generate_output
*
METHOD SET_COLUMNS.
*
*...Get all the Columns
DATA: LO_COLS TYPE REF TO CL_SALV_COLUMNS_TABLE.
LO_COLS = O_ALV->GET_COLUMNS( ).
*
* set the Column optimization
LO_COLS->SET_OPTIMIZE( 'X' ).

* Set the Cell Type
TRY.
LO_COLS->SET_CELL_TYPE_COLUMN( 'I_CELLTYPE' ).
CATCH CX_SALV_DATA_ERROR. "#EC NO_HANDLER
ENDTRY.

ENDMETHOD. "SET_COLUMNS
ENDCLASS. "lcl_report IMPLEMENTATION

标签:Styles,cl,demo,CELLTYPE,LS,DATA,TYPE,SPFLI,SALV
From: https://blog.51cto.com/u_15680210/5757907

相关文章

  • DEMO: BAPI_SALESORDER_CREATEFROMDAT2 创建订单
    REPORTzdemo_va01.PARAMETERSp_kunnrTYPEkunnrDEFAULT'1004615'.PARAMETERSp_vkorgTYPEvkorgDEFAULT'S600'.PARAMETERSp_vtwegTYPEvtwegDEFAULT'10'.PARAM......
  • DEMO: ALV显示明细
    本来需求是ALV双击某个字段的时候,弹出一个新ALV显示对应的明细,但是明细字段太多了,弹出来以后也挺难看的。就想起来SE11进去,查看数据点明细的时候于是就debug了下这个按钮大......
  • Demo:选择屏幕写页签
    效果图:demo代码需要特别注意的是abapmemory的应用文本版:*&---------------------------------------------------------------------**&ReportZLM_SCREEN3*&------------......
  • DEMO:冲销交货单过账凭证WS_REVERSE_GOODS_ISSUE
    reportzdemo_vl09.parametersp_vbelntypevbeln_vl.data:lt_likptypetableoflikp.data:ls_likplikelineoflt_likp.data:lt_mesg......
  • DEMO:MB1B 311 移库 BAPI_GOODSMVT_CREATE
    *&---------------------------------------------------------------------**&ReportZDEMO_MB1B*&*&---------------------------------------------------------------......
  • WDA DEMO 11 根据BAPI/Function创建WDA
    货铺QQ群号:834508274进群统一修改群名片,例如BJ_ABAP_森林木。群内禁止发广告及其他一切无关链接,小程序等,进群看公告,谢谢配合不修改昵称会被不定期踢除,谢谢配合事先声明下,本......
  • Demo:下载模板 02 使用SAP_CONVERT_TO_XLS_FORMAT
    货铺QQ群号:834508274进群统一修改群名片,例如BJ_ABAP_森林木。群内禁止发广告及其他一切无关链接,小程序等,进群看公告,谢谢配合不修改昵称会被不定期踢除,谢谢配合有批导需求的......
  • Demo:下载模板01 SMW0
    货铺QQ群号:834508274进群统一修改群名片,例如BJ_ABAP_森林木。群内禁止发广告及其他一切无关链接,小程序等,进群看公告,谢谢配合不修改昵称会被不定期踢除,谢谢配合有批导需求的......
  • WDA DEMO 03: 根据选择条件查询并显示
    下面开始干货:事先声明下,本人没参加过培训,也没看过完整的标准教程,所以一直都是野路子,土八路。所以文章中不足以及不正确的地方请大家帮忙指正。SE80新建。然后新建一个Attri......
  • 增强Demo 03 销售订单屏幕增强后BAPI增强
    干货:前面两篇文章分别介绍了销售订单抬头和行项目上屏幕增强的案例。屏幕上增加了俩字段,那BAPI创建修改的时候怎么处理?怎么把增强字段值写进去?使用BAPI的EXTENSIONIN参数可......