首页 > 其他分享 >ALV demo 05:cl_salv_table event

ALV demo 05:cl_salv_table event

时间:2022-10-14 20:38:36浏览次数:47  
标签:GR 05 demo cl TABLE DATA TYPE SPFLI SALV



效果图:

ALV demo 05:cl_salv_table event_微信

定义的status

ALV demo 05:cl_salv_table event_微信_02

ALV demo 05:cl_salv_table event_微信_03

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



DATA: GT_SPFLI TYPE TABLE OF SPFLI.
DATA: LS_SPFLI TYPE SPFLI.
DATA: GR_TABLE TYPE REF TO CL_SALV_TABLE.
DATA: GR_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS_LIST.
DATA: GR_EVENTS TYPE REF TO CL_SALV_EVENTS_TABLE.
DATA: GR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.

CLASS LCL_HANDLE_EVENTS DEFINITION.
PUBLIC SECTION.
METHODS:
ON_USER_COMMAND FOR EVENT ADDED_FUNCTION OF CL_SALV_EVENTS IMPORTING E_SALV_FUNCTION,
ON_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_SALV_EVENTS_TABLE IMPORTING ROW COLUMN.
ENDCLASS. "lcl_handle_events DEFINITION

DATA: EVENT_HANDLER TYPE REF TO LCL_HANDLE_EVENTS.

START-OF-SELECTION.

SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_SPFLI FROM SPFLI UP TO 100 ROWS.

CALL METHOD CL_SALV_TABLE=>FACTORY IMPORTING R_SALV_TABLE = GR_TABLE CHANGING T_TABLE = GT_SPFLI.

GR_TABLE->SET_SCREEN_STATUS( PFSTATUS = 'STATUS'
REPORT = SY-REPID
SET_FUNCTIONS = GR_TABLE->C_FUNCTIONS_ALL ).

GR_EVENTS = GR_TABLE->GET_EVENT( ).
CREATE OBJECT EVENT_HANDLER.
SET HANDLER EVENT_HANDLER->ON_USER_COMMAND FOR GR_EVENTS.
SET HANDLER EVENT_HANDLER->ON_DOUBLE_CLICK FOR GR_EVENTS.

* Set up selections.
GR_SELECTIONS = GR_TABLE->GET_SELECTIONS( ).
GR_SELECTIONS->SET_SELECTION_MODE( 1 ). "Single

* Display
GR_TABLE->DISPLAY( ).

CLASS LCL_HANDLE_EVENTS IMPLEMENTATION.
METHOD ON_USER_COMMAND.
"Get the selection rows
DATA: LR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.
DATA: LT_ROWS TYPE SALV_T_ROW.
DATA: LS_ROWS TYPE I.
DATA: MESSAGE TYPE STRING.
CASE E_SALV_FUNCTION.
WHEN 'TEST'.
LR_SELECTIONS = GR_TABLE->GET_SELECTIONS( ).
LT_ROWS = LR_SELECTIONS->GET_SELECTED_ROWS( ).

READ TABLE LT_ROWS INTO LS_ROWS INDEX 1.
READ TABLE GT_SPFLI INTO LS_SPFLI INDEX LS_ROWS.
CONCATENATE LS_SPFLI-CARRID LS_SPFLI-CONNID LS_SPFLI-CITYFROM LS_SPFLI-CITYTO INTO MESSAGE SEPARATED BY SPACE.
MESSAGE I001(00) WITH 'You pushed the button!' MESSAGE.
ENDCASE.
ENDMETHOD. "on_user_command

METHOD ON_DOUBLE_CLICK.
DATA: MESSAGE TYPE STRING.
DATA: ROW_C(4) TYPE C.
ROW_C = ROW.
CONCATENATE 'Row' ROW_C 'Column' COLUMN INTO MESSAGE SEPARATED BY SPACE.
MESSAGE I001(00) WITH 'You double-clicked on ' MESSAGE.
ENDMETHOD.
ENDCLASS.



QQ群 :SAP干货铺,  群号:775662808


标签:GR,05,demo,cl,TABLE,DATA,TYPE,SPFLI,SALV
From: https://blog.51cto.com/u_15680210/5757905

相关文章

  • ALV demo 04:cl_salv_table (ICONs and Tooltips)
    QQ群:SAP干货铺, 群号:775662808干货:​效果图:code:*&---------------------------------------------------------------------**&ReportZLM_ALV003*&*&sapliumeng*&----......
  • ALV demo 05:cl_salv_table(Apply Styles to Cell)
    QQ群:SAP干货铺, 群号:775662808所有群管理严格,严格禁止一切外来链接、招聘、广告等垃圾信息!效果:carrid列的第二行设置为热键,CONNID第三行设置为buttoncode:*&---------......
  • 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_森林木。群内禁止发广告及其他一切无关链接,小程序等,进群看公告,谢谢配合不修改昵称会被不定期踢除,谢谢配合有批导需求的......